OSDL::MVC::ProgrammedModel Class Reference

Event-based model, to be activated on specified ticks by the scheduler. More...

#include <OSDLModel.h>

Inheritance diagram for OSDL::MVC::ProgrammedModel:
Inheritance graph
[legend]
Collaboration diagram for OSDL::MVC::ProgrammedModel:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ProgrammedModel (const Engine::SimulationTickList &activationTicks, bool absolutelyDefined=true, bool autoRegister=true, Engine::ObjectSchedulingPolicy policy=Engine::relaxed, Engine::Weight weight=1)
 Constructor of an OSDL MVC model which is to be scheduled on programmed ticks.
 ProgrammedModel (Events::SimulationTick activationTick, bool absolutelyDefined=true, bool autoRegister=true, Engine::ObjectSchedulingPolicy policy=Engine::relaxed, Engine::Weight weight=1)
 Constructor of an OSDL MVC model which is to be scheduled on a specific programmed tick.
virtual ~ProgrammedModel () throw ()
 Virtual destructor.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const
 Returns an user-friendly description of the state of this object.
virtual void registerToScheduler ()
 Registers this active object to the supposedly already existing scheduler.
virtual void unregisterFromScheduler ()
 Unregisters this active object from the existing scheduler to whom it was supposedly registered.
bool areProgrammedActivationsAbsolute () const
 Tells whether programmed activations are defined absolutely (from the origin of simulation times, i.e.
void absoluteProgrammedActivationsWanted (bool on)
 Defines whether the programmed activations for this object are to be defined absolutely (from the origin of simulation times, i.e.
virtual const SimulationTickListgetProgrammedActivations () const
 Returns a reference to the internal list of programmed activations of this object.
virtual void setProgrammedActivations (const SimulationTickList &newActivationsList)
 Sets the list of programmed activations for this object to specified value.
virtual void addProgrammedActivations (const SimulationTickList &additionalActivationsList)
 Adds the specified list of simulation ticks to the list of activation ticks for this object.
virtual void onRegistering ()
 Automatically called by the scheduler at registration time.
virtual ObjectSchedulingPolicy getPolicy () const
 Returns the scheduling policy for this active object.
virtual Weight getWeight () const
 Returns the average processing need for each activation of this object.
virtual Events::SimulationTick getBirthTick () const
 Returns the birth time, expressed in simulation ticks, of this active object.
virtual void setBirthTick (Events::SimulationTick currentSimulationTick)
 Sets the birth time, expressed in simulation ticks, of this active object.
virtual void onActivation (Events::SimulationTick newTick)=0
 Pure virtual method, which is called when this active object gets activated on behalf of the scheduler.
virtual void onSkip (Events::SimulationTick skippedTick)
 Called whenever the scheduler had to skip a period of activation for this object.
virtual void onImpossibleActivation (Events::SimulationTick missedTick)
 Called whenever the scheduler was unable to activate this object.

Protected Member Functions

Events::SimulationTick getLocalTime () const
 Returns this object local time, as if the origin of time was this object creation.

Protected Attributes

SimulationTickList _programmedTicks
 Records the list of programmed simulation ticks that will be used by the scheduler to activate this object.
bool _absoluteTicks
 Tells whether the programmed trigger ticks should be understood as absolute (i.e.
ObjectSchedulingPolicy _policy
 Determines the scheduling policy of this object.
Weight _weight
 Describe the average processing need for each activation of this object.
bool _registered
 Tells whether this active object has already been registered to a scheduler.
Events::SimulationTick _birthTick
 The date of birth of this object, expressed in simulation time.

Detailed Description

Event-based model, to be activated on specified ticks by the scheduler.

See also:
OSDL::Engine::Scheduler

Definition at line 152 of file OSDLModel.h.


Constructor & Destructor Documentation

OSDL::MVC::ProgrammedModel::ProgrammedModel ( const Engine::SimulationTickList activationTicks,
bool  absolutelyDefined = true,
bool  autoRegister = true,
Engine::ObjectSchedulingPolicy  policy = Engine::relaxed,
Engine::Weight  weight = 1 
) [explicit]

Constructor of an OSDL MVC model which is to be scheduled on programmed ticks.

Parameters:
activationTicks is the list of simulation ticks when this model should be activated. This model does not take ownership of this list, it will make a copy of it.
autoRegister tells whether this new Model is to automatically register itself to the scheduler. It requires the scheduler to exist already.
policy allows to choose a scheduling policy, according to the quality of service this model requires.
weight evaluates how much processing power an activation of this model is to cost on average. This helps the scheduler doing its job balance.
Exceptions:
Engine::SchedulingException if the construction failed.
OSDL::MVC::ProgrammedModel::ProgrammedModel ( Events::SimulationTick  activationTick,
bool  absolutelyDefined = true,
bool  autoRegister = true,
Engine::ObjectSchedulingPolicy  policy = Engine::relaxed,
Engine::Weight  weight = 1 
) [explicit]

Constructor of an OSDL MVC model which is to be scheduled on a specific programmed tick.

Parameters:
activationTick is the simulation tick when this model should be activated.
autoRegister tells whether this new Model is to automatically register itself to the scheduler. It requires the scheduler to exist already.
policy allows to choose a scheduling policy, according to the quality of service this model requires.
weight evaluates how much processing power an activation of this model is to cost on average. This helps the scheduler doing its job balance.
Exceptions:
Engine::SchedulingException if the construction failed.
ProgrammedModel::~ProgrammedModel (  )  throw () [virtual]

Virtual destructor.

Note:
This model will automatically unsubscribe from the scheduler if needed.

Definition at line 122 of file OSDLModel.cc.


Member Function Documentation

void ProgrammedActiveObject::absoluteProgrammedActivationsWanted ( bool  on  )  [inherited]

Defines whether the programmed activations for this object are to be defined absolutely (from the origin of simulation times, i.e.

the scheduler start) or relatively to the simulation tick of the object registering to the scheduler.

Exceptions:
SchedulingException if the operation failed.

Definition at line 181 of file OSDLProgrammedActiveObject.cc.

References OSDL::Engine::ProgrammedActiveObject::_absoluteTicks, and OSDL::Engine::ActiveObject::_registered.

void ProgrammedActiveObject::addProgrammedActivations ( const SimulationTickList additionalActivationsList  )  [virtual, inherited]

Adds the specified list of simulation ticks to the list of activation ticks for this object.

Parameters:
additionalActivationsList the list of additional simulation ticks on which this object will be activated too.
Note:
The method will ensure that this object will not be activated more than once on any given simulation tick.
Scheduling settings should not be changed once an active object has been registered to the scheduler, as the list has already been transmitted to it.
Exceptions:
SchedulingException if the operation failed.

Definition at line 220 of file OSDLProgrammedActiveObject.cc.

References OSDL::Engine::ProgrammedActiveObject::_programmedTicks, and OSDL::Engine::ActiveObject::_registered.

bool ProgrammedActiveObject::areProgrammedActivationsAbsolute (  )  const [inherited]

Tells whether programmed activations are defined absolutely (from the origin of simulation times, i.e.

the scheduler start) or relatively to the simulation tick of the object registering to the scheduler.

Definition at line 172 of file OSDLProgrammedActiveObject.cc.

References OSDL::Engine::ProgrammedActiveObject::_absoluteTicks.

Referenced by OSDL::Engine::Scheduler::registerProgrammedObject(), and OSDL::Engine::Scheduler::unregisterProgrammedObject().

SimulationTick ActiveObject::getBirthTick (  )  const [virtual, inherited]

Returns the birth time, expressed in simulation ticks, of this active object.

Definition at line 107 of file OSDLActiveObject.cc.

References OSDL::Engine::ActiveObject::_birthTick.

Referenced by OSDL::Engine::Scheduler::unregisterProgrammedObject().

Events::SimulationTick OSDL::Engine::ActiveObject::getLocalTime (  )  const [protected, inherited]

Returns this object local time, as if the origin of time was this object creation.

ObjectSchedulingPolicy ActiveObject::getPolicy (  )  const [virtual, inherited]

Returns the scheduling policy for this active object.

Definition at line 80 of file OSDLActiveObject.cc.

References OSDL::Engine::ActiveObject::_policy.

Referenced by OSDL::Engine::PeriodicSlot::add().

const SimulationTickList & ProgrammedActiveObject::getProgrammedActivations (  )  const [virtual, inherited]

Returns a reference to the internal list of programmed activations of this object.

These are the activations as they were specified: if they were relative ticks, they are still offsets, not absolute times.

Definition at line 195 of file OSDLProgrammedActiveObject.cc.

References OSDL::Engine::ProgrammedActiveObject::_programmedTicks.

Referenced by OSDL::Engine::Scheduler::registerProgrammedObject(), and OSDL::Engine::Scheduler::unregisterProgrammedObject().

Weight ActiveObject::getWeight (  )  const [virtual, inherited]

Returns the average processing need for each activation of this object.

Note:
The greater the weight is, the heavier processing should be.

Definition at line 89 of file OSDLActiveObject.cc.

References OSDL::Engine::ActiveObject::_weight.

virtual void OSDL::Engine::ActiveObject::onActivation ( Events::SimulationTick  newTick  )  [pure virtual, inherited]

Pure virtual method, which is called when this active object gets activated on behalf of the scheduler.

Note:
This is where the objects are to live actually: their time slice is to be spent here.
If, for any reason, there is a simulation skip, this method may not be called for some objects. Refer to the onSkip method, which would be called instead (and, sadly, later).
See also:
onSkip.
virtual void OSDL::Engine::ActiveObject::onImpossibleActivation ( Events::SimulationTick  missedTick  )  [virtual, inherited]

Called whenever the scheduler was unable to activate this object.

This can happen for example when an absolute simulation tick is specified whereas the current time is already in its future.

Default behaviour for this method is: throw a SchedulingException.

Parameters:
missedTick tells which tick is out of range.
Exceptions:
SchedulingException if this active object should not stand activation failures.
void ProgrammedActiveObject::onRegistering (  )  [virtual, inherited]

Automatically called by the scheduler at registration time.

Note:
Registering does not always imply object birth, as if the scheduler is not currently running, then birth will happen only when it is started.
Exceptions:
SchedulingException if the operation failed.

Definition at line 245 of file OSDLProgrammedActiveObject.cc.

References OSDL::Engine::ActiveObject::_registered.

Referenced by OSDL::Engine::Scheduler::registerProgrammedObject().

virtual void OSDL::Engine::ActiveObject::onSkip ( Events::SimulationTick  skippedTick  )  [virtual, inherited]

Called whenever the scheduler had to skip a period of activation for this object.

Default behaviour for this method is: do nothing except complain in the warning channel.

Parameters:
skippedTick tells which tick was skipped.
Exceptions:
SchedulingException if this active object cannot stand skipped stimulation ticks.
Note:
Some objects may call the onActivation method for the skipped tick, to emulate the behaviour they would have had if they could have been scheduled at the right time.
void ProgrammedActiveObject::registerToScheduler (  )  [virtual, inherited]

Registers this active object to the supposedly already existing scheduler.

Exceptions:
SchedulingException if the operation failed.

Implements OSDL::Engine::ActiveObject.

Definition at line 121 of file OSDLProgrammedActiveObject.cc.

References OSDL::Engine::ActiveObject::_registered, OSDL::Engine::Scheduler::GetExistingScheduler(), and OSDL::Engine::Scheduler::registerProgrammedObject().

Referenced by OSDL::Engine::ProgrammedActiveObject::ProgrammedActiveObject().

virtual void OSDL::Engine::ActiveObject::setBirthTick ( Events::SimulationTick  currentSimulationTick  )  [virtual, inherited]

Sets the birth time, expressed in simulation ticks, of this active object.

Note:
Called by the scheduler, when registering this active object.
Exceptions:
SchedulingException if the operation failed.

Reimplemented in OSDL::Engine::PeriodicalActiveObject.

Referenced by OSDL::Engine::Scheduler::registerProgrammedObject().

void ProgrammedActiveObject::setProgrammedActivations ( const SimulationTickList newActivationsList  )  [virtual, inherited]

Sets the list of programmed activations for this object to specified value.

Parameters:
newActivationsList the list of simulation ticks which will be copied internally.
Note:
Any previously defined activations are lost.
Scheduling settings should not be changed once an active object has been registered to the scheduler, as the list has already been transmitted to it.
See also:
addProgrammedActivations.
Exceptions:
SchedulingException if the operation failed.

Definition at line 205 of file OSDLProgrammedActiveObject.cc.

References OSDL::Engine::ProgrammedActiveObject::_programmedTicks, and OSDL::Engine::ActiveObject::_registered.

const string ProgrammedModel::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const [virtual]

Returns an user-friendly description of the state of this object.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
Ceylan::TextDisplayable

Reimplemented from OSDL::Engine::ProgrammedActiveObject.

Definition at line 129 of file OSDLModel.cc.

void ProgrammedActiveObject::unregisterFromScheduler (  )  [virtual, inherited]

Unregisters this active object from the existing scheduler to whom it was supposedly registered.

Exceptions:
SchedulingException if the operation failed.

Implements OSDL::Engine::ActiveObject.

Definition at line 146 of file OSDLProgrammedActiveObject.cc.

References OSDL::Engine::ActiveObject::_registered, OSDL::Engine::Scheduler::GetExistingScheduler(), and OSDL::Engine::Scheduler::unregisterProgrammedObject().

Referenced by OSDL::Engine::ProgrammedActiveObject::~ProgrammedActiveObject().


Member Data Documentation

Tells whether the programmed trigger ticks should be understood as absolute (i.e.

if their simulation ticks should be taken litteraly), or as relative (defined as an offset from this object birth time).

Is true by default.

Definition at line 347 of file OSDLProgrammedActiveObject.h.

Referenced by OSDL::Engine::ProgrammedActiveObject::absoluteProgrammedActivationsWanted(), OSDL::Engine::ProgrammedActiveObject::areProgrammedActivationsAbsolute(), and OSDL::Engine::ProgrammedActiveObject::toString().

The date of birth of this object, expressed in simulation time.

Note:
the date of birth corresponds to the first future simulation tick this object is known for the running scheduler (either the scheduler start-up, if this object was registered before), or the simulation tick at which this object was dynamically registered to the scheduler.

Definition at line 373 of file OSDLActiveObject.h.

Referenced by OSDL::Engine::ActiveObject::getBirthTick(), OSDL::Engine::PeriodicalActiveObject::setBirthTick(), and OSDL::Engine::ActiveObject::toString().

ObjectSchedulingPolicy OSDL::Engine::ActiveObject::_policy [protected, inherited]

Determines the scheduling policy of this object.

Definition at line 338 of file OSDLActiveObject.h.

Referenced by OSDL::Engine::ActiveObject::getPolicy(), and OSDL::Engine::ActiveObject::toString().

SimulationTickList OSDL::Engine::ProgrammedActiveObject::_programmedTicks [protected, inherited]
bool OSDL::Engine::ActiveObject::_registered [protected, inherited]
Weight OSDL::Engine::ActiveObject::_weight [protected, inherited]

Describe the average processing need for each activation of this object.

The greater the weight is, the heavier processing should be.

Definition at line 349 of file OSDLActiveObject.h.

Referenced by OSDL::Engine::ActiveObject::getWeight(), and OSDL::Engine::ActiveObject::toString().


The documentation for this class was generated from the following files:
Generated on Mon Nov 29 14:05:54 2010 for OSDL by  doxygen 1.6.3