44 #ifndef SMCLIB__STATEMAP_H_ 45 #define SMCLIB__STATEMAP_H_ 47 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) 49 #if defined(SMC_NO_EXCEPTIONS) 51 #endif // SMC_NO_EXCEPTIONS 55 #if defined(SMC_NO_EXCEPTIONS) 57 #endif // SMC_NO_EXCEPTIONS 60 #if defined(SMC_NO_EXCEPTIONS) 62 #endif // SMC_NO_EXCEPTIONS 65 #if !defined(SMC_NO_EXCEPTIONS) 74 #define MAX_NAME_LEN 100 100 #ifndef SMC_NO_EXCEPTIONS 103 public std::runtime_error
116 : std::runtime_error(reason)
172 :
SmcException(
"transition invoked while in transition")
208 const char *transition)
231 if (_transition != NULL)
233 delete[] _transition;
251 if (_transition != NULL)
253 delete[] _transition;
273 return (_transition);
321 _minIndex(ex._minIndex),
322 _maxIndex(ex._maxIndex)
374 #endif // !SMC_NO_EXCEPTIONS 397 State(
const char *name,
int stateId)
502 if (_transition != NULL)
504 delete[] _transition;
509 while (_state_stack != NULL)
511 state = _state_stack;
512 _state_stack = _state_stack->
_next;
533 virtual void enterStartState() = 0;
538 return(
this == &fsm);
555 #ifdef SMC_USES_IOSTREAMS 557 std::ostream& getDebugStream()
559 return (*_debug_stream);
563 void setDebugStream(std::ostream& debug_stream)
565 _debug_stream = &debug_stream;
568 #endif // SMC_USES_IOSTREAMS 574 return(_state == NULL ?
true :
false);
581 return (_transition);
588 if (_transition != NULL)
590 delete[] _transition;
602 _previous_state = _state;
610 return (_previous_state);
616 _state =
const_cast<State *
>(&state);
618 if (_debug_flag ==
true)
620 #ifdef SMC_USES_IOSTREAMS 621 *_debug_stream <<
"ENTER STATE : " 625 TRACE(
"ENTER STATE : %s\n\r",
627 #endif // SMC_USES_IOSTREAMS 635 return (_state_stack == NULL);
644 for (state_ptr = _state_stack, retval = 0;
646 state_ptr = state_ptr->
getNext(), ++retval)
662 new_entry =
new StateEntry(_state, _state_stack);
663 _state_stack = new_entry;
666 _state =
const_cast<State *
>(&state);
668 if (_debug_flag ==
true)
670 #ifdef SMC_USES_IOSTREAMS 671 *_debug_stream <<
"PUSH TO STATE : " 675 TRACE(
"PUSH TO STATE : %s\n\r",
677 #endif // SMC_USES_IOSTREAMS 688 #ifdef SMC_NO_EXCEPTIONS 689 assert(_state_stack != NULL);
691 if (_state_stack == NULL)
695 #endif // SMC_NO_EXCEPTIONS 697 _state = _state_stack->getState();
698 entry = _state_stack;
699 _state_stack = _state_stack->
getNext();
702 if (_debug_flag ==
true)
704 #ifdef SMC_USES_IOSTREAMS 705 *_debug_stream <<
"POP TO STATE : " 709 TRACE(
"POP TO STATE : %s\n\r",
711 #endif // SMC_USES_IOSTREAMS 721 for (state_ptr = _state_stack;
723 state_ptr = next_ptr)
725 next_ptr = state_ptr->
getNext();
735 : _state(const_cast<
State *>(&state)),
736 _previous_state(NULL),
739 #ifdef SMC_USES_IOSTREAMS
741 _debug_stream(&std::cerr)
782 #ifdef SMC_USES_IOSTREAMS 786 std::ostream *_debug_stream;
787 #endif // SMC_USES_IOSTREAMS 855 #endif // SMCLIB__STATEMAP_H_ const IndexOutOfBoundsException & operator=(const IndexOutOfBoundsException &ex)
IndexOutOfBoundsException(const IndexOutOfBoundsException &ex)
virtual ~TransitionUndefinedException()
virtual ~PopOnEmptyStateStackException()
const char * getTransition() const
TransitionUndefinedException(const TransitionUndefinedException &ex)
SmcException(const std::string &reason)
virtual ~StateUndefinedException()
TransitionUndefinedException()
FSMContext(const State &state)
int getStateStackDepth() const
TransitionUndefinedException(const char *state, const char *transition)
void pushState(const State &state)
int same(const FSMContext &fsm) const
State * getPreviousState()
bool isStateStackEmpty() const
bool isInTransition() const
void setState(const State &state)
const char * getState() const
IndexOutOfBoundsException()
StateUndefinedException()
char * copyString(const char *s)
FSMContext(const FSMContext &)
StateEntry * _state_stack
State(const char *name, int stateId)
IndexOutOfBoundsException(const int index, const int minIndex, const int maxIndex)
virtual ~IndexOutOfBoundsException()
FSMContext & operator=(const FSMContext &fsm)
PopOnEmptyStateStackException()
const char * getName() const
void setDebugFlag(bool flag)
StateEntry(State *state, StateEntry *next)
const TransitionUndefinedException & operator=(const TransitionUndefinedException &ex)
void setTransition(const char *transition)