torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Simulate.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_SIMULATE_HPP
17 #define TORC_GENERIC_SIMULATE_HPP
18 
26 #include "torc/generic/SymTab.hpp"
30 #include "torc/generic/Error.hpp"
31 
32 #include <vector>
33 
34 namespace torc { namespace generic { class BaseVisitor; } }
35 namespace torc { namespace generic { class Apply; } }
36 namespace torc { namespace generic { class WaveValue; } }
37 
38 namespace torc {
39 namespace generic {
40 
41 /**
42  * @brief This class is to model simulate construct which is a named collection
43  * of simulation stimulus and responses statements and is used in the interface and
44  * contents of views.
45  */
46 class Simulate : public Nameable, public Renamable, public Commentable, public Visitable,
47  public SelfReferencing<Simulate>, public UserDataContainer {
48  friend class FactoryType<Simulate> ;
49 
50 public:
51  /**
52  * Convenience class to visit a simulate
53  */
55 
56  /**
57  * Convenience class for creating a simulate
58  */
59  class Factory : public FactoryType<Simulate> {
60  public:
62  /**
63  * Create a simulate.
64  *
65  * @param[in] inName Name of the simulate to be created.
66  * @param[in] inPortListAliases Vector of port list aliases to this simulate.
67  * @param[in] inAllApply Vector of apply to this simulate.
68  * @param[in] inWaveValues Vector of WaveValues to this simulate.
69  * @param[in] inView Pointer to parented (view) object.
70  * @param[in] inOriginalName Original name of the simulate [optional].
71  * @param[in] inInterfaceAttributes Pointer to
72  * parented (InterfaceAttributes) object [optional]. If mentioned then this
73  * will decompile within (contents ...) construct.
74  *
75  * @return Pointer to created simulate.
76  */
77  SimulateSharedPtr virtual newSimulatePtr(const std::string& inName,
78  const std::vector<PortListAliasSharedPtr>& inPortListAliases,
79  const std::vector<ApplySharedPtr>& inAllApply,
80  const std::vector<WaveValueSharedPtr>& inWaveValues, const ViewSharedPtr& inView,
81  const std::string& inOriginalName = std::string(),
82  const InterfaceAttributesSharedPtr& inInterfaceAttributes =
84  };
85 
86  virtual void accept(BaseVisitor& inoutVisitor) throw (Error);
87 
88  /**
89  * Add a port list alias to the symbol table of port list alias.
90  * If an empty pointer is supplied, it returns without doing anything.
91  *
92  * @param[in] inPortListAlias A pointer to a port list alias object.
93  *
94  * @exception Error PortListAlias could not be added, empty PortListAlias name
95  * @exception Error PortListAlias already exists in simulate
96  */
97  void addPortListAlias(const PortListAliasSharedPtr& inPortListAlias) throw (Error);
98 
99  /**
100  * Find a PortListAlias by name, in the symbol table of port list alias.
101  *
102  * @param[in] inName String specifying the name of the PortListAlias.
103  *
104  * @return A pointer to the PortListAlias if found, an empty pointer otherwise.
105  */
107 
108  /**
109  * Get all the PortListAlias of this simulation.
110  *
111  * @param[out] outPortListAliases Vector of PortListAlias to be appended to
112  */
113  inline void getPortListAliases(std::vector<PortListAliasSharedPtr>& outPortListAliases) const;
114 
115  /**
116  * Set all the PortListAlias of this simulation.
117  *
118  * @param[in] inPortListAliases Vector of PortListAlias to be appended to
119  */
120  void setPortListAliases(const std::vector<PortListAliasSharedPtr>& inPortListAliases)
121  throw (Error);
122 
123  /**
124  * Get all the apply objects.
125  *
126  * @param[out] outAllApply Vector of apply objects to be appended to
127  */
128  inline void getAllApply(std::vector<ApplySharedPtr>& outAllApply) const;
129 
130  /**
131  * Set all the apply objects.
132  *
133  * @param[in] inAllApply Vector of apply objects to be appended to
134  */
135  void setAllApply(const std::vector<ApplySharedPtr>& inAllApply) throw (Error);
136 
137  /**
138  * Add an apply objects to the vector of apply objects.
139  *
140  * @param[in] inSource Pointer to Apply object
141  */
142  void addApply(const ApplySharedPtr& inSource) throw (Error);
143 
144  /**
145  * Get the vector of wave values.
146  *
147  * @param[out] outWaveValues Vector of wave values to be appended to
148  */
149  inline void getWaveValues(std::vector<WaveValueSharedPtr>& outWaveValues) const;
150 
151  /**
152  * Set the vector of wave values.
153  *
154  * @param[in] inWaveValues Vector of wave values to be appended to
155  */
156  void setWaveValues(const std::vector<WaveValueSharedPtr>& inWaveValues) throw (Error);
157 
158  /**
159  * Add a wave value to the symbol table of wave values.
160  *
161  * @param[in] inSource Pointer to WaveValue to be appended to
162  *
163  * @exception Error WaveValue could not be added, empty WaveValue name
164  * @exception Error WaveValue already exists in simulate
165  */
166  void addWaveValue(const WaveValueSharedPtr& inSource) throw (Error);
167 
168  /**
169  * Find a WaveValue by name, in the symbol table of port list alias.
170  *
171  * @param[in] inName String specifying the name of the WaveValue.
172  *
173  * @return A pointer to the WaveValue if found, an empty pointer otherwise.
174  */
176 
177  /**
178  * Apply action on all PortListAlias.
179  * @param[in] action Action to be applied
180  *
181  */
182  template <typename _Action> inline void applyOnAllPortListAlias(const _Action& action)
183  throw (Error);
184 
185  /**
186  * Apply action on all WaveValues.
187  * @param[in] action Action to be applied
188  *
189  */
190  template <typename _Action> inline void applyOnAllWaveValues(const _Action& action)
191  throw (Error);
192 
193  ~Simulate() throw ();
194 
195 protected:
196  Simulate();
197 
198 private:
199  Simulate(const Simulate& source);
200 
201  Simulate& operator=(const Simulate& source);
202 
205  std::vector<ApplySharedPtr> mAllApply;
206 
207 };
208 
209 /**
210  * Get all the PortListAlias of this simulation.
211  *
212  * @param[out] outPortListAliases Vector of PortListAlias to be appended to
213  */
214 inline void Simulate::getPortListAliases(
215  std::vector<PortListAliasSharedPtr>& outPortListAliases) const {
216  mPortListAliasSymTab.getValues(outPortListAliases);
217 }
218 
219 /**
220  * Get all the apply objects.
221  *
222  * @param[out] outAllApply Vector of apply objects to be appended to
223  */
224 inline void Simulate::getAllApply(std::vector<ApplySharedPtr>& outAllApply) const {
225  outAllApply.insert(outAllApply.end(), mAllApply.begin(), mAllApply.end());
226 }
227 
228 /**
229  * Get the vector of wave values.
230  *
231  * @param[out] outWaveValues Vector of wave values to be appended to
232  */
233 inline void Simulate::getWaveValues(std::vector<WaveValueSharedPtr>& outWaveValues) const {
234  mWaveValueSymTab.getValues(outWaveValues);
235 }
236 
237 /**
238  * Apply action on all PortListAlias.
239  * @param[in] action Action to be applied
240  *
241  */
242 template <typename _Action> inline void Simulate::applyOnAllPortListAlias(const _Action& action)
243  throw (Error) {
244  try {
246  } catch(Error& e) {
247  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
248  throw;
249  }
250 }
251 
252 /**
253  * Apply action on all WaveValues.
254  * @param[in] action Action to be applied
255  *
256  */
257 template <typename _Action> inline void Simulate::applyOnAllWaveValues(const _Action& action)
258  throw (Error) {
259  try {
261  } catch(Error& e) {
262  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
263  throw;
264  }
265 }
266 
267 } // namespace generic
268 } // namespace torc
269 
270 #endif // TORC_GENERIC_SIMULATE_HPP
void getValues(std::vector< ValueType > &outValues) const
Definition: SymTab.hpp:158
An acyclic inoutVisitor implementation.
Definition: VisitorType.hpp:57
WaveValueSharedPtr findWaveValue(const std::string &inName)
Definition: Simulate.cpp:218
boost::shared_ptr< WaveValue > WaveValueSharedPtr
void getAllApply(std::vector< ApplySharedPtr > &outAllApply) const
Definition: Simulate.hpp:224
void applyOnAllPortListAlias(const _Action &action)
Definition: Simulate.hpp:242
void addPortListAlias(const PortListAliasSharedPtr &inPortListAlias)
Definition: Simulate.cpp:85
Represents all classes that can hold user comments.
Definition: Commentable.hpp:36
Represents class that can hold userData.
void applyOnAll(const _Action &action)
Definition: SymTab.hpp:192
boost::shared_ptr< Simulate > SimulateSharedPtr
std::string string
PortListAliasSharedPtr findPortListAlias(const std::string &inName)
Definition: Simulate.cpp:127
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
A base class for Visitor.
Definition: VisitorType.hpp:31
void addApply(const ApplySharedPtr &inSource)
Definition: Simulate.cpp:143
void getWaveValues(std::vector< WaveValueSharedPtr > &outWaveValues) const
Definition: Simulate.hpp:233
SymTab< std::string, PortListAliasSharedPtr > mPortListAliasSymTab
Definition: Simulate.hpp:203
boost::shared_ptr< Apply > ApplySharedPtr
void getPortListAliases(std::vector< PortListAliasSharedPtr > &outPortListAliases) const
Definition: Simulate.hpp:214
void applyOnAllWaveValues(const _Action &action)
Definition: Simulate.hpp:257
virtual SimulateSharedPtr newSimulatePtr(const std::string &inName, const std::vector< PortListAliasSharedPtr > &inPortListAliases, const std::vector< ApplySharedPtr > &inAllApply, const std::vector< WaveValueSharedPtr > &inWaveValues, const ViewSharedPtr &inView, const std::string &inOriginalName=std::string(), const InterfaceAttributesSharedPtr &inInterfaceAttributes=InterfaceAttributesSharedPtr())
Definition: Simulate.cpp:40
void setWaveValues(const std::vector< WaveValueSharedPtr > &inWaveValues)
Definition: Simulate.cpp:174
boost::shared_ptr< InterfaceAttributes > InterfaceAttributesSharedPtr
std::vector< ApplySharedPtr > mAllApply
Definition: Simulate.hpp:205
SymTab< std::string, WaveValueSharedPtr > mWaveValueSymTab
Definition: Simulate.hpp:204
boost::shared_ptr< View > ViewSharedPtr
An object that has a name.
Definition: Nameable.hpp:34
boost::shared_ptr< PortListAlias > PortListAliasSharedPtr
virtual void accept(BaseVisitor &inoutVisitor)
Definition: Simulate.cpp:67
Represents objects that can be renamed.
A symbol table.
Definition: SymTab.hpp:38
VisitorType< Simulate > Visitor
Definition: Simulate.hpp:54
void setAllApply(const std::vector< ApplySharedPtr > &inAllApply)
Definition: Simulate.cpp:157
A placeholder for a factory method.
Definition: FactoryType.hpp:35
This class is to model simulate construct which is a named collection of simulation stimulus and resp...
Definition: Simulate.hpp:46
void setPortListAliases(const std::vector< PortListAliasSharedPtr > &inPortListAliases)
Definition: Simulate.cpp:107
void addWaveValue(const WaveValueSharedPtr &inSource)
Definition: Simulate.cpp:194
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