torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Timing.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/Timing.hpp"
20 #include "torc/generic/View.hpp"
22 
23 namespace torc {
24 namespace generic {
25 
26 /**
27  * Create a Timing.
28  *
29  * @param[in] inDerivation Derivation value
30  * @param[in] inPathDelays List of path delays of this timing to be appended to.
31  * @param[in] inForbiddentEvents List of forbidden events to be appended to
32  * @param[in] inView Pointer to parented (view) object.
33  * @param[in] inInterfaceAttributes Pointer to
34  * parented (InterfaceAttributes) object [optional].
35  * If mentioned then this will decompile within (contents ...) construct.
36  * @param[in] inInstance Pointer to parented object(Instance) [optional].
37  * If mentioned then this will decompile within (instance ...) construct.
38  *
39  * @return Pointer to created Timing.
40  */
42  const std::list<PathDelaySharedPtr>& inPathDelays,
43  const std::list<ForbiddenEventSharedPtr>& inForbiddentEvents, const ViewSharedPtr& inView,
44  const InterfaceAttributesSharedPtr& inInterfaceAttributes, const InstanceSharedPtr& inInstance)
45  throw (Error) {
46  try {
47  TimingSharedPtr newTiming;
48  create(newTiming);
49  newTiming->setDerivation(inDerivation);
50  newTiming->setPathDelays(inPathDelays);
51  newTiming->setForbiddentEvents(inForbiddentEvents);
52  if(inInstance) {
53  inInstance->setTiming(newTiming);
54  } else if(inInterfaceAttributes) {
55  inInterfaceAttributes->setTiming(newTiming);
56  inView->setInterfaceAttributes(inInterfaceAttributes);
57  } else {
58  inView->setTiming(newTiming);
59  }
60  return newTiming;
61  } catch(Error& e) {
62  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
63  throw;
64  }
65 }
66 
67 void Timing::accept(BaseVisitor& inoutVisitor) throw (Error) {
68  try {
69  runVisitor(*this, inoutVisitor);
70  } catch(Error& e) {
71  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
72  throw;
73  }
74 }
75 
76 /**
77  * Set derivation
78  *
79  * @param[in] value Derivation value
80  */
81 void Timing::setDerivation(const Derivation& value) {
82  mDerivation = value;
83 }
84 
85 /**
86  * Set all the path delays of this timing.
87  *
88  * @param[in] inPathDelays List of path delays of this timing to be appended to
89  */
90 void Timing::setPathDelays(const std::list<PathDelaySharedPtr>& inPathDelays) {
91  std::list<PathDelaySharedPtr>::const_iterator it = inPathDelays.begin();
92  for(; it != inPathDelays.end(); it++) {
93  try {
94  addPathDelay(*it);
95  } catch(Error& e) {
96  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
97  throw;
98  }
99  }
100 }
101 
102 /**
103  * Set all the forbidden events of this timing.
104  *
105  * @param[in] inForbiddentEvents List of events to be appended to
106  */
107 void Timing::setForbiddentEvents(const std::list<ForbiddenEventSharedPtr>& inForbiddentEvents) {
108  std::list<ForbiddenEventSharedPtr>::const_iterator it = inForbiddentEvents.begin();
109  for(; it != inForbiddentEvents.end(); it++) {
110  try {
111  addForbiddenEvent(*it);
112  } catch(Error& e) {
113  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
114  throw;
115  }
116  }
117 }
118 
119 /**
120  * Add a path delay to the list of path delays.
121  *
122  * @param[in] inSource Pointer to path delay to be appended to
123  */
125  try {
126  mPathDelays.push_back(inSource);
127  } catch(Error& e) {
128  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
129  throw;
130  }
131 }
132 
133 /**
134  * Add a forbidden event of the list of forbidden events.
135  *
136  * @param[in] inSource Pointer to forbidden event to be appended to
137  */
139  try {
140  mForbiddentEvents.push_back(inSource);
141  } catch(Error& e) {
142  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
143  throw;
144  }
145 }
146 
148  mDerivation(), mPathDelays(), mForbiddentEvents() {}
149 
150 Timing::~Timing() throw () {}
151 
152 } // namespace generic
153 } // namespace torc
std::list< ForbiddenEventSharedPtr > mForbiddentEvents
Definition: Timing.hpp:149
boost::shared_ptr< Instance > InstanceSharedPtr
virtual TimingSharedPtr newTimingPtr(const Derivation &inDerivation, const std::list< PathDelaySharedPtr > &inPathDelays, const std::list< ForbiddenEventSharedPtr > &inForbiddentEvents, const ViewSharedPtr &inView, const InterfaceAttributesSharedPtr &inInterfaceAttributes=InterfaceAttributesSharedPtr(), const InstanceSharedPtr &inInstance=InstanceSharedPtr())
Definition: Timing.cpp:41
void setForbiddentEvents(const std::list< ForbiddenEventSharedPtr > &inForbiddentEvents)
Definition: Timing.cpp:107
Represents all classes that can hold user comments.
Definition: Commentable.hpp:36
Represents class that can hold userData.
void setPathDelays(const std::list< PathDelaySharedPtr > &inPathDelays)
Definition: Timing.cpp:90
void runVisitor(_Tp &inoutVisited, BaseVisitor &inoutVisitor)
Definition: VisitorType.hpp:78
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
void addPathDelay(const PathDelaySharedPtr &inSource)
Definition: Timing.cpp:124
A base class for Visitor.
Definition: VisitorType.hpp:31
This class is used to provide a set of path delays or timing constrains (forbidden events) ...
Definition: Timing.hpp:40
boost::shared_ptr< ForbiddenEvent > ForbiddenEventSharedPtr
void setDerivation(const Derivation &value)
Definition: Timing.cpp:81
boost::shared_ptr< InterfaceAttributes > InterfaceAttributesSharedPtr
Derivation mDerivation
Definition: Timing.hpp:147
std::list< PathDelaySharedPtr > mPathDelays
Definition: Timing.hpp:148
void addForbiddenEvent(const ForbiddenEventSharedPtr &inSource)
Definition: Timing.cpp:138
virtual void accept(BaseVisitor &inoutVisitor)
Definition: Timing.cpp:67
boost::shared_ptr< View > ViewSharedPtr
boost::shared_ptr< PathDelay > PathDelaySharedPtr
boost::shared_ptr< Timing > TimingSharedPtr
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