23 #ifdef GENOM_SERIALIZATION
24 #include <boost/archive/binary_iarchive.hpp>
25 #include <boost/archive/binary_oarchive.hpp>
26 #include <boost/serialization/base_object.hpp>
27 #include <boost/serialization/list.hpp>
28 #include <boost/serialization/shared_ptr.hpp>
29 #include <boost/serialization/string.hpp>
30 #endif //GENOM_SERIALIZATION
58 #ifdef GENOM_SERIALIZATION
59 std::list< std::string >::iterator it = std::find(mDumpedLibraries.begin(),
60 mDumpedLibraries.end(), name);
61 if(it != mDumpedLibraries.end()) {
66 #endif //GENOM_SERIALIZATION
67 if(
false == mLibraries.set(name, inLibrary)) {
72 inLibrary->setParent(getSharedThis());
91 #ifdef GENOM_SERIALIZATION
92 std::list< std::string >::iterator it = std::find(mDumpedLibraries.begin(),
93 mDumpedLibraries.end(), inName);
94 if(it == mDumpedLibraries.end()) {
99 mDumpedLibraries.erase(it);
101 #endif //GENOM_SERIALIZATION
102 if(
false == mLibraries.remove(inName)) {
116 #ifdef GENOM_SERIALIZATION
117 restoreAllLibraries();
118 #endif //GENOM_SERIALIZATION
132 #ifdef GENOM_SERIALIZATION
133 if(!library && !mDumpedLibraries.empty()) {
134 library = restoreSingleLibrary(inName);
136 #endif //GENOM_SERIALIZATION
153 if(
false == mDesignSymTab.set(name, inDesign)) {
158 inDesign->setParent(getSharedThis());
172 if(
false == mDesignSymTab.remove(inName)) {
216 newRoot->setName(inName);
217 newRoot->setLevel(inEdifLevel);
218 newRoot->setOriginalName(inOriginalName);
255 #ifdef GENOM_SERIALIZATION
257 void Root::setDumpRestoreData(
const DumpRestoreData& inDumpRestoreData) {
258 mDumpRestoreData = inDumpRestoreData;
261 void Root::handleNewDumpRestoreData(
const DumpRestoreData& inDumpRestoreData)
throw(Error) {
262 mDumpRestoreData = inDumpRestoreData;
263 if(mDumpRestoreData.getRestoreAllComponents()) {
265 restoreAllLibraries();
267 e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__ );
273 #endif //GENOM_SERIALIZATION
276 #ifdef GENOM_SERIALIZATION
277 , mDumpRestoreData(), mDumpedLibraries()
282 log(
"Root destroyed\n");
285 #ifdef GENOM_SERIALIZATION
286 template <
class Archive>
void Root::load(Archive& ar,
unsigned int) {
287 ar & boost::serialization::base_object<Commentable>(*this);
288 ar & boost::serialization::base_object<Nameable>(*this);
289 ar & boost::serialization::base_object<Renamable>(*this);
290 ar & boost::serialization::base_object<Visitable>(*this);
291 ar & boost::serialization::base_object<SelfReferencing<Root> >(*this);
295 ar & mDumpedLibraries;
300 template <
class Archive>
void Root::save(Archive& ar,
unsigned int)
const {
301 typedef std::vector< LibrarySharedPtr > Libs;
302 ar & boost::serialization::base_object<Commentable>(*this);
303 ar & boost::serialization::base_object<Nameable>(*this);
304 ar & boost::serialization::base_object<Renamable>(*this);
305 ar & boost::serialization::base_object<Visitable>(*this);
306 ar & boost::serialization::base_object<SelfReferencing<Root> >(*this);
312 Libs::iterator lib = libs.begin();
313 Libs::iterator end = libs.end();
314 for(; lib != end; ++lib) {
319 e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__ );
322 mDumpedLibraries.push_back((*lib)->getName());
324 ar & mDumpedLibraries;
325 mDumpedLibraries.clear();
335 std::list< std::string >::iterator lib = find(mDumpedLibraries.begin(),
336 mDumpedLibraries.end(), inName);
337 if(lib == mDumpedLibraries.end()) {
340 library = restore(*lib, getSharedThis());
342 mDumpedLibraries.erase(lib);
346 e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__ );
352 void Root::restoreAllLibraries() throw(Error) {
354 std::vector<std::string> libs;
355 libs.insert(libs.end(), mDumpedLibraries.begin(), mDumpedLibraries.end());
356 for(std::vector<std::string>::iterator lib = libs.begin(); lib != libs.end(); ++lib) {
358 restoreSingleLibrary(*lib);
360 e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__ );
365 e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__ );
371 template void Root::load<boost::archive::binary_iarchive>(boost::archive::binary_iarchive& ar,
374 template void Root::save<boost::archive::binary_oarchive>(boost::archive::binary_oarchive& ar,
375 const unsigned int)
const;
382 dump(inRoot, inRoot->getDumpRestoreData());
384 e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__ );
389 void dump(
const RootSharedPtr& inRoot,
const DumpRestoreData& inData )
throw(Error) {
393 if(inRoot->getName().empty()) {
396 if(inData.getDumpPath().empty()) {
399 inRoot->setDumpRestoreData(inData);
401 fileName += inRoot->getName() +
".root";
402 std::ofstream dout(fileName.c_str(), std::ios::out | std::ios::binary);
406 boost::archive::binary_oarchive rootAr(dout);
415 if(inData.getDumpPath().empty()) {
419 fileName += inName +
".root";
420 std::ifstream din(fileName.c_str(), std::ios::out | std::ios::binary);
424 boost::archive::binary_iarchive rootAr(din);
428 root->handleNewDumpRestoreData(inData);
430 e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__ );
436 #endif //GENOM_SERIALIZATION
void getValues(std::vector< ValueType > &outValues) const
void log(const char *fmt,...)
virtual void getDesigns(std::vector< DesignSharedPtr > &outDesigns)
void setVersion(const EdifVersion &inSource)
SymTab< std::string, LibrarySharedPtr > mLibraries
Represents class that can hold userData.
void runVisitor(_Tp &inoutVisited, BaseVisitor &inoutVisitor)
boost::shared_ptr< Design > DesignSharedPtr
virtual void removeDesign(const std::string &inName)
The Error object thrown by different methods of EdifOM.
virtual RootSharedPtr newRootPtr(const std::string &inName, const EdifLevel &inEdifLevel=eEdifLevel0, const std::string &inOriginalName=std::string())
boost::shared_ptr< Library > LibrarySharedPtr
A base class for Visitor.
bool get(const KeyType &inKey, ValueType &outValue) const
void saveContextData(const std::string &inName, const boost::any &inSource)
Root of the EDIF Object Model.
virtual void getLibraries(std::vector< LibrarySharedPtr > &outLibraries)
virtual void addLibrary(const LibrarySharedPtr &inLibrary)
virtual LibrarySharedPtr findLibrary(const std::string &inName)
An object that has a name.
virtual void removeLibrary(const std::string &inName)
Represents objects that can be renamed.
virtual void addDesign(const DesignSharedPtr &inDesign)
Represents objects that have status.
virtual DesignSharedPtr findDesign(const std::string &inName)
void setLevel(const EdifLevel &inSource)
virtual void accept(BaseVisitor &inoutVisitor)
boost::shared_ptr< Root > RootSharedPtr
SymTab< std::string, DesignSharedPtr > mDesignSymTab
An object that receives an inoutVisitor.
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)