Jump to content
  • Advertisement
Sign in to follow this  
supagu

custom RTTI - using the preprocessor

This topic is 3971 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

i have my own run time type info. system which goes something like this:
class BaseClass
{
enum
	{
		Type = -1,
		ParentType = -1,
	};

	virtual unsigned int GetType() { return Type; }
	virtual unsigned int GetParentType() { return ParentType; }
};

class ClassA : public BaseClass
{
enum
	{
		Type = 1,
		ParentType = BaseClass::Type,
	};


	virtual unsigned int GetType() { return Type; }
	virtual unsigned int GetParentType() { return ParentType; }
};

class ClassB : public ClassA
{
enum
	{
		Type = 2,
		ParentType = ClassA::Type,
	};


	virtual unsigned int GetType() { return Type; }
	virtual unsigned int GetParentType() { return ParentType; }
};

now, i want to change this to use macros, and i want the preprocessor to generate the Type = xxx I saw a thread on here once about a preprocessor macro that would increment a value each time it was used, but i forgot what it was.

Share this post


Link to post
Share on other sites
Advertisement
__COUNTER__ is almost certainly reset for each compilation unit though, so you'll probably need to define all of your IDs in one unit (Or header and make sure that __COUNTER__ isn't used elsewhere).

Share this post


Link to post
Share on other sites
i assume __COUNTER__ is microsoft specific, better than nothing for now though :) . Would also be nice if there was a general cross platform solution.

Can you explain further how this typelists' can be used for RTTI?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!