Re: [Boost-users] [serialization]
I still got some starting problems with the boost::serialization library. I want to serialize a shared_ptr to my own polymorphic class. I'm building my own networkprotocol and the basic idea is a kind of "header"-class which with a shared_ptr
which can point to a lot of different data structs, which are polymorphic children of data_base. This "header"-class is then serialized and send to another peer. But how should this peer get the real type from the shared_ptr
? Which child is it pointing to? I can get the name with "typeid()", but i cannot get the type through that way. I would like to get the type from it automaticly without using some case-conditions, so i only have to add a new child of data_base and can use it, without changing any networkprotocol related code. Kind Regards Manuel Jung
This isn't really related to Boost.Serialization, but I think You might get what You want using the visitor pattern. That's how I manage the different message bodies in my latest project at work. (See http://en.wikipedia.org/wiki/Visitor_pattern). HTH, Johan Franzén
participants (1)
-
Johan Franzén