torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ForbiddenEvent.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 ForbiddenEvent.
25  *
26  * @param[in] inStartTimeInterval Pointer to start event/offsetEvent of timeInterval.
27  * @param[in] inEndTimeInterval Pointer to end event/offsetEvent of timeInterval.
28  * @param[in] inEvents List of events which are forbidden during a period of time
29  * specified by TimeInterval(StartTimeInterval and EndTimeInterval).
30  * @param[in] inTiming Pointer to parented object (Timing) [optional].
31  * If not mentioned PathDelay will not be added to timing.
32  * @param[in] inDuration Duration of timeInterval, if end event is absent [optional].
33  *
34  * @return Pointer to created ForbiddenEvent.
35  */
37  const EventSharedPtr& inStartTimeInterval, const EventSharedPtr& inEndTimeInterval,
38  const std::list<EventSharedPtr>& inEvents, const TimingSharedPtr& inTiming,
39  const Value& inDuration) throw (Error) {
40  try {
41  ForbiddenEventSharedPtr newForbiddenEvent;
42  create(newForbiddenEvent);
43  newForbiddenEvent->setStartTimeInterval(inStartTimeInterval);
44  newForbiddenEvent->setEndTimeInterval(inEndTimeInterval);
45  newForbiddenEvent->setEvents(inEvents);
46  if(inDuration.getIsSet()) {
47  newForbiddenEvent->setDuration(inDuration);
48  }
49  if(inTiming) {
50  inTiming->addForbiddenEvent(newForbiddenEvent);
51  }
52  return newForbiddenEvent;
53  } catch(Error& e) {
54  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
55  throw;
56  }
57 }
58 
59 void ForbiddenEvent::accept(BaseVisitor& inoutVisitor) throw (Error) {
60  try {
61  runVisitor(*this, inoutVisitor);
62  } catch(Error& e) {
63  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
64  throw;
65  }
66 }
67 
68 /**
69  * Set the pointer to start event/offsetEvent of timeInterval
70  * @param[in] inSource Pointer to start event/offsetEvent of timeInterval
71  */
73  mStartTimeInterval = inSource;
74 }
75 
76 /**
77  * Set the pointer to end event/offsetEvent of timeInterval
78  * @param[in] inSource Pointer to end event/offsetEvent of timeInterval
79  */
81  mEndTimeInterval = inSource;
82 }
83 
84 /**
85  * Set the duration of timeInterval, if end event is absent.
86  * @param[in] inValue Duration of timeInterval, if end event is absent.
87  */
88 void ForbiddenEvent::setDuration(const Value& inValue) {
89  mDuration = inValue;
90 }
91 
92 /**
93  * Set all the events of this forbiddenEvent.
94  *
95  * @param[out] inEvents List of events to be appended to
96  */
97 void ForbiddenEvent::setEvents(const std::list<EventSharedPtr>& inEvents) {
98  std::list<EventSharedPtr>::const_iterator it = inEvents.begin();
99  for(; it != inEvents.end(); it++) {
100  try {
101  addEvent(*it);
102  } catch(Error& e) {
103  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
104  }
105  }
106 }
107 
108 /**
109  * Add an event to the list of events
110  *
111  * @param[in] inSource Pointer to event to be appended to
112  */
114  try {
115  mEvents.push_back(inSource);
116  } catch(Error& e) {
117  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
118  throw;
119  }
120 }
121 
123  mStartTimeInterval(), mEndTimeInterval(), mDuration(), mEvents() {}
124 
126 
127 } // namespace generic
128 } // namespace torc
void setEvents(const std::list< EventSharedPtr > &inEvents)
void setStartTimeInterval(const EventSharedPtr &inSource)
void runVisitor(_Tp &inoutVisited, BaseVisitor &inoutVisitor)
Definition: VisitorType.hpp:78
void setDuration(const Value &inValue)
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
virtual void accept(BaseVisitor &inoutVisitor)
A base class for Visitor.
Definition: VisitorType.hpp:31
void setEndTimeInterval(const EventSharedPtr &inSource)
boost::shared_ptr< ForbiddenEvent > ForbiddenEventSharedPtr
ForbiddenEvent class lists events which are forbidden during a period of times which is specified by ...
boost::shared_ptr< Event > EventSharedPtr
std::list< EventSharedPtr > mEvents
virtual ForbiddenEventSharedPtr newForbiddenEventPtr(const EventSharedPtr &inStartTimeInterval, const EventSharedPtr &inEndTimeInterval, const std::list< EventSharedPtr > &inEvents, const TimingSharedPtr &inTiming=TimingSharedPtr(), const Value &inDuration=Value())
void addEvent(const EventSharedPtr &inSource)
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