Menu

Member Functions

Timothy Hollies

Member Functions

In order to make storing calls to member functions safe, classes which want to register a member function with a 'dispatch_manager' have to have store lightweight RAII structures, one for each registered member function. The type for these objects is contained within the 'dispatch_manager' class to ensure compatibility.

class TestClass
{

delayed::dispatch_manager<delayed::adler32>::member_connector connector;</delayed::adler32>

bool someMemberFunction(int a)
{
//code
return true;
}

TestClass()
{
connector.connect( "test", &dispatchManager, this, &TestClass::someMemberFunction);
}

};

To register the member function call the 'connect' member function of the 'member_connector' with the parameters as the functions ID, a reference to the dispatch_manager the function is to be registered to, a pointer to the instance the function is to be invoked on, and a reference to the member function.

When the instance of TestClass is destroyed the member function is automatically unregistered.