Public Types | Public Member Functions
Tonido::Util::OpProcessor< TObj > Class Template Reference

Processes incoming messages and then calls the appropriate function. More...

List of all members.

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.

Detailed Description

template<class TObj>
class Tonido::Util::OpProcessor< TObj >

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);

Constructor & Destructor Documentation

template<class TObj>
Tonido::Util::OpProcessor< TObj >::OpProcessor ( )

Ctor.

details if needed ...

template<class TObj>
Tonido::Util::OpProcessor< TObj >::~OpProcessor ( )

Dtor.

details if needed ...


Member Function Documentation

template<class TObj>
bool Tonido::Util::OpProcessor< TObj >::processOperation ( Tonido::Data::Message::SharedPtr &  a_msg,
bool  ignoreNotFound = false 
)

Processes the incoming message and dispatches the message.

Parameters:
[in]a_msgIncoming Message
Returns:
true if the message was routed, false otherwise
template<class TObj>
void Tonido::Util::OpProcessor< TObj >::registerOperation ( const std::string &  a_operation,
ProcessDelegate  a_pd 
)

Registers the function handler for a given operation.

Parameters:
[in]a_operationOperation Name
[in]a_pdProcessDelegate which points to the function to be invoked
Returns:
none

Generated on Wed Oct 12 2011 21:46:54. © CodeLathe LLC 2007-2011. All Rights Reserved.