torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimulationInfo.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_SIMULATIONINFO_HPP
17 #define TORC_GENERIC_SIMULATIONINFO_HPP
18 
20 #include "torc/generic/Error.hpp"
27 #include "torc/generic/SymTab.hpp"
29 
30 #include <list>
31 #include <vector>
32 
33 namespace torc { namespace generic { class BaseVisitor; } }
34 namespace torc { namespace generic { class Library; } }
35 namespace torc { namespace generic { class LogicValue; } }
36 
37 namespace torc {
38 namespace generic {
39 
40 /**
41  * @brief This class is used to hold all information about the logic values used
42  * within a library.
43  */
44 class SimulationInfo : public Commentable, public Visitable, public ParentedObject<Library>,
45  public SelfReferencing<SimulationInfo>, public UserDataContainer {
46 
47  friend class FactoryType<SimulationInfo> ;
48 
49 public:
50  /**
51  * Convenience typedef for visiting a simulation info
52  */
54 
55  /**
56  * Convenience class for creating a simulation info
57  */
58  class Factory : public FactoryType<SimulationInfo> {
59  public:
61 
62  /**
63  * Create a simulation info.
64  *
65  * @param[in] inLogicValues Vector of logic values to be appended to
66  * @param[in] inLibraryPtr Pointer to parented(Library) object.
67  *
68  * @return Pointer to simulation info.
69  **/
71  newSimulationInfoPtr(const std::vector<LogicValueSharedPtr>& inLogicValues,
72  const LibrarySharedPtr& inLibraryPtr) throw (Error);
73  };
74 
75  virtual void accept(BaseVisitor& inoutVisitor) throw (Error);
76 
77  /**
78  * Add a logic value to the list of logic values. If an empty pointer is supplied,
79  * it returns without doing anything.
80  *
81  * @param[in] inLogicValue A pointer to a logic value object.
82  *
83  * @exception Error Logic value could not be added.
84  */
85  void addLogicValue(const LogicValueSharedPtr& inLogicValue) throw (Error);
86 
87  /**
88  * Find a logic value by name, in the list of logic values in simulationInfo.
89  *
90  * @param[in] inName String value specifying the name of the logic value.
91  *
92  * @return A pointer to the logic value if found, an empty pointer otherwise.
93  */
95 
96  /**
97  * Remove the specified logic value from the list of logic values.
98  * If an empty pointer is passed, it returns without doing anything
99  *
100  * @param[in] inName name of the object to be removed
101  *
102  * @exception Error Logic Value not preset in collection.
103  */
104  void removeLogicValue(const std::string& inName) throw (Error);
105 
106  /**
107  * Get the list of logic values.
108  *
109  * @param[out] outLogicValues Vector of logic values to be appended to
110  */
111  inline void getLogicValues(std::vector<LogicValueSharedPtr>& outLogicValues) const;
112 
113  /**
114  * Set the list of logic values.
115  *
116  * @param[in] inLogicValues Vector of logic values to be appended to
117  */
118  void setLogicValues(const std::vector<LogicValueSharedPtr>& inLogicValues) throw (Error);
119 
120  /**
121  * Apply action on all logic values.
122  * @param[in] action Action to be applied
123  *
124  */
125  template <typename _Action> inline void applyOnAllLogicValues(const _Action& action)
126  throw (Error);
127 
128  virtual ~SimulationInfo() throw ();
129 
130 protected:
131  SimulationInfo();
132 
133 private:
134  SimulationInfo(const SimulationInfo& source);
135 
136  SimulationInfo& operator=(const SimulationInfo& source);
137 
139 
140 };
141 
142 /**
143  * Get the list of logic values.
144  *
145  * @param[out] outLogicValues Vector of logic values to be appended to
146  */
147 inline void SimulationInfo::getLogicValues(std::vector<LogicValueSharedPtr>& outLogicValues) const {
148  mLogicValueSymTab.getValues(outLogicValues);
149 }
150 
151 /**
152  * Apply action on all logic values.
153  * @param[in] action Action to be applied
154  *
155  */
156 template <typename _Action> inline void SimulationInfo::applyOnAllLogicValues(const _Action& action)
157  throw (Error) {
158  try {
160  } catch(Error& e) {
161  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
162  throw;
163  }
164 }
165 
166 } // namespace generic
167 } // namespace torc
168 
169 #endif // TORC_GENERIC_SIMULATIONINFO_HPP
boost::shared_ptr< LogicValue > LogicValueSharedPtr
An acyclic inoutVisitor implementation.
Definition: VisitorType.hpp:57
An object that has a parent.
void applyOnAllLogicValues(const _Action &action)
void removeLogicValue(const std::string &inName)
void getLogicValues(std::vector< LogicValueSharedPtr > &outLogicValues) const
VisitorType< SimulationInfo > Visitor
Represents all classes that can hold user comments.
Definition: Commentable.hpp:36
This class is used to hold all information about the logic values used within a library.
Represents class that can hold userData.
void applyOnAll(const _Action &action)
Definition: SymTab.hpp:192
std::string string
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
void addLogicValue(const LogicValueSharedPtr &inLogicValue)
boost::shared_ptr< Library > LibrarySharedPtr
A base class for Visitor.
Definition: VisitorType.hpp:31
boost::shared_ptr< SimulationInfo > SimulationInfoSharedPtr
virtual void accept(BaseVisitor &inoutVisitor)
void setLogicValues(const std::vector< LogicValueSharedPtr > &inLogicValues)
virtual SimulationInfoSharedPtr newSimulationInfoPtr(const std::vector< LogicValueSharedPtr > &inLogicValues, const LibrarySharedPtr &inLibraryPtr)
A symbol table.
Definition: SymTab.hpp:38
LogicValueSharedPtr findLogicValue(const std::string &inName)
A placeholder for a factory method.
Definition: FactoryType.hpp:35
SymTab< std::string, LogicValueSharedPtr > mLogicValueSymTab
An object that receives an inoutVisitor.
Definition: Visitable.hpp:38
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:73