21 #include <boost/bind.hpp>
22 #include <boost/mem_fn.hpp>
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/is_abstract.hpp>
28 #include <boost/serialization/map.hpp>
29 #include <boost/serialization/shared_ptr.hpp>
30 #endif //GENOM_SERIALIZATION
44 #ifdef GENOM_SERIALIZATION
45 class RestoredInstanceUpdater {
49 inInst->setParent(mView);
50 inInst->restoreMaster();
52 e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__ );
57 RestoredInstanceUpdater(
const ViewSharedPtr& inView) : mView(inView) {}
61 #endif //GENOM_SERIALIZATION
77 newView->setName(inName);
78 newView->setParent(inCellPtr);
79 newView->setType(inViewType);
80 newView->setOriginalName(inOriginalName);
81 inCellPtr->addView(newView);
120 std::vector<InstanceSharedPtr>::const_iterator instance = inSource.begin();
121 std::vector<InstanceSharedPtr>::const_iterator end = inSource.end();
122 for(; instance != end; ++instance) {
124 addInstance(*instance);
144 e.
saveContextData(
"Pointer to the instance object does not exist", inInstance);
153 if(
false == mInstanceSymTab.set(name, inInstance)) {
158 inInstance->setParent(getSharedThis());
198 std::vector<PortReferenceSharedPtr> refs;
199 instance->getPortReferences(refs);
200 for_each(refs.begin(), refs.end(),
202 if(
false == mInstanceSymTab.remove(inName)) {
220 std::vector<NetSharedPtr>::const_iterator net = inSource.begin();
221 std::vector<NetSharedPtr>::const_iterator end = inSource.end();
222 for(; net != end; ++net) {
250 if(
false == mNetSymTab.set(name, inNet)) {
255 inNet->setParent(getSharedThis());
292 if(
false == mNetSymTab.remove(inName)) {
305 std::vector<PortSharedPtr>::const_iterator port = inSource.begin();
306 std::vector<PortSharedPtr>::const_iterator end = inSource.end();
307 for(; port != end; ++port) {
335 if(
false == mPortSymTab.set(name, inPort)) {
340 inPort->setParent(getSharedThis());
378 if(
false == mPortSymTab.remove(inName)) {
397 std::vector<PermutableSharedPtr>::const_iterator entry = inSource.begin();
398 std::vector<PermutableSharedPtr>::const_iterator end = inSource.end();
399 for(; entry != end; ++entry) {
401 addPermutable(*entry);
418 e.
saveContextData(
"Pointer to the permutable object does not exist", inPermutable);
422 mPermutables.push_back(inPermutable);
437 std::vector<InterfaceJoinedInfoSharedPtr>::const_iterator entry = inSource.begin();
438 std::vector<InterfaceJoinedInfoSharedPtr>::const_iterator end = inSource.end();
439 for(; entry != end; ++entry) {
441 addInterfaceJoinedInfo(*entry);
458 e.
saveContextData(
"Pointer to the joined info object does not exist", inJoinedInfo);
462 mInterfaceJoinedInfos.push_back(inJoinedInfo);
500 mParameters(new
ParameterMap()), mMyContext(mParameters->getNewContext()), mInstanceSymTab(),
501 mNetSymTab(), mPortSymTab(), mType(eTypeNetlist), mPermutables(), mInterfaceJoinedInfos(),
502 mAttributes(), mSimulate(), mTiming() {}
506 log(
"View %s is being destroyed.\n",
getName().c_str());
516 #ifdef GENOM_SERIALIZATION
517 template <
class Archive>
void View::load(Archive& ar,
unsigned int) {
518 ar & boost::serialization::base_object<Extern>(*this);
519 ar & boost::serialization::base_object<Nameable>(*this);
520 ar & boost::serialization::base_object<PropertyContainer>(*this);
521 ar & boost::serialization::base_object<Renamable>(*this);
522 ar & boost::serialization::base_object<SelfReferencing<View> >(*this);
523 ar & boost::serialization::base_object<Visitable>(*this);
528 std::map<std::string, ParameterSharedPtr> params;
531 std::map<std::string, ParameterSharedPtr>::iterator
533 std::map<std::string, ParameterSharedPtr>::iterator
535 for(; it != end; ++it) {
540 template <
class Archive>
void View::save(Archive& ar,
unsigned int)
const {
541 ar & boost::serialization::base_object<Extern>(*this);
542 ar & boost::serialization::base_object<Nameable>(*this);
543 ar & boost::serialization::base_object<PropertyContainer>(*this);
544 ar & boost::serialization::base_object<Renamable>(*this);
545 ar & boost::serialization::base_object<SelfReferencing<View> >(*this);
546 ar & boost::serialization::base_object<Visitable>(*this);
551 std::map<std::string,ParameterSharedPtr> params;
556 void View::restoreActions() throw(Error) {
558 mInstanceSymTab.applyOnAll(RestoredInstanceUpdater(
getSharedThis()));
559 mInstanceSymTab.applyOnAll(boost::bind(boost::mem_fn(&
Net::setParent), _1,
561 mInstanceSymTab.applyOnAll(boost::bind(boost::mem_fn(&
Port::setParent), _1,
564 e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
570 template void View::load<boost::archive::binary_iarchive>(boost::archive::binary_iarchive& ar,
573 template void View::save<boost::archive::binary_oarchive>(boost::archive::binary_oarchive& ar,
574 const unsigned int)
const;
576 #endif //GENOM_SERIALIZATION
void setNets(const std::vector< NetSharedPtr > &inSource)
ParameterContext mMyContext
void removeInstance(const std::string &inName)
void log(const char *fmt,...)
boost::shared_ptr< Instance > InstanceSharedPtr
bool addPermutable(const PermutableSharedPtr &inPermutable)
ParameterMapSharedPtr getParameters()
An object that has a parent.
SymTab< std::string, NetSharedPtr > mNetSymTab
Represents objects that have properties.
void addNet(const NetSharedPtr &inNet)
void setTiming(const TimingSharedPtr &inSource)
Represents and EDIF View.
void addInstance(const InstanceSharedPtr &inInstance)
void setInstances(const std::vector< InstanceSharedPtr > &inSource)
boost::shared_ptr< Permutable > PermutableSharedPtr
void setType(const Type &inSource)
void removePort(const std::string &inName)
Represents class that can hold userData.
bool addInterfaceJoinedInfo(const InterfaceJoinedInfoSharedPtr &inJoinedInfo)
void setSimulate(const SimulateSharedPtr &inSource)
void applyOnAll(const _Action &action)
void addPort(const PortSharedPtr &inPort)
std::vector< InterfaceJoinedInfoSharedPtr > mInterfaceJoinedInfos
boost::shared_ptr< Simulate > SimulateSharedPtr
void runVisitor(_Tp &inoutVisited, BaseVisitor &inoutVisitor)
virtual void disconnect()
void setPorts(const std::vector< PortSharedPtr > &inSource)
The Error object thrown by different methods of EdifOM.
void setNonNetlistViewData(const std::string &inData)
virtual void accept(BaseVisitor &inoutVisitor)
boost::shared_ptr< Net > NetSharedPtr
A base class for Visitor.
std::vector< PermutableSharedPtr > mPermutables
bool get(const KeyType &inKey, ValueType &outValue) const
void saveContextData(const std::string &inName, const boost::any &inSource)
SymTab< std::string, PortSharedPtr > mPortSymTab
ParameterMapSharedPtr mParameters
virtual void disconnect()
NetSharedPtr findNet(const std::string &inName)
boost::shared_ptr< InterfaceAttributes > InterfaceAttributesSharedPtr
InstanceSharedPtr findInstance(const std::string &inName)
void removeNet(const std::string &inName)
void setInterfaceJoinedInfos(const std::vector< InterfaceJoinedInfoSharedPtr > &inSource)
virtual const std::string getName() const
boost::shared_ptr< View > ViewSharedPtr
boost::shared_ptr< Cell > CellSharedPtr
void setInterfaceAttributes(const InterfaceAttributesSharedPtr &inSource)
An object that has a name.
boost::shared_ptr< InterfaceJoinedInfo > InterfaceJoinedInfoSharedPtr
Pointer getSharedThis() const
boost::shared_ptr< Port > PortSharedPtr
virtual void setParent(const boost::shared_ptr< View > &inSource)
SymTab< std::string, InstanceSharedPtr > mInstanceSymTab
Represents objects that can be renamed.
std::string mNonNetlistViewData
Represents objects that have status.
boost::shared_ptr< Timing > TimingSharedPtr
SimulateSharedPtr mSimulate
void setPermutables(const std::vector< PermutableSharedPtr > &inSource)
InterfaceAttributesSharedPtr mAttributes
virtual ViewSharedPtr newViewPtr(const std::string &inName, const CellSharedPtr &inCellPtr, const View::Type &inViewType=View::eTypeNetlist, const std::string &inOriginalName=std::string())
boost::shared_ptr< ParameterMap > ParameterMapSharedPtr
An object that receives an inoutVisitor.
PortSharedPtr findPort(const std::string &inName)
Used to implement external object referencing.
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)