torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParameterArray.hpp
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 TORC_GENERIC_PARAMETERARRAY_HPP
17 #define TORC_GENERIC_PARAMETERARRAY_HPP
18 
20 
21 //BOOST
22 #ifdef GENOM_SERIALIZATION
23 #include <boost/serialization/access.hpp>
24 #endif //GENOM_SERIALIZATION
25 #include "torc/generic/Error.hpp"
29 #include "torc/generic/Vector.hpp"
31 
32 namespace torc { namespace generic { class BaseVisitor; } }
33 
34 namespace torc {
35 namespace generic {
36 
37 /**
38  * @brief Represents a parameter array.
39  *
40  * The ParameterArray class represents an array of parameters.
41  */
42 class ParameterArray : public Parameter, public Vector<Parameter, ParameterArrayElement,
43  ParameterArrayElement::Factory, false> {
44 #ifdef GENOM_SERIALIZATION
45  friend class boost::serialization::access;
46 #endif //GENOM_SERIALIZATION
47  friend class FactoryType<ParameterArray> ;
48 
49 public:
53 
54  /**
55  * Convenience class to create a parameter array.
56  */
57  class Factory : public FactoryType<ParameterArray> {
58  public:
60  /**
61  * Create a parameter array.
62  *
63  * @param[in] inName Name of the parameter array to be created.
64  * @param[in] inSize Size of the instance array.
65  * @param[in] inFactory Factory for the child.
66  * @param[in] inOriginalName Original name of the parameter array [optional].
67  *
68  * @return Pointer to created parameter array.
69  */
71  const size_t& inSize, const ChildFactorySharedPtr& inFactory
73  const std::string& inOriginalName = std::string()) throw (Error);
74 
75  /**
76  * Create a parameter array.
77  *
78  * @param[in] inName Name of the parameter array to be created.
79  * @param[in] inLimits Dimensions of the vector.
80  * @param[in] inFactory Factory for the child.
81  * @param[in] inOriginalName Original name of the parameter array [optional].
82  *
83  * @return Pointer to created parameter array.
84  */
86  const std::vector<size_t>& inLimits, const ChildFactorySharedPtr& inFactory
88  const std::string& inOriginalName = std::string()) throw (Error);
89  };
90 
91  virtual ~ParameterArray() throw ();
92 
93  /**
94  * Receive an inoutVisitor to this class. The visit method of the inoutVisitor is called and a
95  * reference to this object is passed as a parameter. It has to be noted however, that a
96  * dynamic_cast is performed inside this method. If the cast fails, an appropriate exception is
97  * thrown by this method. This situation can arise when the passed Visitor object does not
98  * inherit from the appropriate inoutVisitor specialization. See Visitor documentation for more
99  * details.
100  *
101  * @param[in,out] inoutVisitor A reference to the inoutVisitor object
102  * @exception Error Visitor type inappropriate for visiting this object or any other error
103  * thrown by the Visitor::throw() method.
104  */
105  virtual void accept(BaseVisitor& inoutVisitor) throw (Error);
106 
107 protected:
108  virtual void onChildCreate(const boost::shared_ptr<BaseVectorType::ChildType>& inCreatedChild)
109  const throw (Error);
110 
111  ParameterArray();
112 
113 private:
114 #ifdef GENOM_SERIALIZATION
115  template <class Archive> void serialize(Archive& ar, unsigned int);
116 #endif //GENOM_SERIALIZATION
117 };
118 
119 } // namespace generic
120 } // namespace torc
121 
122 #endif // TORC_GENERIC_PARAMETERARRAY_HPP
An acyclic inoutVisitor implementation.
Definition: VisitorType.hpp:57
boost::shared_ptr< ParameterArray > ParameterArraySharedPtr
Vector< Parameter, ParameterArrayElement, ParameterArrayElement::Factory, false > BaseVectorType
std::string string
VisitorType< ParameterArray > Visitor
Represents a parameter object in EDIF.
Definition: Parameter.hpp:38
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
Represents a parameter array.
virtual ParameterArraySharedPtr newParameterArrayPtr(const std::string &inName, const size_t &inSize, const ChildFactorySharedPtr &inFactory=BaseVectorType::ChildFactorySharedPtr(new BaseVectorType::ChildFactory()), const std::string &inOriginalName=std::string())
A base class for Visitor.
Definition: VisitorType.hpp:31
virtual void onChildCreate(const boost::shared_ptr< BaseVectorType::ChildType > &inCreatedChild) const
An array of objects.
Definition: Vector.hpp:50
virtual void accept(BaseVisitor &inoutVisitor)
A placeholder for a factory method.
Definition: FactoryType.hpp:35