#include <AbstractSimObject.h>
Classes | |
| class | CustomPriorityQueue |
| This implementation of PriorityQueue imitates std::prioirty_queue but allows reserving space in the underlying std::vector. More... | |
Public Member Functions | |
| AbstractSimObject (size_t id, size_t numOutputs, size_t numInputs) | |
| Instantiates a new simulation object. | |
| AbstractSimObject (const AbstractSimObject &that) | |
| virtual | ~AbstractSimObject () |
| virtual AbstractSimObject * | clone () const =0 |
| a way to construct different subtypes | |
| EventTy | makeEvent (SimObject *sendObj, SimObject *recvObj, const EventTy::Type &type, const LogicUpdate &act, const SimTime &sendTime, SimTime delay=MIN_DELAY) |
| Make event. | |
| void | recvEvent (size_t inputIndex, const EventTy &e) |
| Recv event. | |
| virtual void | execEvent (Graph &graph, GNode &myNode, const EventTy &e)=0 |
| Exec event. | |
| size_t | simulate (Graph &graph, GNode &myNode) |
| Simulate. | |
| bool | isActive () const |
| Checks if is active. | |
| void | updateActive () |
| active is set to true if there exists a pending event(s) on each input pq or if one input pq (not all) is empty and an event with INFINITY_SIM_TIME has already been received telling that no more events on this input will be received. | |
| virtual size_t | numPendingEvents () const |
| virtual const std::string | toString () const |
| size_t | getId () const |
| Gets the id. | |
Static Public Attributes | |
| static size_t | NEVENTS_PER_ITER = 1024 |
| Upper limit on the number of events processed by a SimObject during a call to. | |
Private Types | |
| typedef CustomPriorityQueue < EventTy, EventRecvTimeLocalTieBrkCmp < EventTy > > | PriorityQueue |
Private Member Functions | |
| void | init (size_t id, size_t numOutputs, size_t numInputs) |
| Inits the object. | |
| void | deepCopy (const AbstractSimObject &that) |
| performs a deep copy. | |
| void | updateClock () |
| compute the min. | |
Private Attributes | |
| size_t | id |
| The id. | |
| size_t | numInputs |
| The number of inputs. | |
| size_t | numOutputs |
| number of outputs | |
| std::vector< SimTime > | inputTimes |
| store the timestamp of latest event received on an input line | |
| SimTime | clock |
| local clock value, is the minimum of events received on all input lines | |
| PriorityQueue | pendingEvents |
| Events received on any input go into pendingEvents and are stored here until processed. | |
| bool | active |
| time stamp of the last message sent on output protected SimTime lastSent = 0; | |
| size_t | eventIdCntr |
| Counter to assign id's to events sent by this SimObject. | |
Static Private Attributes | |
| static const bool | DEBUG = false |
| static const size_t | PQ_OVER_RESERVE = 1024 |
| multiplication factor for space reserved in the prioirty queue | |
The Class AbstractSimObject represents an abstract simulation object (processing station). A simulation application would inherit from this class.
typedef CustomPriorityQueue<EventTy, EventRecvTimeLocalTieBrkCmp<EventTy> > AbstractSimObject::PriorityQueue [private] |
| AbstractSimObject::AbstractSimObject | ( | size_t | id, | |
| size_t | numOutputs, | |||
| size_t | numInputs | |||
| ) | [inline] |
Instantiates a new simulation object.
| id | Must be unique | |
| numOutputs | the number of outputs | |
| numInputs | the number of inputs |
| AbstractSimObject::AbstractSimObject | ( | const AbstractSimObject & | that | ) | [inline] |
| virtual AbstractSimObject::~AbstractSimObject | ( | ) | [inline, virtual] |
| virtual AbstractSimObject* AbstractSimObject::clone | ( | ) | const [pure virtual] |
a way to construct different subtypes
Implements SimObject.
Implemented in Input, OneInputGate, Output, and TwoInputGate.
| void AbstractSimObject::deepCopy | ( | const AbstractSimObject & | that | ) | [inline, private] |
performs a deep copy.
| that | the that |
| virtual void AbstractSimObject::execEvent | ( | Graph & | graph, | |
| GNode & | myNode, | |||
| const EventTy & | e | |||
| ) | [pure virtual] |
Exec event.
The user code should override this method inorder to define the semantics of executing and event on a sub-type
| graph,: | the graph containg simulation objects as nodes and communication links as edges | |
| myNode,: | the node in the graph that has this SimObject as its node data | |
| e,: | the input event |
Implements SimObject.
Implemented in Input, OneInputGate, Output, and TwoInputGate.
| size_t AbstractSimObject::getId | ( | ) | const [inline, virtual] |
| void AbstractSimObject::init | ( | size_t | id, | |
| size_t | numOutputs, | |||
| size_t | numInputs | |||
| ) | [inline, private] |
Inits the object.
| id | unique identifier for this object | |
| numOutputs | the number of outputs | |
| numInputs | the number of inputs |
| bool AbstractSimObject::isActive | ( | ) | const [inline, virtual] |
| EventTy AbstractSimObject::makeEvent | ( | SimObject * | sendObj, | |
| SimObject * | recvObj, | |||
| const EventTy::Type & | type, | |||
| const LogicUpdate & | act, | |||
| const SimTime & | sendTime, | |||
| SimTime | delay = MIN_DELAY | |||
| ) | [inline, virtual] |
Make event.
| sendObj | the send obj | |
| recvObj | the recv obj | |
| type | the type | |
| act | the action to be performed | |
| sendTime | the send time | |
| delay | the delay |
Implements SimObject.
| virtual size_t AbstractSimObject::numPendingEvents | ( | ) | const [inline, virtual] |
Implements SimObject.
| void AbstractSimObject::recvEvent | ( | size_t | inputIndex, | |
| const EventTy & | e | |||
| ) | [inline, virtual] |
Recv event.
put in the input indexed by inputIndex
| inputIndex | ||
| e | the event |
Implements SimObject.
Simulate.
pre-condition: The object should be active
Computes the set of readyEvents, then executes the events in time-stamp order
Here the set of readyEvents is the subset of pendingEvents that have a recvTime <= this->clock
The parameter NEVENTS_PER_ITER defines an upper limit on the number of ready events that can be processed in one call to simulate
| graph,: | the graph containg simulation objects as nodes and communication links as edges | |
| myNode | the node in the graph that has this SimObject as its node data |
Implements SimObject.
| virtual const std::string AbstractSimObject::toString | ( | ) | const [inline, virtual] |
Implements SimObject.
Reimplemented in OneInputGate, and TwoInputGate.
| void AbstractSimObject::updateActive | ( | ) | [inline, virtual] |
active is set to true if there exists a pending event(s) on each input pq or if one input pq (not all) is empty and an event with INFINITY_SIM_TIME has already been received telling that no more events on this input will be received.
We can tell if there are pending events on input i if inputTimes[i] >= pendingEvents.top () We can tell if there are no pending events by checking pendingEvents.empty ();
Implements SimObject.
| void AbstractSimObject::updateClock | ( | ) | [inline, private] |
compute the min.
of the timestamps of latest message received so far for every input
bool AbstractSimObject::active [private] |
time stamp of the last message sent on output protected SimTime lastSent = 0;
whether it can process some events received on the input. i.e. if pendingEvents is computed, it'll be non-empty
SimTime AbstractSimObject::clock [private] |
local clock value, is the minimum of events received on all input lines
const bool AbstractSimObject::DEBUG = false [static, private] |
size_t AbstractSimObject::eventIdCntr [private] |
Counter to assign id's to events sent by this SimObject.
size_t AbstractSimObject::id [private] |
The id.
std::vector<SimTime> AbstractSimObject::inputTimes [private] |
store the timestamp of latest event received on an input line
size_t AbstractSimObject::NEVENTS_PER_ITER = 1024 [static] |
Upper limit on the number of events processed by a SimObject during a call to.
size_t AbstractSimObject::numInputs [private] |
The number of inputs.
size_t AbstractSimObject::numOutputs [private] |
number of outputs
Events received on any input go into pendingEvents and are stored here until processed.
readyEvents set, is a set of events that can safely be processed, if this AbstractSimObject is active. If minRecv is the min. of the latest timestamp received on any input i.e. min of inputTimes[i] for all i then events with timestamp <= minRecv go into readyEvents set. readyEvents set is a subset of pendingEvents.
const size_t AbstractSimObject::PQ_OVER_RESERVE = 1024 [static, private] |
multiplication factor for space reserved in the prioirty queue
1.6.3