Processes incoming messages and then calls the appropriate function. More...
Public Types | |
|
typedef boost::shared_ptr < OpProcessor > | SharedPtr |
|
typedef Poco::Delegate< TObj, Tonido::Data::Message::SharedPtr > | ProcessDelegate |
|
typedef BootHashMap < std::string, ProcessDelegate > | ProcessMap |
Public Member Functions | |
| OpProcessor () | |
| Ctor. | |
| ~OpProcessor () | |
| Dtor. | |
| void | registerOperation (const std::string &a_operation, ProcessDelegate a_pd) |
| Registers the function handler for a given operation. | |
| bool | processOperation (Tonido::Data::Message::SharedPtr &a_msg, bool ignoreNotFound=false) |
| Processes the incoming message and dispatches the message. | |
Processes incoming messages and then calls the appropriate function.
Convenience class for managing incoming messages
Class MyClass
{
private:
DECLARE_BOOTMESSAGE_HANDLER(DoThis);
DECLARE_BOOTMESSAGE_HANDLER(DoThat);
DECLARE_BOOTMESSAGE_MAP(MyClass);
}
// ... then in the class constructor for example
// ... setup the map
MyClass::MyClass()
{
BEGIN_BOOTMESSAGE_MAP
ON_BOOTMESSAGE("DoThis", MyClass, DoThis)
ON_BOOTMESSAGE("DoThat", MyClass, DoThat)
END_BOOTMESSAGE_MAP
}
// ... Assuming you have functions like this
MyClass::DoThis(const void* pSender,
Message::SharedPtr& args)
{
}
MyClass::DoThat(const void* pSender,
Message::SharedPtr& args)
{
}
// ... When you get a message to be dispatched
// ... Just do the following, message type being
// ... Message::SharedPtr&
PROCESS_BOOTMESSAGE(message);
| Tonido::Util::OpProcessor< TObj >::OpProcessor | ( | ) |
Ctor.
details if needed ...
| Tonido::Util::OpProcessor< TObj >::~OpProcessor | ( | ) |
Dtor.
details if needed ...
| bool Tonido::Util::OpProcessor< TObj >::processOperation | ( | Tonido::Data::Message::SharedPtr & | a_msg, |
| bool | ignoreNotFound = false |
||
| ) |
Processes the incoming message and dispatches the message.
| [in] | a_msg | Incoming Message |
| void Tonido::Util::OpProcessor< TObj >::registerOperation | ( | const std::string & | a_operation, |
| ProcessDelegate | a_pd | ||
| ) |
Registers the function handler for a given operation.
| [in] | a_operation | Operation Name |
| [in] | a_pd | ProcessDelegate which points to the function to be invoked |