Jean Noel wrote:
You should send a code snippet.
Event.h:
#include
#include
#include
#include
#include
#include
#include <fstream>
class SENSOR_Event{
friend class Sensor;
friend class AODVRTSensor;
friend class OLSRRTSensor;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar.register<NodeEvent>();
""// for each derived class
ar & time;
ar & sourceId;
ar & sourceType;
ar & eventType;
ar & *data;
}
protected:
double time;
int sourceId;
std::string sourceType;
std::string eventType;
DataNode *data;
public:
...
};
class NodeEvent : public SENSOR_Event{
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & boost::serialization::base_object(*this);
}
public:
NodeEvent();
NodeEvent(double nodeId, double x, double y, double z, double
speed);
};
...//other derived Events
BOOST_CLASS_EXPORT(NodeEvent);
""// for each derived class
BOOST_IS_ABSTRACT(SENSOR_Event);
Sensor.cc:
#include "Event.h"
void Sensor::send(const SENSOR_Event *event){
...
// serialize to string
std::stringstream s;
boost::archive::text_oarchive oa(s);
SENSOR_Event tmp = *event;
oa << tmp;
std::string p = s.str();
...
}
Error:
...
boost/archive/detail/oserializer.hpp: In function `void
boost::archive::save(Archive&, T&) [with Archive =
boost::archive::text_oarchive, T = SENSOR_Event]':
boost/archive/basic_text_oarchive.hpp:78: instantiated from `void
boost::archive::basic_text_oarchive<Archive>::save_override(T&, int)
[with T = SENSOR_Event, Archive = boost::archive::text_oarchive]'
boost/archive/detail/interface_oarchive.hpp:78: instantiated from
`Archive&
boost::archive::detail::interface_oarchive<Archive>::operator<<(T&)
[with T = SENSOR_Event, Archive = boost::archive::text_oarchive]'
IDSNet/Sensor.cc:24: instantiated from here
boost/archive/detail/oserializer.hpp:567: error: incomplete type `
boost::STATIC_ASSERTION_FAILURE<false>' does not have member `value'
What are the syntax error you get, and the error you get when doing a "BOOST_CLASS_EXPORT(derived);" ?
"syntax error before `;' token" for that line
I also have a problem with an abstract base class (although at link time, not compile time). Try removing the pure virtual function (just to see if it works).
this doesn't help
Another hint too would be to try to serialize a constant member; sometimes I had strange ASSERTION_FAILURE related to serialization of non-constants (this is also explained in the docs)
I'm serializing a constant member...