SIMLIB/C++ 3.09
Loading...
Searching...
No Matches
simlib3::Event Class Referenceabstract

abstract base class for events Event behavior is simple function (can not be interrupted) More...

#include <simlib.h>

Inheritance diagram for simlib3::Event:
Collaboration diagram for simlib3::Event:

Public Member Functions

 Event (Priority_t p=DEFAULT_PRIORITY)
 constructor, default priority if not specified
virtual ~Event ()
 destructor
virtual void Behavior ()=0
 behavior description
virtual void Output () const override
 print object to default output
virtual std::string Name () const override
 name of object
virtual void Activate (double t) override
 activate at time t (schedule)
void Activate ()
 activate now
Public Member Functions inherited from simlib3::Entity
unsigned long id () const
 Entity (Priority_t p=DEFAULT_PRIORITY)
 constructor
virtual ~Entity ()
 destructor
 operator Entity * ()
double ActivationTime ()
 get activation time of entity - iff scheduled
it is here, because Entity has no knowledge of calendar activation record structure
void Activate ()
 activate now
virtual void Passivate ()
 deactivation
bool Idle ()
 entity activation is not scheduled in calendar
void Cancel ()
 end Behavior() and remove entity
virtual void Out () override
 remove entity from queue
EventNotice * GetEventNotice ()
Public Member Functions inherited from simlib3::SimObject
bool TestAndSetFlag (bool new_value, unsigned n)
 internal method for flag manipulation is used for algebraic loop checking in continuous blocks
 SimObject ()
 constructor
virtual ~SimObject ()
 virtual destructor
void * operator new (size_t size)
 allocate object, set _flags
void operator delete (void *ptr)
 deallocate object
void * operator new[] (size_t size)=delete
void operator delete[] (void *ptr)=delete
bool isAllocated () const
bool HasName () const
void SetName (const std::string &name)
 assign the name

Private Member Functions

virtual void _Run () noexcept override
 activation method, called from simulation control algorithm
virtual void Terminate () override
 passivate event, it will be destroyed if not activated later in Behavior()
Should not be used.

Additional Inherited Members

Public Types inherited from simlib3::Entity
typedef EntityPriority_t Priority_t
Public Types inherited from simlib3::SimObject
enum  _Flags { _CLEAR_ALL_FLAGS = 0 , _ALLOCATED_FLAG = 1<<0 , _EVAL_FLAG = 1<<1 , _HAS_NAME_FLAG = 1<<2 }
Public Attributes inherited from simlib3::Entity
Priority_t Priority
 priority of the entity (scheduling,queues)
Protected Attributes inherited from simlib3::Entity
unsigned long _Ident
 unique identification number of entity
double _MarkTime
union simlib3::Entity:: { ... }  
ServicePriority_t _SPrio
 priority of service in Facility
Protected Attributes inherited from simlib3::SimObject
unsigned _flags
 bool flags for internal use (TODO bitfield?)
Static Protected Attributes inherited from simlib3::Entity
static unsigned long _Number = 0L
 current number of entities

Detailed Description

abstract base class for events Event behavior is simple function (can not be interrupted)

Definition at line 493 of file simlib.h.

Constructor & Destructor Documentation

◆ Event()

simlib3::Event::Event ( Priority_t p = DEFAULT_PRIORITY)

constructor, default priority if not specified

Definition at line 28 of file event.cc.

References Dprintf, and simlib3::Entity::Entity().

◆ ~Event()

simlib3::Event::~Event ( )
virtual

destructor

Definition at line 35 of file event.cc.

References Dprintf.

Member Function Documentation

◆ _Run()

void simlib3::Event::_Run ( )
overrideprivatevirtualnoexcept

activation method, called from simulation control algorithm

Implements simlib3::Entity.

Definition at line 42 of file event.cc.

References Behavior(), simlib3::Entity::Idle(), and Terminate().

◆ Activate() [1/2]

void simlib3::Entity::Activate ( )
inline

activate now

Definition at line 413 of file simlib.h.

◆ Activate() [2/2]

void simlib3::Event::Activate ( double t)
overridevirtual

◆ Behavior()

virtual void simlib3::Event::Behavior ( )
pure virtual

behavior description

Implemented in simlib3::Sampler, and simlib3::ZDelayTimer.

References simlib3::Entity::Activate(), Activate(), Name(), Output(), and t.

Referenced by _Run().

◆ Name()

std::string simlib3::Event::Name ( ) const
overridevirtual

name of object

get name of event. It is generic "Event#" if not explicitly named

Reimplemented from simlib3::SimObject.

Definition at line 71 of file event.cc.

References simlib3::Entity::_Ident, simlib3::SimObject::Name(), and simlib3::SIMLIB_create_tmp_name().

Referenced by Behavior(), Output(), and Terminate().

◆ Output()

void simlib3::Event::Output ( ) const
overridevirtual

print object to default output

Reimplemented from simlib3::SimObject.

Reimplemented in simlib3::Sampler.

Definition at line 35 of file output1.cc.

References Name(), and simlib3::Print().

Referenced by Behavior().

◆ Terminate()

void simlib3::Event::Terminate ( )
overrideprivatevirtual

passivate event, it will be destroyed if not activated later in Behavior()
Should not be used.

It is there only for backwards compatibility.

Implements simlib3::Entity.

Definition at line 52 of file event.cc.

References Dprintf, simlib3::SQS::Get(), simlib3::Entity::Idle(), simlib3::SimObject::isAllocated(), Name(), and simlib3::SIMLIB_Current.

Referenced by _Run().


The documentation for this class was generated from the following files: