I am having a problem where I am trying to serialize a message of a template class. The template's class message is of type BaseClass, but I want it to serialize the derived versions of the class. As of right now, it is only serializing the BaseClass. How am I supposed to register with boost::serialization the types of the derived classes that I want it to serialize? I have tried several methods such as using the 'BOOST_CLASS_EXPORT' macro. Also I have tried using this example:
ar.register_type(static_cast<bus_stop_corner *>(NULL));
from here: http://www.boost.org/doc/libs/1_36_0/libs/serialization/example/demo_gps.hpp but still no luck.
template <class T>
class Frame{
...
private:
T message;
};
class BaseType{};
class SubTypeA : public BaseType{};
class SubTypeB : public BaseType{};
int main(){
std::vector< Frame<BaseType> > myFrames;
//add a bunch of Frame<SubTypeA> and Frame<SubTypeB> objects to the myFrames vector.
//serialize the vector.
return 0;
}
This code is not compilable at all, but was included to give you an idea of the structure of my program.