1 #ifndef _ots_FiniteStateMachine_h
2 #define _ots_FiniteStateMachine_h
4 #include <toolbox/fsm/FiniteStateMachine.h>
5 #include <xoap/MessageReference.h>
15 using toolbox::fsm::FiniteStateMachine::addStateTransition;
17 template<
class OBJECT>
18 void addStateTransition(toolbox::fsm::State from,
19 toolbox::fsm::State to,
20 const std::string& input,
21 const std::string& transitionName,
23 void (OBJECT::*func)(toolbox::Event::Reference))
26 stateTransitionNameTable_[from][input] = transitionName;
27 toolbox::fsm::FiniteStateMachine::addStateTransition(from, to, input, obj, func);
30 template<
class OBJECT>
31 void addStateTransition(toolbox::fsm::State from,
32 toolbox::fsm::State to,
33 const std::string& input,
34 const std::string& transitionName,
35 const std::string& transitionParameter,
37 void (OBJECT::*func)(toolbox::Event::Reference))
40 stateTransitionParameterTable_[from][input] = transitionParameter;
41 addStateTransition(from, to, input, transitionName, obj, func);
44 toolbox::fsm::State getProvenanceState(
void);
45 toolbox::fsm::State getTransitionFinalState(
const std::string& transition);
47 std::string getProvenanceStateName(
void);
48 std::string getCurrentStateName(
void);
49 time_t getTimeInState(
void);
50 std::string getCurrentTransitionName(
const std::string& transition);
51 std::string getTransitionName(
const toolbox::fsm::State from,
const std::string& transition);
52 std::string getTransitionParameter(
const toolbox::fsm::State from,
const std::string& transition);
53 std::string getTransitionFinalStateName(
const std::string& transition);
54 const std::string& getErrorMessage()
const;
55 const std::string& getStateMachineName(
void)
const {
return stateMachineName_; }
56 void setStateMachineName(
const std::string& name) { stateMachineName_ = name; }
58 const xoap::MessageReference& getCurrentMessage(
void);
60 bool execTransition(
const std::string& transition);
61 bool execTransition(
const std::string& transition,
const xoap::MessageReference& message);
62 bool isInTransition(
void);
63 void setInitialState(toolbox::fsm::State state);
64 void setErrorMessage(
const std::string& errMessage,
bool append =
true);
67 time_t stateEntranceTime_;
78 volatile bool inTransition_;
79 toolbox::fsm::State provenanceState_;
80 std::map<toolbox::fsm::State, std::map<std::string, std::string, std::less<std::string> > > stateTransitionNameTable_;
81 std::map<toolbox::fsm::State, std::map<std::string, std::string, std::less<std::string> > > stateTransitionParameterTable_;
83 xoap::MessageReference theMessage_;
84 std::string theErrorMessage_;
85 std::string stateMachineName_;