torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Event.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/Event.hpp"
17 #include "torc/generic/Port.hpp"
19 
20 namespace torc {
21 namespace generic {
22 
23 /**
24  * Create an event.
25  *
26  * @param[in] inEventType Event type.
27  * @param[in] inPorts List of ports to this composition.
28  * @param[in] inPortReferences List of port references to this composition.
29  * @param[in] inNets List of nets to this composition.
30  * @param[in] inTransition Pointer to logic state value(transition/becomes) [optional].
31  * If no transition are specified, then the default meaning is any logic state change.
32  * @param[in] inPortList Connected Port list to this event [optional].
33  * @param[in] inOffsetTime Offset time retative to an event [optional].
34  * This is must for OffsetEvent, but optional for normal Event.
35  *
36  * @return Pointer to created event.
37  */
39  const std::list<PortSharedPtr>& inPorts,
40  const std::list<PortReferenceSharedPtr>& inPortReferences,
41  const std::list<NetSharedPtr>& inNets, const LogicElementSharedPtr& inTransition,
42  const PortListSharedPtr& inPortList, const Value& inOffsetTime) throw (Error) {
43  try {
44  EventSharedPtr newEvent;
45  create(newEvent);
46  newEvent->setType(inEventType);
47  std::list<PortSharedPtr>::const_iterator portIt = inPorts.begin();
48  for(; portIt != inPorts.end(); portIt++) {
49  newEvent->addPort(*portIt);
50  }
51 
52  std::list<PortReferenceSharedPtr>::const_iterator portRefIt = inPortReferences.begin();
53  for(; portRefIt != inPortReferences.end(); portRefIt++) {
54  newEvent->addPortReference(*portRefIt);
55  }
56 
57  std::list<NetSharedPtr>::const_iterator netIt = inNets.begin();
58  for(; netIt != inNets.end(); netIt++) {
59  newEvent->addNet(*netIt);
60  }
61  if(inTransition) {
62  newEvent->setTransition(inTransition);
63  }
64  if(inPortList) {
65  newEvent->setPortList(inPortList);
66  }
67  if(Event::eTypeOffsetEvent == inEventType) {
68  if(inOffsetTime.getIsSet()) {
69  newEvent->setOffsetTime(inOffsetTime);
70  }
71  }
72  return newEvent;
73  } catch(Error& e) {
74  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
75  throw;
76  }
77 }
78 
79 void Event::accept(BaseVisitor& inoutVisitor) throw (Error) {
80  try {
81  runVisitor(*this, inoutVisitor);
82  } catch(Error& e) {
83  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
84  throw;
85  }
86 }
87 
88 /**
89  * Set the event type
90  *
91  * @param[in] inSource Event type
92  */
93 void Event::setType(const Type& inSource) {
94  mType = inSource;
95 }
96 
97 /**
98  * Add a port to the port list.
99  *
100  * @param[in] inPort Pointer to port to be added.
101  */
102 void Event::addPort(const PortSharedPtr& inPort) {
103  mPortElements.push_back(PortElement(inPort));
104 }
105 
106 /**
107  * Add a port reference to the port list.
108  *
109  * @param[in] inPortRef Pointer to port reference to be added.
110  */
112  mPortElements.push_back(PortElement(inPortRef));
113 }
114 
115 /**
116  * Set the pointer to portList
117  *
118  * @param[in] inPortList Pointer to portList
119  */
120 
121 void Event::setPortList(const PortListSharedPtr& inPortList) {
122  mPortList = inPortList;
123 }
124 
125 /**
126  * Add a Net to the Net list.
127  *
128  * @param[in] inNet Pointer to Net to be added.
129  */
130 void Event::addNet(const NetSharedPtr& inNet) {
131  mNets.push_back(inNet);
132 }
133 
134 /**
135  * Set the pointer to logic state value(transition/becomes).
136  *
137  * @param[in] inSource Pointer to logic state value(transition/becomes).
138  */
140  mTransition = inSource;
141 }
142 
143 /**
144  * Set the offset time retative to an event.
145  * @param[in] value Offset time retative to an event.
146  */
147 void Event::setOffsetTime(const Value& value) {
148  mOffsetTime = value;
149 }
150 
151 Event::Event() : Visitable(), SelfReferencing<Event>(), mType(), mPortElements(), mPortList(),
152  mNets(), mTransition(), mOffsetTime() {}
153 
154 Event::~Event() throw () {}
155 
156 } // namespace generic
157 } // namespace torc
void setType(const Type &inSource)
Definition: Event.cpp:93
std::list< NetSharedPtr > mNets
Definition: Event.hpp:199
void setTransition(const LogicElementSharedPtr &inSource)
Definition: Event.cpp:139
boost::shared_ptr< LogicElement > LogicElementSharedPtr
Represents port element like port or port reference.
Definition: PortElement.hpp:32
PortListSharedPtr mPortList
Definition: Event.hpp:198
virtual ~Event()
Definition: Event.cpp:154
void runVisitor(_Tp &inoutVisited, BaseVisitor &inoutVisitor)
Definition: VisitorType.hpp:78
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
boost::shared_ptr< Net > NetSharedPtr
void addPortReference(const PortReferenceSharedPtr &inPortRef)
Definition: Event.cpp:111
A base class for Visitor.
Definition: VisitorType.hpp:31
boost::shared_ptr< PortReference > PortReferenceSharedPtr
boost::shared_ptr< PortList > PortListSharedPtr
boost::shared_ptr< Event > EventSharedPtr
std::list< PortElement > mPortElements
Definition: Event.hpp:197
virtual void accept(BaseVisitor &inoutVisitor)
Definition: Event.cpp:79
void addPort(const PortSharedPtr &inPort)
Definition: Event.cpp:102
void setOffsetTime(const Value &value)
Definition: Event.cpp:147
Event is used to describe an event on a port or a net using logic state transitions. Events can also be described for unordered groups of ports or nets using portGroup or netGroup. An ordered list of ports may also be used using a portList.
Definition: Event.hpp:45
boost::shared_ptr< Port > PortSharedPtr
virtual EventSharedPtr newEventPtr(const Event::Type &inEventType, const std::list< PortSharedPtr > &inPorts, const std::list< PortReferenceSharedPtr > &inPortReferences, const std::list< NetSharedPtr > &inNets, const LogicElementSharedPtr &inTransition=LogicElementSharedPtr(), const PortListSharedPtr &inPortList=PortListSharedPtr(), const Value &inOffsetTime=Value())
Definition: Event.cpp:38
void addNet(const NetSharedPtr &inNet)
Definition: Event.cpp:130
LogicElementSharedPtr mTransition
Definition: Event.hpp:200
void setPortList(const PortListSharedPtr &inPortList)
Definition: Event.cpp:121
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