|
Boost Users : |
From: tankbattle (tankbattle_at_[hidden])
Date: 2006-10-10 08:27:54
I'm using boost::serialization now and, indeed, it is very powerful, especially
in type identification and object tracking, which make me very convenient.
However, I think the lack of construction-time deserialization a pitfall.
Usually the semantic of constructor is that either the constructed object is
valid or an exception is thrown. However, boost::serialization require
programmers provide a default constructor to construct an empty object and a
load method (or serialize) to really initialize the object. Such a mechanism
cannot prevent from invoking load method other than one time. Whatâs more, the
default constructor usually lacks information to completely initialize the
object, sometimes, it is even impossible to initialize. For instance,
class B
{
public:
void operator() (){â¦}
}
class A
{
private:
B* pB;
boost::thread m_theThread;//make use of pB->operator() as the entry
point
};
In the code above, pB in A cannot be correctly initialized in default
constructor, but m_theThread MUST be initialized there. What entry point should
we provide to m_theThread?
I think serialization mechanism (especially deserialization part) should be
provided for constructors. A tricky problem is how can constructor-time
deserialization be coherent with that in âloadâ method and however can we
eliminate duplicate code is another issue.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net