Archived

This topic is now archived and is closed to further replies.

Trying not to send a class to do a templates job

This topic is 6367 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

    
class QuitMessageHandler : public BaseMessageIndex
{
public:
	QuitMessageHandler()
	{
		RegisterID(MESSAGE_QUIT);
	}
private :
	static void dummy(void);
};
[/source]

Ok, I''m implementing pluggable factories and would like to know how I might turn this code in to a template. At first it seems easy however the RegisterID line could be called an unknown number of times with different values (MESSAGE_QUIT is an enum constant). Some code to indicate what I''m trying to achieve:

[source]
template <funcname,enum,...>
class GenericMessageHandler
{
public:
	GenericMessageHandler()
	{
		RegisterID(MESSAGE_QUIT);
		RegisterID(MESSAGE_EXIT); //??? can I loop to get all the paramaters

		//etc

		//Make a ''new'' funcname function

		
	}
private :
	static void dummy(void);
};
    
In theory the compiler should be able to work out a dynamic number of argumets but I''m not sure if the language could support what I''m trying to do. gimp

Share this post


Link to post
Share on other sites