INET Framework for OMNeT++/OMNEST
inet::Macho::_StateInstance Class Referenceabstract

#include <Macho.h>

Inheritance diagram for inet::Macho::_StateInstance:
inet::Macho::_RootInstance inet::Macho::_SubstateInstance< S >

Public Member Functions

virtual ~_StateInstance ()
 
void entry (_StateInstance &previous, bool first=true)
 
void exit (_StateInstance &next)
 
void init (bool history)
 
void saveHistory (_StateInstance &shallow, _StateInstance &deep)
 
void setHistorySuper (_StateInstance &deep)
 
void shutdown ()
 
void restore (_StateInstance &instance)
 
virtual ID id ()=0
 
virtual Key key ()=0
 
virtual const char * name ()=0
 
virtual _StateInstancecreate (_MachineBase &machine, _StateInstance *parent)=0
 
virtual void createBox ()=0
 
virtual void deleteBox ()=0
 
void setBox (void *box)
 
bool isChild (const _StateInstance &instance)
 
_StateSpecificationspecification ()
 
void * box ()
 
_MachineBasemachine ()
 
void setHistory (_StateInstance *history) const
 
_StateInstancehistory () const
 

Protected Member Functions

 _StateInstance (_MachineBase &machine, _StateInstance *parent)
 

Protected Attributes

_MachineBasemyMachine
 
_StateSpecificationmySpecification
 
_StateInstancemyHistory
 
_StateInstancemyParent
 
void * myBox
 
void * myBoxPlace
 

Constructor & Destructor Documentation

inet::_StateInstance::_StateInstance ( _MachineBase machine,
_StateInstance parent 
)
protected
122  : myMachine(machine)
123  , mySpecification(nullptr)
124  , myHistory(nullptr)
125  , myParent(parent)
126  , myBox(nullptr)
127  , myBoxPlace(nullptr)
128 {
129 }
void * myBox
Definition: Macho.h:825
_StateSpecification * mySpecification
Definition: Macho.h:822
_StateInstance * myParent
Definition: Macho.h:824
_MachineBase & machine()
Definition: Macho.h:804
_StateInstance * myHistory
Definition: Macho.h:823
_MachineBase & myMachine
Definition: Macho.h:821
void * myBoxPlace
Definition: Macho.h:826
inet::_StateInstance::~_StateInstance ( )
virtual
132 {
133  if (myBoxPlace)
134  ::operator delete(myBoxPlace);
135 
136  delete mySpecification;
137 }
_StateSpecification * mySpecification
Definition: Macho.h:822
void * myBoxPlace
Definition: Macho.h:826

Member Function Documentation

void* inet::Macho::_StateInstance::box ( )
inline

Referenced by inet::Macho::MachoLink< C, P >::_box().

799  {
800  assert(myBox);
801  return myBox;
802  }
void * myBox
Definition: Macho.h:825
virtual _StateInstance* inet::Macho::_StateInstance::create ( _MachineBase machine,
_StateInstance parent 
)
pure virtual
virtual void inet::Macho::_StateInstance::createBox ( )
pure virtual
virtual void inet::Macho::_StateInstance::deleteBox ( )
pure virtual
void inet::_StateInstance::entry ( _StateInstance previous,
bool  first = true 
)

Referenced by entry().

140 {
141  // Only Root has no parent
142  if (!myParent)
143  return;
144 
145  // first entry or previous state is not substate -> perform entry
146  if (first || !previous.isChild(*this)) {
147  myParent->entry(previous, false);
148 
149  createBox();
150 
151  MACHO_TRC2(name(), "Entry");
153  }
154 }
void entry(_StateInstance &previous, bool first=true)
Definition: Macho.cc:139
virtual const char * name()=0
virtual void createBox()=0
_StateSpecification * mySpecification
Definition: Macho.h:822
_StateInstance * myParent
Definition: Macho.h:824
virtual void entry()
Definition: Macho.h:538
#define MACHO_TRC2(STATE, MSG)
Definition: Macho.cc:46
void inet::_StateInstance::exit ( _StateInstance next)

Referenced by exit().

157 {
158  // Only Root has no parent
159  if (!myParent)
160  return;
161 
162  // self transition or next state is not substate -> perform exit
163  if (this == &next || !next.isChild(*this)) {
164  MACHO_TRC2(name(), "Exit");
166 
167  // EmptyBox should be most common box, so optimize for this case.
169  mySpecification->_deleteBox(*this);
170 
171  myParent->exit(next);
172  }
173 }
static _EmptyBox theEmptyBox
Definition: Macho.h:382
virtual const char * name()=0
void exit(_StateInstance &next)
Definition: Macho.cc:156
void * myBox
Definition: Macho.h:825
_StateSpecification * mySpecification
Definition: Macho.h:822
_StateInstance * myParent
Definition: Macho.h:824
virtual void _deleteBox(_StateInstance &instance)
Definition: Macho.h:566
#define MACHO_TRC2(STATE, MSG)
Definition: Macho.cc:46
virtual void exit()
Definition: Macho.h:535
_StateInstance* inet::Macho::_StateInstance::history ( ) const
inline

Referenced by inet::Macho::_AdaptingInitializer::adapt(), inet::Macho::MachoLink< C, P >::history(), and init().

816  {
817  return myHistory;
818  }
_StateInstance * myHistory
Definition: Macho.h:823
virtual ID inet::Macho::_StateInstance::id ( )
pure virtual
void inet::_StateInstance::init ( bool  history)

Referenced by inet::Macho::_DefaultInitializer::execute(), inet::Macho::_HistoryInitializer::execute(), inet::Macho::_AdaptingInitializer::execute(), and inet::Macho::_MachineBase::rattleOn().

176 {
177  if (history && myHistory) {
178  MACHO_TRC3(name(), "History transition to", myHistory->name());
179  myMachine.setPendingState(*myHistory, &_theDefaultInitializer);
180  }
181  else {
182  MACHO_TRC2(name(), "Init");
184  }
185 
186  myHistory = nullptr;
187 }
virtual void init()
Definition: Macho.h:545
virtual const char * name()=0
void setPendingState(_StateInstance &instance, _Initializer *init)
Definition: Macho.h:1516
_StateInstance * history() const
Definition: Macho.h:815
_StateSpecification * mySpecification
Definition: Macho.h:822
#define MACHO_TRC2(STATE, MSG)
Definition: Macho.cc:46
_StateInstance * myHistory
Definition: Macho.h:823
#define MACHO_TRC3(STATE, MSG1, MSG2)
Definition: Macho.cc:47
_MachineBase & myMachine
Definition: Macho.h:821
bool inet::Macho::_StateInstance::isChild ( const _StateInstance instance)
inline

Referenced by inet::Macho::_MachineBase::clearHistoryDeep(), entry(), and exit().

788  {
789  return this == &instance || (myParent && myParent->isChild(instance));
790  }
bool isChild(const _StateInstance &instance)
Definition: Macho.h:787
_StateInstance * myParent
Definition: Macho.h:824
virtual Key inet::Macho::_StateInstance::key ( )
pure virtual
_MachineBase& inet::Macho::_StateInstance::machine ( )
inline
805  {
806  return myMachine;
807  }
_MachineBase & myMachine
Definition: Macho.h:821
virtual const char* inet::Macho::_StateInstance::name ( )
pure virtual
void inet::Macho::_StateInstance::restore ( _StateInstance instance)
inline

Referenced by inet::Macho::Machine< fsm::TopState >::Machine().

753  {
754  mySpecification->_restore(instance);
755  }
_StateSpecification * mySpecification
Definition: Macho.h:822
virtual void _restore(_StateInstance &current)
Definition: Macho.cc:101
void inet::Macho::_StateInstance::saveHistory ( _StateInstance shallow,
_StateInstance deep 
)
inline
726  {
727  // Check state's history strategy.
728  mySpecification->_saveHistory(*this, shallow, deep);
729  }
virtual void _saveHistory(_StateInstance &self, _StateInstance &shallow, _StateInstance &deep)
Definition: Macho.h:569
_StateSpecification * mySpecification
Definition: Macho.h:822
void inet::Macho::_StateInstance::setBox ( void *  box)
inline

Referenced by inet::Macho::Machine< fsm::TopState >::Machine(), and inet::Macho::_MachineBase::rattleOn().

774  {
775  assert(!myBox);
776 
777  if (myBoxPlace) {
778  // Free cached memory of previously used box.
779  ::operator delete(myBoxPlace);
780  myBoxPlace = 0;
781  }
782 
783  myBox = box;
784  }
void * myBox
Definition: Macho.h:825
void * box()
Definition: Macho.h:798
void * myBoxPlace
Definition: Macho.h:826
void inet::Macho::_StateInstance::setHistory ( _StateInstance history) const
inline

Referenced by inet::Macho::MachoLink< C, P >::clearHistory(), inet::Macho::_MachineBase::clearHistoryDeep(), and init().

811  {
812  myHistory = history;
813  }
_StateInstance * history() const
Definition: Macho.h:815
_StateInstance * myHistory
Definition: Macho.h:823
void inet::Macho::_StateInstance::setHistorySuper ( _StateInstance deep)
inline
733  {
734  if (myParent)
735  // Let it choose between deep or shallow history.
736  myParent->saveHistory(*this, deep);
737  }
void saveHistory(_StateInstance &shallow, _StateInstance &deep)
Definition: Macho.h:725
_StateInstance * myParent
Definition: Macho.h:824
void inet::Macho::_StateInstance::shutdown ( )
inline
748  {
750  }
_StateSpecification * mySpecification
Definition: Macho.h:822
virtual void _shutdown()
Definition: Macho.cc:96

Member Data Documentation

void* inet::Macho::_StateInstance::myBox
protected

Referenced by exit(), and init().

void* inet::Macho::_StateInstance::myBoxPlace
protected

Referenced by ~_StateInstance().

_StateInstance* inet::Macho::_StateInstance::myHistory
mutableprotected

Referenced by init().

_MachineBase& inet::Macho::_StateInstance::myMachine
protected
_StateInstance* inet::Macho::_StateInstance::myParent
protected

Referenced by entry(), exit(), and init().

_StateSpecification* inet::Macho::_StateInstance::mySpecification
protected

Referenced by entry(), exit(), init(), and ~_StateInstance().


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