When trying to save the database using boost serialization, I encounter the segfault that I could not resolve. Would you please help? Any suggestion is greately appreciated. I've pinned down the statement below as the culprit but not sure of how to resolve it
oa << *this;
My code section is below:
template<class Archive>
void nDB::serialize(Archive &ar, const unsigned int version) {
ar & _LAYERS;
ar & _MACROS;
ar & _MODULES;
ar & _INSTS;
}
void nDB::save_db(string filename) {
std::ofstream ofs(filename.c_str(), std::ios::out | std::ios::binary);
//assert(ofs.good());
boost::archive::binary_oarchive oa(ofs);
oa << *this;
ofs.close();
}
Hi, I was able to pin point the issue to a circular reference in my database. The code are below:
template<class Archive>
void pin::serialize(Archive &ar, const unsigned int version) {
ar & pin_Port;
ar & pin_Layer;
}
and
template<class Archive>
void port::serialize(Archive & ar, const unsigned int version){
ar & port_Name;
ar & port_Use;
ar & port_Dir;
ar & port_PINS;
}
Hi below are my class definition
class pin {
public:
port* pin_Port;
layer* pin_Layer;
// rect* pin_shape;
pin();
~pin();
void set_port(port*);
void set_layer(layer*);
string get_name();
port* get_port();
layer* get_layer();
string get_layer_name();
double get_layer_width();
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version);
};
class port {
public:
string port_Name;
char port_Use;
char port_Dir;
pin_vector port_PINS;
port();
~port();
void set_name(string);
void set_use(int);
void set_dir(int);
string get_name(void);
string get_use(void);
string get_dir(void);
void add_pin(pin*);
pin_vector get_all_pins(void);
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version);
};