[gameprogrammer] Fun with the preprocessor
- From: "Kevin Jenkins" <gameprogrammer@xxxxxxxxxx>
- To: <gameprogrammer@xxxxxxxxxxxxx>
- Date: Fri, 21 May 2004 22:18:03 -0700
I'm doing something with synchronized memory in classes. Here is the gist
of what I would like to do.
In the header file, inside the class:
class MyClass
{
vector position;
int orientation;
START_SYNCHRONIZATION(BaseClass)
SYNCHRONIZE(vector, position);
SYNCHRONIZE(int, orientation);
...
END_SYNCHRONIZATION
}
I want the defines (all in caps) to expand to two functions and a copy of
each variable with a different name.
SerializeClass(BitStream *bitStream)
{
BaseClass::SerializeClass(bitStream)
Serialize(position, bitStream);
Serialize(orientation, bitStream);
}
DeserializeClass(BitStream *bitStream)
{
BaseClass::DeserializeClass(bitStream)
Deserialize(position,bitStream);
Deserialize(orientation,bitStream);
}
vector variableCopy_position;
int variableCopy_orientation;
Any way to do this with what I have here? There is one way, which is to
pass all paramters to the #define to begin with. I.E.
SUPER_SYNCHRONIZE(base_class, type1, variablename1, type2, variablename2)
Problem with that is I want to support an unlimited number of paramters. I
guess I can write this define out until type99, variablename99, and hope
nobody does more than 99 parameters. But that is sort of ugly and stupid.
Any better way?
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] test
- From: Dave Slutzkin
- [gameprogrammer] Re: test
- From: David Olofson
- [gameprogrammer] Re: test
- From: Dave Slutzkin
- [gameprogrammer] Pure virtual function getting called
- From: Kevin Jenkins
- [gameprogrammer] Re: Pure virtual function getting called
- From: Dave Slutzkin
Other related posts:
- » [gameprogrammer] Fun with the preprocessor
- [gameprogrammer] test
- From: Dave Slutzkin
- [gameprogrammer] Re: test
- From: David Olofson
- [gameprogrammer] Re: test
- From: Dave Slutzkin
- [gameprogrammer] Pure virtual function getting called
- From: Kevin Jenkins
- [gameprogrammer] Re: Pure virtual function getting called
- From: Dave Slutzkin