blob: ce4b20f1724156308ec212af41b82fd8b8d1684b [file] [log] [blame]
Jeff Thompsona04f23c2013-09-16 17:48:38 -07001/**
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
13namespace ndn {
14
15/**
16 * An OnChanged function object is called to notify a listener of a changed event.
17 */
18typedef func_lib::function<void()> OnChanged;
19
20class ChangedEvent {
21public:
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 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070026 void
27 add(OnChanged onChanged)
Jeff Thompsona04f23c2013-09-16 17:48:38 -070028 {
29 listeners_.push_back(onChanged);
30 }
31
32 /**
33 * Call all the listeners.
34 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070035 void
36 fire();
Jeff Thompsona04f23c2013-09-16 17:48:38 -070037
38#if 0
39private:
40#endif
41 std::vector<OnChanged> listeners_;
42};
43
44}
45
46#endif