jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
jubatus::core::clustering::event_dispatcher< EventType, EventData > Class Template Reference

#include <event_dispatcher.hpp>

Inheritance diagram for jubatus::core::clustering::event_dispatcher< EventType, EventData >:
Inheritance graph
Collaboration diagram for jubatus::core::clustering::event_dispatcher< EventType, EventData >:
Collaboration graph

Public Member Functions

void add_event_listener (const EventType &type, callback_t callback)
 
virtual ~event_dispatcher ()
 

Protected Member Functions

void dispatch (const EventType &type, const EventData &data) const
 

Protected Attributes

event_type_table events_
 

Private Types

typedef jubatus::util::lang::function< void(const EventData &)> callback_t
 
typedef std::vector< callback_tcallbacks_t
 
typedef std::map< EventType, callbacks_tevent_type_table
 

Detailed Description

template<typename EventType, typename EventData>
class jubatus::core::clustering::event_dispatcher< EventType, EventData >

Definition at line 30 of file event_dispatcher.hpp.

Member Typedef Documentation

template<typename EventType, typename EventData>
typedef jubatus::util::lang::function<void (const EventData&)> jubatus::core::clustering::event_dispatcher< EventType, EventData >::callback_t
private

Definition at line 31 of file event_dispatcher.hpp.

template<typename EventType, typename EventData>
typedef std::vector<callback_t> jubatus::core::clustering::event_dispatcher< EventType, EventData >::callbacks_t
private

Definition at line 32 of file event_dispatcher.hpp.

template<typename EventType, typename EventData>
typedef std::map<EventType, callbacks_t> jubatus::core::clustering::event_dispatcher< EventType, EventData >::event_type_table
private

Definition at line 33 of file event_dispatcher.hpp.

Constructor & Destructor Documentation

template<typename EventType, typename EventData>
virtual jubatus::core::clustering::event_dispatcher< EventType, EventData >::~event_dispatcher ( )
inlinevirtual

Definition at line 36 of file event_dispatcher.hpp.

36 {}

Member Function Documentation

template<typename EventType, typename EventData >
void jubatus::core::clustering::event_dispatcher< EventType, EventData >::add_event_listener ( const EventType &  type,
callback_t  callback 
)

Definition at line 46 of file event_dispatcher.hpp.

48  {
49  events_[type].push_back(callback);
50 }
template<typename EventType, typename EventData>
void jubatus::core::clustering::event_dispatcher< EventType, EventData >::dispatch ( const EventType &  type,
const EventData &  data 
) const
protected

Definition at line 53 of file event_dispatcher.hpp.

55  {
56  typename event_type_table::const_iterator ev = events_.find(type);
57  if (ev == events_.end()) {
58  return;
59  }
60  typename callbacks_t::const_iterator it;
61  for (it = ev->second.begin(); it != ev->second.end(); ++it) {
62  (*it)(data);
63  }
64 }

Member Data Documentation

template<typename EventType, typename EventData>
event_type_table jubatus::core::clustering::event_dispatcher< EventType, EventData >::events_
protected

Definition at line 42 of file event_dispatcher.hpp.


The documentation for this class was generated from the following file: