#include <Reactor.hpp>
Inherits pion::platform::PlatformPlugin.
Inherited by pion::plugins::DatabaseOutputReactor, pion::plugins::FilterReactor, pion::plugins::FissionReactor, pion::plugins::LogInputReactor, pion::plugins::LogOutputReactor, pion::plugins::PythonReactor, pion::plugins::ScriptReactor, and pion::plugins::TransformReactor.
Definition at line 45 of file Reactor.hpp.
Public Types | |
|
typedef boost::function1< void, EventPtr > | EventHandler |
| data type for a function that receives Events | |
| typedef std::vector< std::string > | QueryBranches |
| data type for a collection of uri path branches used for HTTP queries | |
| typedef StringDictionary | QueryParams |
| data type for a dictionary of strings (used for HTTP headers) | |
| TYPE_COLLECTION | |
| TYPE_PROCESSING | |
| TYPE_STORAGE | |
| enum | ReactorType { TYPE_COLLECTION, TYPE_PROCESSING, TYPE_STORAGE } |
| data type used to describe the type of Reactor | |
Public Member Functions | |
| virtual | ~Reactor () |
| virtual destructor: this class is meant to be extended | |
| virtual void | start (void) |
| called by the ReactorEngine to start Event processing | |
| virtual void | stop (void) |
| called by the ReactorEngine to stop Event processing | |
| virtual void | reset (void) |
| resets the Reactor to its initial state | |
| virtual void | clearStats (void) |
| clears statistic counters for the Reactor | |
| virtual void | setConfig (const Vocabulary &v, const xmlNodePtr config_ptr) |
| virtual void | updateVocabulary (const Vocabulary &v) |
| virtual void | updateCodecs (void) |
| virtual void | updateDatabases (void) |
| virtual void | updateProtocols (void) |
| virtual void | query (std::ostream &out, const QueryBranches &branches, const QueryParams &qp) |
| template<typename F> | |
| boost::signals::connection | subscribe (const std::string &signal_id, F f) |
| void | operator() (const EventPtr &e) |
| bool | startOutRunning (const xmlNodePtr config_ptr, bool exec_start) |
| void | addConnection (Reactor &output_reactor) |
| void | addConnection (const std::string &connection_id, EventHandler connection_handler) |
| void | removeConnection (const std::string &connection_id) |
| void | clearConnections (void) |
| clears all of the reactor's output connections | |
| void | writeStatsXML (std::ostream &out) const |
| write all XML statistics (including Reactor elements) for this Reactor to the output stream | |
| void | setScheduler (ReactionScheduler &scheduler) |
| sets the scheduler that will be used to deliver Events to other Reactors | |
| void | setMultithreadBranches (bool b) |
| sets the value of the "multithreaded branches" setting | |
| boost::uint32_t | getEventsIn (void) const |
| returns the total number of Events received by this Reactor | |
| boost::uint32_t | getEventsOut (void) const |
| returns the total number of Events delivered by this Reactor | |
| bool | isRunning (void) const |
| returns true if the Reactor is running | |
| ReactorType | getType (void) const |
| returns the type of Reactor (collection, processing, storage) | |
| std::string | getWorkspace (void) const |
| returns the ID of the Workspace the Reactor belongs to | |
Static Public Attributes | |
| static const std::string | REACTOR_ELEMENT_NAME = "Reactor" |
| name of the Reactor element for Pion XML config files | |
| static const std::string | RUNNING_ELEMENT_NAME = "Running" |
| name of the run status element for Pion XML config files | |
| static const std::string | WORKSPACE_ELEMENT_NAME = "Workspace" |
| name of the Workspace element for Pion XML config files | |
| static const std::string | X_COORDINATE_ELEMENT_NAME = "X" |
| name of the X Coordinate element for Pion XML config files | |
| static const std::string | Y_COORDINATE_ELEMENT_NAME = "Y" |
| name of the Y Coordinate element for Pion XML config files | |
Protected Types | |
|
typedef boost::signal3< void, const std::string &, const std::string &, void * > | SignalType |
| pointer to a named signal object - signature is (reactor_id, signal_name, void *) | |
|
typedef boost::shared_ptr< SignalType > | SignalPtr |
| pointer to a named signal object - signature is (reactor_id, signal_name, void *) | |
|
typedef PION_HASH_MAP< std::string, SignalPtr, PION_HASH_STRING > | SignalMap |
| data type for a map of signal names to signal object pointers | |
Protected Member Functions | |
| Reactor (const ReactorType type) | |
| constructs a new Reactor object | |
| ReactionScheduler & | getScheduler (void) |
| returns the task scheduler used by the ReactionEngine | |
| virtual void | process (const EventPtr &e) |
| void | deliverEvent (const EventPtr &e, bool return_immediately=false) |
| void | deliverEvents (const EventContainer &events, bool return_immediately=false) |
| void | incrementEventsIn (void) |
| void | publish (const std::string &signal_id) |
| void | signalNoLock (const std::string &signal_id, void *ptr=NULL) |
| void | signal (const std::string &signal_id, void *ptr=NULL) |
| void | writeStatsOnlyXML (std::ostream &out) const |
| write only XML statistics (excluding Reactor elements) for this Reactor to the output stream | |
| void | writeBeginReactorXML (std::ostream &out) const |
| write beginning XML element for this Reactor | |
| void | writeEndReactorXML (std::ostream &out) const |
| write ending XML element for this Reactor | |
Protected Attributes | |
| SignalMap | m_signals |
| map of signals supported by this reactor | |
| volatile bool | m_is_running |
| will be true if the Reactor is "running" | |
Friends | |
| class | ConfigReadLock |
| class | ConfigWriteLock |
Classes | |
| class | AlreadyConnectedException |
| exception thrown if you try to add a duplicate connection More... | |
| class | ConfigLockException |
| exception thrown if there is a problem obtaining a configuration lock More... | |
| class | ConfigReadLock |
| class | ConfigWriteLock |
| class | ConnectionNotFoundException |
| exception thrown if you try to remove a connection that does not exist More... | |
| class | MissingWorkspaceException |
| exception thrown if a Reactor configuration does not have a Workspace element (or it is empty) More... | |
| class | OutputConnection |
| data type used to represent Reactor output connections | |
| class | UnknownSignalException |
| exception thrown if an unknown signal is referenced More... | |
| void pion::platform::Reactor::addConnection | ( | const std::string & | connection_id, | |
| EventHandler | connection_handler | |||
| ) |
connects a handler to the output of this Reactor
| connection_id | unique identifier associated with the output connection | |
| connection_handler | function handler to which Events will be sent |
Definition at line 96 of file Reactor.cpp.
| void pion::platform::Reactor::addConnection | ( | Reactor & | output_reactor | ) |
connects another Reactor to the output of this Reactor
| connection_id | unique identifier associated with the output connection | |
| output_reactor | the Reactor to which output Events will be sent |
Definition at line 83 of file Reactor.cpp.
References pion::platform::PlatformPlugin::getId().
Referenced by pion::platform::ReactionEngine::addTempConnectionOut().
| void pion::platform::Reactor::deliverEvent | ( | const EventPtr & | e, | |
| bool | return_immediately = false | |||
| ) | [inline, protected] |
delivers an Event to the output connections. This is not thread-safe and should be called only while a ConfigReadLock is held by the thread
| e | pointer to the Event to deliver | |
| return_immediately | if true, all delivery will use other threads |
Definition at line 389 of file Reactor.hpp.
Referenced by pion::plugins::PythonReactor::deliverToConnections(), pion::plugins::TransformReactor::process(), pion::plugins::PythonReactor::process(), pion::plugins::LogOutputReactor::process(), pion::plugins::FissionReactor::process(), pion::plugins::FilterReactor::process(), and pion::plugins::DatabaseOutputReactor::process().
| void pion::platform::Reactor::deliverEvents | ( | const EventContainer & | events, | |
| bool | return_immediately = false | |||
| ) | [inline, protected] |
delivers a container of Events to the output connections. This is not thread-safe and should be called only while a ConfigReadLock is held by the thread
| events | a container of Events to deliver | |
| return_immediately | if true, all delivery will use other threads |
Definition at line 447 of file Reactor.hpp.
| void pion::platform::Reactor::incrementEventsIn | ( | void | ) | [inline, protected] |
increments the incoming Events counter. This is not thread-safe and should be called only when the Reactor's mutex is locked. processes a new Event. Derived Reactors should call deliverEvent() to send Events to output connections
| e | pointer to the Event to process |
Definition at line 464 of file Reactor.hpp.
| void pion::platform::Reactor::operator() | ( | const EventPtr & | e | ) | [inline] |
public function to process a new Event. checks to make sure the reactor is running, increments "events in" counter, and ensures configuration data is not being changed before calling the virtual process() function
| e | pointer to the Event to process |
Definition at line 213 of file Reactor.hpp.
| virtual void pion::platform::Reactor::process | ( | const EventPtr & | e | ) | [inline, protected, virtual] |
processes a new Event. Derived Reactors should call deliverEvent() to send Events to output connections
| e | pointer to the Event to process |
Reimplemented in pion::plugins::DatabaseOutputReactor, pion::plugins::FilterReactor, pion::plugins::FissionReactor, pion::plugins::LogOutputReactor, pion::plugins::PythonReactor, pion::plugins::ScriptReactor, and pion::plugins::TransformReactor.
Definition at line 378 of file Reactor.hpp.
| void pion::platform::Reactor::publish | ( | const std::string & | signal_id | ) | [inline, protected] |
publishes a new signal to which external observers may subscribe (should be called in constructor)
| signal_id | unique identifier for the signal |
Definition at line 471 of file Reactor.hpp.
Referenced by pion::plugins::LogInputReactor::LogInputReactor().
| void pion::platform::Reactor::query | ( | std::ostream & | out, | |
| const QueryBranches & | branches, | |||
| const QueryParams & | qp | |||
| ) | [virtual] |
handle an HTTP query (from QueryService)
| out | the ostream to write the statistics info into | |
| branches | URI stem path branches for the HTTP request | |
| qp | query parameters or pairs passed in the HTTP request |
Definition at line 128 of file Reactor.cpp.
References writeBeginReactorXML(), writeEndReactorXML(), and writeStatsOnlyXML().
Referenced by pion::platform::ReactionEngine::query(), and pion::platform::ReactionEngine::writeStatsXML().
| void pion::platform::Reactor::removeConnection | ( | const std::string & | connection_id | ) |
removes an existing output connection
| connection_id | unique identifier associated with the output connection |
Definition at line 109 of file Reactor.cpp.
| void pion::platform::Reactor::setConfig | ( | const Vocabulary & | v, | |
| const xmlNodePtr | config_ptr | |||
| ) | [virtual] |
sets configuration parameters for this Reactor
| v | the Vocabulary that this Reactor will use to describe Terms | |
| config_ptr | pointer to a list of XML nodes containing Reactor configuration parameters |
Reimplemented from pion::platform::PlatformPlugin.
Reimplemented in pion::plugins::DatabaseOutputReactor, pion::plugins::FilterReactor, pion::plugins::FissionReactor, pion::plugins::LogInputReactor, pion::plugins::LogOutputReactor, pion::plugins::PythonReactor, pion::plugins::ScriptReactor, and pion::plugins::TransformReactor.
Definition at line 43 of file Reactor.cpp.
References pion::platform::ConfigManager::getConfigOption(), pion::platform::PlatformPlugin::getId(), pion::platform::PlatformPlugin::setConfig(), and WORKSPACE_ELEMENT_NAME.
| void pion::platform::Reactor::signal | ( | const std::string & | signal_id, | |
| void * | ptr = NULL | |||
| ) | [inline, protected] |
emits a signal to all external observers which are subscribed
| signal_id | unique identifier for the signal | |
| ptr | points to an object that carries additional information about the signal |
Definition at line 497 of file Reactor.hpp.
| void pion::platform::Reactor::signalNoLock | ( | const std::string & | signal_id, | |
| void * | ptr = NULL | |||
| ) | [inline, protected] |
emits a signal to all external observers which are subscribed *without locking* (must already have ConfigReadLock or ConfigWriteLock)
| signal_id | unique identifier for the signal | |
| ptr | points to an object that carries additional information about the signal |
Definition at line 484 of file Reactor.hpp.
| bool pion::platform::Reactor::startOutRunning | ( | const xmlNodePtr | config_ptr, | |
| bool | exec_start | |||
| ) |
returns true if the reactor should be initialized in a "running" state
| config_ptr | pointer to a list of XML nodes containing Reactor configuration parameters | |
| exec_start | if true, and the reactor is not running, and it should be initialized in a "running" state, then attempt to start the reactor |
Definition at line 62 of file Reactor.cpp.
References pion::platform::ConfigManager::getConfigOption(), getType(), isRunning(), RUNNING_ELEMENT_NAME, and start().
Referenced by pion::platform::ReactionEngine::restartReactorsThatShouldBeRunning().
| boost::signals::connection pion::platform::Reactor::subscribe | ( | const std::string & | signal_id, | |
| F | f | |||
| ) | [inline] |
subscribes an external observer to a named signal
| signal_id | unique identifier for the signal | |
| f | callback function or slot to connect to the signal - signature must be (const std::string&, const std::string&, void*) |
Definition at line 198 of file Reactor.hpp.
Referenced by pion::platform::ReactionEngine::subscribe().
| virtual void pion::platform::Reactor::updateCodecs | ( | void | ) | [inline, virtual] |
this updates the Codecs that are used by this Reactor; it should be called whenever any Codec's configuration is updated
Reimplemented in pion::plugins::FissionReactor, pion::plugins::LogOutputReactor, and pion::plugins::ScriptReactor.
Definition at line 163 of file Reactor.hpp.
Referenced by pion::platform::ReactionEngine::updateCodecs().
| virtual void pion::platform::Reactor::updateDatabases | ( | void | ) | [inline, virtual] |
this updates the Databases that are used by this Reactor; it should be called whenever any Database's configuration is updated
Reimplemented in pion::plugins::DatabaseOutputReactor.
Definition at line 169 of file Reactor.hpp.
Referenced by pion::platform::ReactionEngine::updateDatabases().
| virtual void pion::platform::Reactor::updateProtocols | ( | void | ) | [inline, virtual] |
this updates the Protocols that are used by this Reactor; it should be called whenever any Protocol's configuration is updated
Definition at line 175 of file Reactor.hpp.
Referenced by pion::platform::ReactionEngine::updateProtocols().
| void pion::platform::Reactor::updateVocabulary | ( | const Vocabulary & | v | ) | [virtual] |
this updates the Vocabulary information used by this Reactor; it should be called whenever the global Vocabulary is updated
| v | the Vocabulary that this Reactor will use to describe Terms |
Reimplemented from pion::platform::PlatformPlugin.
Reimplemented in pion::plugins::DatabaseOutputReactor, pion::plugins::FilterReactor, pion::plugins::FissionReactor, pion::plugins::LogOutputReactor, pion::plugins::PythonReactor, pion::plugins::ScriptReactor, and pion::plugins::TransformReactor.
Definition at line 56 of file Reactor.cpp.
References pion::platform::PlatformPlugin::updateVocabulary().
1.4.7