Jeff Thompson | a04f23c | 2013-09-16 17:48:38 -0700 | [diff] [blame^] | 1 | /** |
| 2 | * Copyright (C) 2013 Regents of the University of California. |
| 3 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NDN_CHANGED_EVENT_HPP |
| 8 | #define NDN_CHANGED_EVENT_HPP |
| 9 | |
| 10 | #include <vector> |
| 11 | #include "../common.hpp" |
| 12 | |
| 13 | namespace ndn { |
| 14 | |
| 15 | /** |
| 16 | * An OnChanged function object is called to notify a listener of a changed event. |
| 17 | */ |
| 18 | typedef func_lib::function<void()> OnChanged; |
| 19 | |
| 20 | class ChangedEvent { |
| 21 | public: |
| 22 | /** |
| 23 | * Add onChanged to the listener list. This does not check if a duplicate is already in the list. |
| 24 | * @param onChanged The OnChanged function object. |
| 25 | */ |
| 26 | void add(OnChanged onChanged) |
| 27 | { |
| 28 | listeners_.push_back(onChanged); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Call all the listeners. |
| 33 | */ |
| 34 | void fire(); |
| 35 | |
| 36 | #if 0 |
| 37 | private: |
| 38 | #endif |
| 39 | std::vector<OnChanged> listeners_; |
| 40 | }; |
| 41 | |
| 42 | } |
| 43 | |
| 44 | #endif |