appkit  1.5.1
RoadNarrows Robotics Application Kit
rnr::StateEvent Class Reference

Public Member Functions

 StateEvent (int nEventId, const std::string &strEventName="", const std::string &strActionName="")
 Initialization constructor. More...
 
virtual bool evalGuardExpr (State *pState, int nPrevStateId, int nEventId)
 Evaluate event guard condition. More...
 
virtual int execAction (State *pState, int nPrevStateId, int nEventId)
 Execute action associated with the event. More...
 
int getEventId () const
 
std::string getEventName () const
 
std::string getActionName () const
 

Protected Attributes

int m_nEventId
 
std::string m_strEventName
 
std::string m_strActionName
 

Detailed Description

Definition at line 82 of file State.h.

Constructor & Destructor Documentation

StateEvent::StateEvent ( int  nEventId,
const std::string &  strEventName = "",
const std::string &  strActionName = "" 
)

Initialization constructor.

Parameters
nEventIdEvent id.
nEventNameEvent name.
nActionNameAction name.

Definition at line 76 of file State.cxx.

79 {
80  m_nEventId = nEventId;
81 
82  if( strEventName.empty() )
83  {
84  stringstream ss;
85 
86  ss << "e" << m_nEventId;
87  ss >> m_strEventName;
88  }
89  else
90  {
91  m_strEventName = strEventName;
92  }
93 
94  if( strActionName.empty() )
95  {
96  stringstream ss;
97 
98  ss << "action_" << m_strEventName;
99  ss >> m_strActionName;
100  }
101  else
102  {
103  m_strActionName = strActionName;
104  }
105 }

Member Function Documentation

virtual bool rnr::StateEvent::evalGuardExpr ( State pState,
int  nPrevStateId,
int  nEventId 
)
inlinevirtual

Evaluate event guard condition.

Parameters
pStateAssociated state.
nPrevStateIdPrevious state id.
nEventIdReceived event id.
Returns
Returns true if event is accepted, otherwise returns false.

Definition at line 109 of file State.h.

References execAction().

Referenced by rnr::State::dispatchEvent().

112  {
113  return true;
114  }
int StateEvent::execAction ( State pState,
int  nPrevStateId,
int  nEventId 
)
virtual

Execute action associated with the event.

Parameters
pStateAssociated state.
nPrevStateIdPrevious state id.
nEventIdReceived event id.
Returns
Returns next state.

Definition at line 107 of file State.cxx.

References rnr::State::m_nStateId.

Referenced by rnr::State::dispatchEvent(), and evalGuardExpr().

110 {
111  return pState->m_nStateId;
112 }
int m_nStateId
state id
Definition: State.h:389

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