torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SingleInstance.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 #ifndef HAVE_CONFIG_H
17 #include "torc/generic/config.h"
18 #endif
19 
20 #ifdef GENOM_SERIALIZATION
21 #include <boost/archive/binary_iarchive.hpp>
22 #include <boost/archive/binary_oarchive.hpp>
23 #include <boost/serialization/base_object.hpp>
24 #include <boost/serialization/export.hpp>
25 #endif //GENOM_SERIALIZATION
27 
28 #ifdef GENOM_SERIALIZATION
29 BOOST_CLASS_EXPORT(torc::generic::SingleInstance)
30 #endif //GENOM_SERIALIZATION
31 namespace torc {
32 namespace generic {
33 
34 /**
35  * Create a single instance.
36  * @param[in] inName Name of the single instance to be created.
37  * @param[in] inViewPtr Pointer to parented(View) object.
38  * @param[in] inMasterPtr Pointer to master(View) object.
39  * @param[in] inOriginalName Original name of the single instance [optional].
40  *
41  * @return Pointer to created single instance.
42  */
44  const ViewSharedPtr& inViewPtr, const ViewSharedPtr& inMasterPtr,
45  const std::string& inOriginalName) throw (Error) {
46  try {
47  SingleInstanceSharedPtr newSingleInstance;
48  create(newSingleInstance);
49  newSingleInstance->setName(inName);
50  newSingleInstance->setMaster(inMasterPtr);
51  newSingleInstance->setOriginalName(inOriginalName);
52  inViewPtr->addInstance(newSingleInstance);
53  return newSingleInstance;
54  } catch(Error& e) {
55  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
56  throw;
57  }
58 }
59 
60 void SingleInstance::accept(BaseVisitor& inoutVisitor) throw (Error) {
61  try {
62  runVisitor(*this, inoutVisitor);
63  } catch(Error& e) {
64  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
65  throw;
66  }
67 }
68 
70 
72 
73 #ifdef GENOM_SERIALIZATION
74 template <class Archive> void SingleInstance::serialize(Archive& ar, unsigned int) {
75  ar & boost::serialization::base_object<Instance>(*this);
76  ar & boost::serialization::base_object<
77  Scalar<Instance> >(*this);
78 }
79 
80 //TO SATISFY THE LINKER
81 template void SingleInstance::serialize<boost::archive::binary_iarchive>(
82  boost::archive::binary_iarchive& ar, const unsigned int);
83 
84 template void SingleInstance::serialize<boost::archive::binary_oarchive>(
85  boost::archive::binary_oarchive& ar, const unsigned int);
86 
87 #endif //GENOM_SERIALIZATION
88 
89 }// namespace generic
90 } // namespace torc
A single object with no child objects.
Definition: Scalar.hpp:34
Represents an instantiation of a cell view in the view of another cell.
virtual void accept(BaseVisitor &inoutVisitor)
Represents a single instance of the view of a cell.
void runVisitor(_Tp &inoutVisited, BaseVisitor &inoutVisitor)
Definition: VisitorType.hpp:78
std::string string
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
A base class for Visitor.
Definition: VisitorType.hpp:31
virtual SingleInstanceSharedPtr newSingleInstancePtr(const std::string &inName, const ViewSharedPtr &inViewPtr, const ViewSharedPtr &inMasterPtr, const std::string &inOriginalName=std::string())
boost::shared_ptr< View > ViewSharedPtr
boost::shared_ptr< SingleInstance > SingleInstanceSharedPtr
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:73