torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PathDelay.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 
17 #include "torc/generic/Event.hpp"
18 #include "torc/generic/Timing.hpp"
19 
20 namespace torc {
21 namespace generic {
22 
23 /**
24  * Create a PathDelay.
25  *
26  * @param[in] inDelay Value::MiNoMax Delay value.
27  * @param[in] inEvents List of events to be appended to
28  * @param[in] inTiming Pointer to parented object (Timing) [optional].
29  * If not mentioned PathDelay will not be added to timing.
30  *
31  * @return Pointer to created PathDelay.
32  */
34  const std::list<EventSharedPtr>& inEvents, const TimingSharedPtr& inTiming) throw (Error) {
35  try {
36  PathDelaySharedPtr newPathDelay;
37  create(newPathDelay);
38  newPathDelay->setDelay(inDelay);
39  newPathDelay->setEvents(inEvents);
40  if(inTiming) {
41  inTiming->addPathDelay(newPathDelay);
42  }
43  return newPathDelay;
44  } catch(Error& e) {
45  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
46  throw;
47  }
48 }
49 
50 void PathDelay::setDelay(const Value::MiNoMax& inSource) {
51  mDelay = inSource;
52 }
53 
54 /**
55  * Set all the events of this forbiddenEvent.
56  *
57  * @param[out] inEvents List of events to be appended to
58  */
59 void PathDelay::setEvents(const std::list<EventSharedPtr>& inEvents) {
60  std::list<EventSharedPtr>::const_iterator it = inEvents.begin();
61  for(; it != inEvents.end(); it++) {
62  try {
63  addEvent(*it);
64  } catch(Error& e) {
65  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
66  }
67  }
68 }
69 
70 void PathDelay::addEvent(const EventSharedPtr& inEvent) throw (Error) {
71  if(!inEvent) {
72  return;
73  }
74  mEvents.push_back(inEvent);
75 }
76 
77 PathDelay::PathDelay() : SelfReferencing<PathDelay>(), mDelay(), mEvents() {}
78 
79 PathDelay::~PathDelay() throw () {}
80 
81 } // namespace generic
82 } // namespace torc
void setDelay(const Value::MiNoMax &inSource)
Definition: PathDelay.cpp:50
Value::MiNoMax mDelay
Definition: PathDelay.hpp:105
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
This class associates a delay with a specified chain of events. Delay contains the time from first ev...
Definition: PathDelay.hpp:36
boost::shared_ptr< Event > EventSharedPtr
void setEvents(const std::list< EventSharedPtr > &inEvents)
Definition: PathDelay.cpp:59
virtual PathDelaySharedPtr newPathDelayPtr(const Value::MiNoMax &inDelay, const std::list< EventSharedPtr > &inEvents, const TimingSharedPtr &inTiming=TimingSharedPtr())
Definition: PathDelay.cpp:33
boost::shared_ptr< PathDelay > PathDelaySharedPtr
boost::shared_ptr< Timing > TimingSharedPtr
void addEvent(const EventSharedPtr &inEvent)
Definition: PathDelay.cpp:70
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:73