Jump to content
  • Advertisement

Archived

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

gimp

Trying not to send a class to do a templates job

This topic is 6577 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
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!