17 #ifndef JUBATUS_CORE_CLUSTERING_EVENT_DISPATCHER_HPP_
18 #define JUBATUS_CORE_CLUSTERING_EVENT_DISPATCHER_HPP_
22 #include "jubatus/util/lang/function.h"
26 namespace clustering {
29 template <
typename EventType,
typename EventData>
31 typedef jubatus::util::lang::function<void (const EventData&)>
callback_t;
41 void dispatch(
const EventType& type,
const EventData& data)
const;
45 template <
typename EventType,
typename EventData>
47 const EventType& type,
49 events_[type].push_back(callback);
52 template <
typename EventType,
typename EventData>
54 const EventType& type,
55 const EventData& data)
const {
56 typename event_type_table::const_iterator ev = events_.find(type);
57 if (ev == events_.end()) {
60 typename callbacks_t::const_iterator it;
61 for (it = ev->second.begin(); it != ev->second.end(); ++it) {
70 #endif // JUBATUS_CORE_CLUSTERING_EVENT_DISPATCHER_HPP_
std::vector< callback_t > callbacks_t
void dispatch(const EventType &type, const EventData &data) const
jubatus::util::lang::function< void(const EventData &)> callback_t
void add_event_listener(const EventType &type, callback_t callback)
virtual ~event_dispatcher()
std::map< EventType, callbacks_t > event_type_table