torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SingleParameter.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_SINGLEPARAMETER_HPP
17 #define TORC_GENERIC_SINGLEPARAMETER_HPP
18 
20 
21 //BOOST
22 #ifdef GENOM_SERIALIZATION
23 #include <boost/serialization/access.hpp>
24 #endif //GENOM_SERIALIZATION
26 #include "torc/generic/Scalar.hpp"
29 #include "torc/generic/Error.hpp"
30 
31 namespace torc { namespace generic { class BaseVisitor; } }
32 
33 namespace torc {
34 namespace generic {
35 
36 /**
37  * Represents a single parameter inSource.
38  */
39 class SingleParameter : public Parameter, public Scalar<Parameter> {
40 #ifdef GENOM_SERIALIZATION
41  friend class boost::serialization::access;
42 #endif //GENOM_SERIALIZATION
44 
45 public:
47 
48  /**
49  * Convenience class to create a single parameter.
50  */
51  class Factory : public FactoryType<SingleParameter> {
52  public:
54  /**
55  * Create a single parameter.
56  *
57  * @param[in] inName Name of the single parameter to be created.
58  * @param[in] inValue Value of the parameter.
59  * @param[in] inUnit Unit of the parameter.
60  * @param[in] inOriginalName Original name of the single parameter [optional].
61  *
62  * @return Pointer to created single parameter.
63  */
65  const Value& inValue, const Unit& inUnit = eUnitUndefined,
66  const std::string& inOriginalName = std::string()) throw (Error);
67  };
68 
69  virtual ~SingleParameter() throw ();
70 
71  /**
72  * Receive an inoutVisitor to this class. The visit method of the inoutVisitor is called and a
73  * reference to this object is passed as a parameter. It has to be noted however, that a
74  * dynamic_cast is performed inside this method. If the cast fails, an appropriate exception is
75  * thrown by this method. This situation can arise when the passed Visitor object does not
76  * inherit from the appropriate inoutVisitor specialization. See Visitor documentation for more
77  * details.
78  *
79  * @param[in,out] inoutVisitor A reference to the inoutVisitor object
80  * @exception Error Visitor type inappropriate for visiting this object or any other error
81  * thrown by the Visitor::throw() method.
82  */
83  virtual void accept(BaseVisitor& inoutVisitor) throw (Error);
84 
85 protected:
87 
88 private:
89 #ifdef GENOM_SERIALIZATION
90  template <class Archive> void serialize(Archive& ar, unsigned int);
91 #endif //GENOM_SERIALIZATION
92 };
93 
94 } // namespace generic
95 } // namespace torc
96 
97 #endif // TORC_GENERIC_SINGLEPARAMETER_HPP
An acyclic inoutVisitor implementation.
Definition: VisitorType.hpp:57
A single object with no child objects.
Definition: Scalar.hpp:34
std::string string
Represents a parameter object in EDIF.
Definition: Parameter.hpp:38
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
A base class for Visitor.
Definition: VisitorType.hpp:31
boost::shared_ptr< SingleParameter > SingleParameterSharedPtr
VisitorType< SingleParameter > Visitor
virtual void accept(BaseVisitor &inoutVisitor)
virtual SingleParameterSharedPtr newSingleParameterPtr(const std::string &inName, const Value &inValue, const Unit &inUnit=eUnitUndefined, const std::string &inOriginalName=std::string())
A placeholder for a factory method.
Definition: FactoryType.hpp:35