blob: e20f3d5f845a56f3d62a24c0491ddd1132cd2396 [file] [log] [blame]
Jeff Thompson25b4e612013-10-10 16:03:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Jeff Thompsona04f23c2013-09-16 17:48:38 -07002/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
5 * See COPYING for copyright and distribution information.
6 */
7
8#ifndef NDN_CHANGED_EVENT_HPP
Jeff Thompsone589c3f2013-10-12 17:30:50 -07009#define NDN_CHANGED_EVENT_HPP
Jeff Thompsona04f23c2013-09-16 17:48:38 -070010
11#include <vector>
Jeff Thompson25b4e612013-10-10 16:03:24 -070012#include <ndn-cpp/common.hpp>
Jeff Thompsona04f23c2013-09-16 17:48:38 -070013
14namespace ndn {
15
16/**
17 * An OnChanged function object is called to notify a listener of a changed event.
18 */
19typedef func_lib::function<void()> OnChanged;
20
21class ChangedEvent {
22public:
23 /**
24 * Add onChanged to the listener list. This does not check if a duplicate is already in the list.
25 * @param onChanged The OnChanged function object.
26 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070027 void
28 add(OnChanged onChanged)
Jeff Thompsona04f23c2013-09-16 17:48:38 -070029 {
30 listeners_.push_back(onChanged);
31 }
32
33 /**
34 * Call all the listeners.
35 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070036 void
37 fire();
Jeff Thompsona04f23c2013-09-16 17:48:38 -070038
39#if 0
40private:
41#endif
42 std::vector<OnChanged> listeners_;
43};
44
45}
46
47#endif