torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Event.hpp
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 #ifndef TORC_GENERIC_EVENT_HPP
17 #define TORC_GENERIC_EVENT_HPP
18 
24 #include "torc/generic/Value.hpp"
26 
27 #include <list>
28 
29 namespace torc { namespace generic { class PortElement; } }
30 namespace torc { namespace generic { class PortList; } }
31 namespace torc { namespace generic { class Net; } }
32 
33 namespace torc {
34 namespace generic {
35 
36 /**
37  * @brief Event is used to describe an event on a port or a net using
38  * logic state transitions. Events can also be described for unordered groups
39  * of ports or nets using portGroup or netGroup. An ordered list of ports may
40  * also be used using a portList.
41  *
42  * This class also models edif OffsetEvent construct,
43  * which is used to define a time relative to an Event.
44  */
45 class Event : public Visitable, public SelfReferencing<Event> {
46  friend class FactoryType<Event> ;
47 
48 public:
49  /**
50  * @enum Type
51  * Event type
52  */
53  enum Type {
55  };
56 
57  /**
58  * Convenience class to visit an Event.
59  */
61 
62  virtual void accept(BaseVisitor& inoutVisitor) throw (Error);
63 
64  /**
65  * Convenience class to create an Event.
66  */
67  class Factory : public FactoryType<Event> {
68  public:
70  /**
71  * Create an event.
72  *
73  * @param[in] inEventType Event type.
74  * @param[in] inPorts List of ports to this composition.
75  * @param[in] inPortReferences List of port references to this composition.
76  * @param[in] inNets List of nets to this composition.
77  * @param[in] inTransition Pointer to logic state value(transition/becomes) [optional].
78  * If no transition are specified, then the default meaning is any logic state
79  * change.
80  * @param[in] inPortList Connected Port list to this event [optional].
81  * @param[in] inOffsetTime Offset time retative to an event [optional].
82  * This is must for OffsetEvent, but optional for normal Event.
83  *
84  * @return Pointer to created event.
85  */
86  virtual EventSharedPtr newEventPtr(const Event::Type& inEventType,
87  const std::list<PortSharedPtr>& inPorts,
88  const std::list<PortReferenceSharedPtr>& inPortReferences,
89  const std::list<NetSharedPtr>& inNets,
90  const LogicElementSharedPtr& inTransition = LogicElementSharedPtr(),
91  const PortListSharedPtr& inPortList = PortListSharedPtr(),
92  const Value& inOffsetTime = Value()) throw (Error);
93  };
94 
95  /**
96  * Get the event type
97  *
98  * @return Event type
99  */
100  inline const Type getType() const;
101 
102  /**
103  * Set the event type
104  *
105  * @param[in] inSource Event type
106  */
107  void setType(const Type& inSource);
108 
109  /**
110  * Get the list of port elements of an Event.
111  * When port element list size is more than one, it is portGroup.
112  *
113  * @return outPortElements List of port elements to be appended to
114  */
115  inline void getPortElements(std::list<PortElement>& outPortElements) const;
116 
117  /**
118  * Add a port to the port list.
119  *
120  * @param[in] inPort Pointer to port to be added.
121  */
122  void addPort(const PortSharedPtr& inPort);
123 
124  /**
125  * Add a port reference to the port list.
126  *
127  * @param[in] inPortRef Pointer to port reference to be added.
128  */
129  void addPortReference(const PortReferenceSharedPtr& inPortRef);
130 
131  /**
132  * Get the pointer to portList of an Event.
133  *
134  * @return Pointer to portList
135  */
136  inline const PortListSharedPtr getPortList() const;
137 
138  /**
139  * Set the pointer to portList
140  *
141  * @param[in] inPortList Pointer to portList
142  */
143  void setPortList(const PortListSharedPtr& inPortList);
144 
145  /**
146  * Get the list of Net of an Event.
147  * When Net element list size is more than one, it is NetGroup.
148  *
149  * @return outNets List of nets to be appended to
150  */
151  inline void getNets(std::list<NetSharedPtr>& outNets) const;
152 
153  /**
154  * Add a Net to the Net list.
155  *
156  * @param[in] inNet Pointer to Net to be added.
157  */
158  void addNet(const NetSharedPtr& inNet);
159 
160  /**
161  * Get the pointer to logic state value(transition/becomes).
162  *
163  * @return Pointer to logic state value(transition/becomes).
164  */
165  inline const LogicElementSharedPtr getTransition() const;
166 
167  /**
168  * Set the pointer to logic state value(transition/becomes).
169  *
170  * @param[in] inSource Pointer to logic state value(transition/becomes).
171  */
172  void setTransition(const LogicElementSharedPtr& inSource);
173 
174  /**
175  * Get the offset time retative to an event.
176  * @return Value offset time retative to an event.
177  */
178  inline const Value getOffsetTime() const;
179 
180  /**
181  * Set the offset time retative to an event.
182  * @param[in] value Offset time retative to an event.
183  */
184  void setOffsetTime(const Value& value);
185 
186  virtual ~Event() throw ();
187 
188 protected:
189  Event();
190 
191 private:
192  Event(const Event& source);
193 
194  Event& operator=(const Event& source);
195 
199  std::list<NetSharedPtr> mNets;
202 
203 };
204 
205 /**
206  * Get the event type
207  *
208  * @return Event type
209  */
210 inline const Event::Type Event::getType() const {
211  return mType;
212 }
213 
214 /**
215  * Get the list of port elements of an Event.
216  * When port element list size is more than one, it is portGroup.
217  *
218  * @return outPortElements List of port elements to be appended to
219  */
220 inline void Event::getPortElements(std::list<PortElement>& outPortElements) const {
221  outPortElements.insert(outPortElements.end(), mPortElements.begin(), mPortElements.end());
222 }
223 
224 /**
225  * Get the pointer to portList of an Event.
226  *
227  * @return Pointer to portList
228  */
229 inline const PortListSharedPtr Event::getPortList() const {
230  return mPortList;
231 }
232 
233 /**
234  * Get the list of nets of an Event.
235  * When Net element list size is more than one, it is NetGroup.
236  *
237  * @return outNets List of nets to be appended to
238  */
239 inline void Event::getNets(std::list<NetSharedPtr>& outNets) const {
240  outNets.insert(outNets.end(), mNets.begin(), mNets.end());
241 }
242 
243 /**
244  * Get the pointer to logic state value(transition/becomes).
245  *
246  * @return Pointer to logic state value(transition/becomes).
247  */
249  return mTransition;
250 }
251 
252 /**
253  * Get the offset time retative to an event.
254  * @return Value offset time retative to an event.
255  */
256 inline const Value Event::getOffsetTime() const {
257  return mOffsetTime;
258 }
259 
260 } // namespace generic
261 } // namespace torc
262 
263 #endif // TORC_GENERIC_EVENT_HPP
An acyclic inoutVisitor implementation.
Definition: VisitorType.hpp:57
const Type getType() const
Definition: Event.hpp:210
void getNets(std::list< NetSharedPtr > &outNets) const
Definition: Event.hpp:239
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
void getPortElements(std::list< PortElement > &outPortElements) const
Definition: Event.hpp:220
virtual ~Event()
Definition: Event.cpp:154
VisitorType< Event > Visitor
Definition: Event.hpp:60
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
const PortListSharedPtr getPortList() const
Definition: Event.hpp:229
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
const LogicElementSharedPtr getTransition() const
Definition: Event.hpp:248
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
A placeholder for a factory method.
Definition: FactoryType.hpp:35
LogicElementSharedPtr mTransition
Definition: Event.hpp:200
const Value getOffsetTime() const
Definition: Event.hpp:256
void setPortList(const PortListSharedPtr &inPortList)
Definition: Event.cpp:121
An object that receives an inoutVisitor.
Definition: Visitable.hpp:38