SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
sm::Event Class Reference

Event class used in the state machine. More...

#include <Event.h>

Public Types

enum  { EVENT_IGNORED = 0xFE }
 

Public Member Functions

 Event (std::string name, std::string senderInfo)
 
virtual ~Event ()
 
void enableTransition (unsigned int from, unsigned int to)
 
unsigned int getNewState (unsigned int currentState)
 Check if there is a transition to a new state. The current state is used to lookup the new state. More...
 
EventDatagetEventData ()
 Get event data that was possibly send with this event. If the function returns nullptr, it contains no data. More...
 
const char * name () const
 
const char * senderInfo () const
 

Protected Attributes

EventData_eventData = nullptr
 

Private Attributes

std::map< unsigned int, unsigned int > _transitions
 
std::string _name
 
std::string _senderInfo
 

Detailed Description

Event class used in the state machine.

Definition at line 31 of file Event.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
EVENT_IGNORED 

Definition at line 34 of file Event.h.

35  {
36  EVENT_IGNORED = 0xFE,
37  };
@ EVENT_IGNORED
Definition: Event.h:36

Constructor & Destructor Documentation

◆ Event()

sm::Event::Event ( std::string  name,
std::string  senderInfo 
)
inline

Definition at line 39 of file Event.h.

40  : _name(name),
42  {
43  }
std::string _senderInfo
Definition: Event.h:87
const char * name() const
Definition: Event.h:77
const char * senderInfo() const
Definition: Event.h:78
std::string _name
Definition: Event.h:86

◆ ~Event()

virtual sm::Event::~Event ( )
inlinevirtual

Definition at line 45 of file Event.h.

45 {};

Member Function Documentation

◆ enableTransition()

void sm::Event::enableTransition ( unsigned int  from,
unsigned int  to 
)
inline

Definition at line 48 of file Event.h.

49  {
50  _transitions[from] = to;
51  }
std::map< unsigned int, unsigned int > _transitions
Definition: Event.h:84

◆ getEventData()

EventData* sm::Event::getEventData ( )
inline

Get event data that was possibly send with this event. If the function returns nullptr, it contains no data.

Returns
EventData*

Definition at line 72 of file Event.h.

73  {
74  return _eventData;
75  }
EventData * _eventData
Definition: Event.h:81

◆ getNewState()

unsigned int sm::Event::getNewState ( unsigned int  currentState)
inline

Check if there is a transition to a new state. The current state is used to lookup the new state.

Definition at line 54 of file Event.h.

55  {
56  auto it = _transitions.find(currentState);
57  if (it != _transitions.end())
58  {
59  return it->second;
60  }
61  else
62  {
63  return EVENT_IGNORED;
64  }
65  }

◆ name()

const char* sm::Event::name ( ) const
inline

Definition at line 77 of file Event.h.

77 { return _name.c_str(); }

◆ senderInfo()

const char* sm::Event::senderInfo ( ) const
inline

Definition at line 78 of file Event.h.

78 { return _senderInfo.c_str(); }

Member Data Documentation

◆ _eventData

EventData* sm::Event::_eventData = nullptr
protected

Definition at line 81 of file Event.h.

◆ _name

std::string sm::Event::_name
private

Definition at line 86 of file Event.h.

◆ _senderInfo

std::string sm::Event::_senderInfo
private

Definition at line 87 of file Event.h.

◆ _transitions

std::map<unsigned int, unsigned int> sm::Event::_transitions
private

Definition at line 84 of file Event.h.


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