torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InstanceArrayMember.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
29 
30 #ifdef GENOM_SERIALIZATION
31 BOOST_CLASS_EXPORT(torc::generic::InstanceArrayMember)
32 #endif //GENOM_SERIALIZATION
33 namespace torc {
34 namespace generic {
35 
36 /**
37  * Receive an inoutVisitor to this class. The visit method of the inoutVisitor is called and a
38  * reference to this object is passed as a parameter. It has to be noted however, that a
39  * dynamic_cast is performed inside this method. If the cast fails, an appropriate exception is
40  * thrown by this method. This situation can arise when the passed Visitor object does not inherit
41  * from the appropriate inoutVisitor specialization. See Visitor documentation for more details.
42  *
43  * @param[in,out] inoutVisitor A reference to the inoutVisitor object
44  * @exception Error Visitor type inappropriate for visiting this object or any other error thrown
45  * by the Visitor::throw() method.
46  */
47 void InstanceArrayMember::accept(BaseVisitor& inoutVisitor) throw (Error) {
48  try {
49  runVisitor(*this, inoutVisitor);
50  } catch(Error& e) {
51  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
52  throw;
53  }
54 }
55 
58  if(!parent) {
59  return ParameterContext();
60  }
61  return parent->getParameterContext();
62 }
63 
64 /**
65  * Get the ParameterMap corresponding to this instance and it's master
66  *
67  * @return A ParameterMap consisiting of only the overridden parameters.
68  */
71  if(!parent) {
72  Error e(eMessageIdErrorPointerToItemDoesNotExist, __FUNCTION__, __FILE__, __LINE__);
73  e.saveContextData("Parent Collection", parent);
74  throw e;
75  }
76  return parent->getParameters();
77 }
78 
80 
82 
83 #ifdef GENOM_SERIALIZATION
84 template <class Archive> void InstanceArrayMember::serialize(Archive& ar, unsigned int) {
85  ar & boost::serialization::base_object<Instance>(*this);
86  ar & boost::serialization::base_object<
87  VectorBit<Instance> >(*this);
88 }
89 
90 //TO SATISFY THE LINKER
91 template void InstanceArrayMember::serialize<boost::archive::binary_iarchive>(
92  boost::archive::binary_iarchive& ar, const unsigned int);
93 
94 template void InstanceArrayMember::serialize<boost::archive::binary_oarchive>(
95  boost::archive::binary_oarchive& ar, const unsigned int);
96 
97 #endif //GENOM_SERIALIZATION
98 
99 } // namespace generic
100 } // namespace torc
boost::shared_ptr< Instance > InstanceSharedPtr
Represents an instantiation of a cell view in the view of another cell.
Represents a member of an instance array.
virtual ParameterContext getParameterContext() const
void runVisitor(_Tp &inoutVisited, BaseVisitor &inoutVisitor)
Definition: VisitorType.hpp:78
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
virtual Pointer getParentCollection() const
A base class for Visitor.
Definition: VisitorType.hpp:31
virtual void accept(BaseVisitor &inoutVisitor)
void saveContextData(const std::string &inName, const boost::any &inSource)
Definition: Error.cpp:79
virtual ParameterMapSharedPtr getParameters() const
Represents a single element of a vector composition.
Definition: VectorBit.hpp:41
boost::shared_ptr< ParameterMap > ParameterMapSharedPtr
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:73