Original Post
(Following is based on the "Pluggable Factories Rock My Multiplayer World"]
Ok, this is driving me nuts. I designed my system with these as THE core component for handling my queue''s.
I''m still trying to make ''pluggable factories'' actually work, and , I''m pretty sure I''m getting the class pointers wrong. If you havent read the tutorial here is a short of whats happening.
Class B is derived from class A. Class B has a static member fucntion that causes it to be initialised at startup(whatever that means). Now, when class B''s static member is initialised the constructor is called. The constructor sends a pointer to itself through to class A where it is recorded in a map.
Now the problem I have is that I''m not entirly sure of the syntax for passing this pointer. I also don''t understand if the initialised class that is started at app start is a full object?(as in the same as a ''newed'' one)
The following code shows a meager attempt at understanding this subject:
In my specific example I''m planning on registering two different types of messages, so eventially there will be two maps, one for console messages, the other for normal MessageID(enum) messages.
If anyone has any source code it would be of help...
Many thanks
gimp
class MessageRegistry
{
public:
RegisterMessageID(unsigned char messageid,this)
{
Registry.insert(messageid,this);
}
RegisterString(string messagestring,this)
{
Registry.insert(messagestring,this);
}
this Switch(unsigned char messageid)
{
return Registry.find(messageid).second;
}
protected:
typedef MessageRegistry* MessageHandlerPtr;
typedef map<string,MessageHandlerPtr> RegistryMap;
static RegistryMap Registry;
};
|