torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Apply.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 #include "torc/generic/Apply.hpp"
19 
20 namespace torc {
21 namespace generic {
22 
23 /**
24  * Create an apply.
25  *
26  * @param[in] inNoOfCycle int32_t No of cycles for this apply.
27  * @param[in] inCycleDuration Value Duration of each cycle.
28  * @param[in] inLogicResponces List of LogicResponces.
29  * @param[in] inSimulate Pointer to parented (Simulate) object [optional].
30  * If not mentioned apply will not be added to simulate.
31  *
32  * @return Pointer to created apply.
33  */
34 ApplySharedPtr Apply::Factory::newApplyPtr(const int32_t& inNoOfCycle, const Value& inCycleDuration,
35  const std::list<LogicalResponseSharedPtr>& inLogicResponces,
36  const SimulateSharedPtr& inSimulate) throw (Error) {
37  try {
38  ApplySharedPtr newApply;
39  create(newApply);
40  newApply->setNoOfCycle(inNoOfCycle);
41  newApply->setCycleDuration(inCycleDuration);
42  newApply->setLogicResponses(inLogicResponces);
43  if(inSimulate) {
44  inSimulate->addApply(newApply);
45  }
46  return newApply;
47  } catch(Error& e) {
48  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
49  throw;
50  }
51 }
52 
53 void Apply::accept(BaseVisitor& inoutVisitor) throw (Error) {
54  try {
55  runVisitor(*this, inoutVisitor);
56  } catch(Error& e) {
57  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
58  throw;
59  }
60 }
61 
62 /**
63  * Set the no of cycles
64  * @param[in] inValue int32_t No of cycles
65  */
66 void Apply::setNoOfCycle(const int32_t& inValue) {
67  mNoOfCycle = inValue;
68 }
69 
70 /**
71  * Set the duration of each cycle
72  * @param[in] value Duration of each cycle
73  */
74 void Apply::setCycleDuration(const Value& value) {
75  mCycleDuration = value;
76 }
77 
78 /**
79  * Set the list of LogicResponce.
80  *
81  * @param[in] inLogicResponces List of LogicResponce (s) to be appended to
82  */
83 void Apply::setLogicResponses(const std::list<LogicalResponseSharedPtr>& inLogicResponces) {
84  std::list<LogicalResponseSharedPtr>::const_iterator logicalResponse = inLogicResponces.begin();
85  std::list<LogicalResponseSharedPtr>::const_iterator end = inLogicResponces.end();
86  for(; logicalResponse != end; logicalResponse++) {
87  try {
88  addLogicResponse(*logicalResponse);
89  } catch(Error& e) {
90  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
91  throw;
92  }
93  }
94 }
95 
96 /**
97  * Add a LogicResponce to the list of LogicResponces.
98  *
99  * @param[in] inLogicResponce Pointer to LogicResponce to be appended to
100  */
101 void Apply::addLogicResponse(const LogicalResponseSharedPtr& inLogicResponce) {
102  try {
103  mLogicResponses.push_back(inLogicResponce);
104  } catch(Error& e) {
105  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
106  throw;
107  }
108 }
109 
111  mNoOfCycle(0), mCycleDuration(), mLogicResponses() {}
112 
113 Apply::~Apply() throw () {}
114 
115 } // namespace generic
116 } // namespace torc
void setLogicResponses(const std::list< LogicalResponseSharedPtr > &inLogicResponces)
Definition: Apply.cpp:83
int32_t mNoOfCycle
Definition: Apply.hpp:127
This class is used within simulate to describe input stimuli and expected responces over a certain ti...
Definition: Apply.hpp:37
virtual ApplySharedPtr newApplyPtr(const int32_t &inNoOfCycle, const Value &inCycleDuration, const std::list< LogicalResponseSharedPtr > &inLogicResponces, const SimulateSharedPtr &inSimulate=SimulateSharedPtr())
Definition: Apply.cpp:34
void setNoOfCycle(const int32_t &inValue)
Definition: Apply.cpp:66
Represents all classes that can hold user comments.
Definition: Commentable.hpp:36
Represents class that can hold userData.
boost::shared_ptr< Simulate > SimulateSharedPtr
void runVisitor(_Tp &inoutVisited, BaseVisitor &inoutVisitor)
Definition: VisitorType.hpp:78
void addLogicResponse(const LogicalResponseSharedPtr &inLogicResponce)
Definition: Apply.cpp:101
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
boost::shared_ptr< LogicalResponse > LogicalResponseSharedPtr
A base class for Visitor.
Definition: VisitorType.hpp:31
std::list< LogicalResponseSharedPtr > mLogicResponses
Definition: Apply.hpp:129
boost::shared_ptr< Apply > ApplySharedPtr
virtual void accept(BaseVisitor &inoutVisitor)
Definition: Apply.cpp:53
void setCycleDuration(const Value &value)
Definition: Apply.cpp:74
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