Hello,
My previous post contained a minimal example, which was incomplete,
deliberately so as not to bloat the post with code. However Jeff Flynn
has requested a minimal code example.
I have attached several files for classes to this e-mail.
* BaseClass - the base class, which has a serialize method
* DerivedClass - a sub-class with its own serialize method
* InstantiableClass - the class actually instantiated from DerivedClass
* Main - code example of the client/server that serializes and
de-serializes the InstantiableClass object.
Our system automatically inserts some pre-compiled headers so
to get the code to compile you may need to add your own #includes.
The output from the main program is this:
Serializing...
BOOST: I am an Instantiable class object
BOOST: I am in BaseClass::serialize
De-serializing...
BOOST: I am an Instantiable class object
BOOST: I am in BaseClass::serialize
Assertion failed: dynamic_cast(object).getCom() ==
20, file Main.cc, line 8
This highlights the polymorphism problem in a nutshell. The overloaded
what() method is telling me that in both the client and server code
the objects is an InstantiableClass object. However the Derived::serialize
is not being called on either side. Thus the data (m_com) from the
DerivedClass
is not being serialized and is lost.
The compiler, and debugger, is telling me my object is an InstantiableClass,
however when boost calls serialize on the object, the code in the BaseClass
and not the Derived class is being called.
Any help greatly appreciated.
--
Marcus A.T MacWilliam, Senior Software Engineer. 1Spatial Ltd.
Tel: +44 (0)1223 420414, ext 2289, Mob: +44 (0)7803 706597.
E-Mail: marcus.macwilliam@1spatial.com Skype:marcus.macwilliam
Tennyson House, 7 Cambridge Business Park, Cambridge, CB4 0WZ.
Registered in England No. 4785688, VAT Reg. No. 135539408.
Website: http://www.1spatial.com/ E-mail: info@1spatial.com