37 template <
class StateType>
73 unsigned int getId()
const;
109 template <
typename T>
122 template <
typename T>
123 typename std::enable_if_t<!(std::is_base_of_v<VariantDataClass, T> ||
124 std::is_base_of_v<VariantContainerBase, T>),
139 template <
class derivedState>
157 addRemoteState(std::string stateName, std::string proxyName, std::string instanceName =
"");
181 StateIceBasePtr sourceState,
182 StateIceBasePtr destinationState,
183 ParameterMappingIceBasePtr mappingToNextStatesInput =
nullptr,
184 ParameterMappingIceBasePtr mappingToParentStatesLocal =
nullptr,
185 ParameterMappingIceBasePtr mappingToParentStatesOutput =
nullptr);
196 template <
class EventType>
199 StateIceBasePtr destinationState,
200 ParameterMappingIceBasePtr mappingToNextStatesInput =
nullptr,
201 ParameterMappingIceBasePtr mappingToParentStatesLocal =
nullptr,
202 ParameterMappingIceBasePtr mappingToParentStatesOutput =
nullptr);
209 template <
class EventType>
211 StateIceBasePtr destinationState,
212 ParameterMappingIceBasePtr mappingToNextStatesInput =
nullptr,
213 ParameterMappingIceBasePtr mappingToParentStatesLocal =
nullptr,
214 ParameterMappingIceBasePtr mappingToParentStatesOutput =
nullptr);
227 const ContainerType& type,
229 VariantContainerBasePtr defaultValue = VariantContainerBasePtr());
262 const ContainerType& type,
263 VariantContainerBasePtr defaultValue = VariantContainerBasePtr());
281 bool addToOutput(
const std::string& key,
const ContainerType& type,
bool optional);
314 template <
typename T>
316 getInput(
const std::string& key)
const;
329 template <
typename T>
330 typename std::enable_if_t<!(std::is_base_of_v<VariantDataClass, T> ||
331 std::is_base_of_v<VariantContainerBase, T>),
333 getInput(
const std::string& key)
const;
364 template <
typename T>
366 getLocal(
const std::string& key)
const;
377 template <
typename T>
378 typename std::enable_if_t<!(std::is_base_of_v<VariantDataClass, T> ||
379 std::is_base_of_v<VariantContainerBase, T>),
381 getLocal(
const std::string& key)
const;
413 void setInput(std::string
const& key,
const VariantContainerBase& valueList);
438 void setLocal(std::string
const& key,
const VariantContainerBase& valueList);
461 void setOutput(std::string
const& key,
const VariantContainerBase& valueList);
518 template <
class EventType,
class StateType>
520 template <
typename ContextType>
523 template <
class StateType>
528 std::unique_ptr<Impl> simpl;
538 template <
class derivedState>
543 static_assert(std::is_same_v<typename derivedState::Type, derivedState>,
544 "The template parameter 'derivedState' must be derived from "
545 "StateTemplate<derivedState> or the class 'State' itself! It must not "
546 "inherit from a class that inherits from StateTemplate!");
559 template <
class EventType>
562 StateIceBasePtr destinationState,
563 ParameterMappingIceBasePtr mappingToNextStatesInput,
564 ParameterMappingIceBasePtr mappingToParentStatesLocal,
565 ParameterMappingIceBasePtr mappingToParentStatesOutput)
570 mappingToNextStatesInput,
571 mappingToParentStatesLocal,
572 mappingToParentStatesOutput);
575 template <
class EventType>
578 ParameterMappingIceBasePtr mappingToNextStatesInput,
579 ParameterMappingIceBasePtr mappingToParentStatesLocal,
580 ParameterMappingIceBasePtr mappingToParentStatesOutput)
585 assert(destinationState._ptr);
587 t.destinationState = destinationState;
589 if (mappingToNextStatesInput)
591 t.mappingToNextStatesInput = PMPtr::dynamicCast(mappingToNextStatesInput)->clone();
594 if (mappingToParentStatesLocal)
596 t.mappingToParentStatesLocal = PMPtr::dynamicCast(mappingToParentStatesLocal)->clone();
599 if (mappingToParentStatesOutput)
601 t.mappingToParentStatesOutput =
602 PMPtr::dynamicCast(mappingToParentStatesOutput)->clone();
609 "Cannot insert a general transition on event '" + t.evt->eventName +
610 "' from any state to '" + destinationState->stateName +
"' into state '" +
612 "'! There already exists a transition to that state on that event.");
614 transitions.push_back(t);
615 return *transitions.rbegin();
618 template <
typename T>
623 VariantContainerBasePtr varContainer;
626 !SingleVariantPtr::dynamicCast(
639 template <
typename T>
640 typename std::enable_if_t<!(std::is_base_of_v<VariantDataClass, T> ||
641 std::is_base_of_v<VariantContainerBase, T>),
648 return var->get<
T>();
651 template <
typename T>
656 VariantContainerBasePtr varContainer;
659 !SingleVariantPtr::dynamicCast(
672 template <
typename T>
673 typename std::enable_if_t<!(std::is_base_of_v<VariantDataClass, T> ||
674 std::is_base_of_v<VariantContainerBase, T>),
681 return var->get<
T>();
684 template <
typename T>
689 VariantContainerBasePtr varContainer;
692 !SingleVariantPtr::dynamicCast(
705 template <
typename T>
706 typename std::enable_if_t<!(std::is_base_of_v<VariantDataClass, T> ||
707 std::is_base_of_v<VariantContainerBase, T>),
714 return var->get<
T>();
This Statetype is used to create a state instance that represents a state that is located in another ...
void getParameterContainer(const StateParameterMap ¶mMap, const std::string &key, VariantContainerBasePtr &valueContainer) const
void __checkPhase(StatePhase allowedType, const char *functionName) const
Helper function for checking if a function was called in valid position of the statechart.
void __checkPhaseMin(StatePhase allowedType, const char *functionName) const
void getParameter(const StateParameterMap ¶mMap, const std::string &key, VariantPtr &value) const
std::string getStateName() const
getStateName
bool __checkExistenceOfTransition(const TransitionIceBase &transition)
Template class from which all states with additional functionality like an overriden onEnter() functi...
This class provides utility functions for statechart-implementing-users to communicate with other dis...
EventPtr createEvent()
Utility function to create a new Event.
Class that offers the main functionality needed to create a statechart.
friend class StateTemplate
void setStateName(const std::string &newName)
StateParameterMap getInputParameters() override
Returns a new copy of the inputparameters-dictionary, so that the caller cannot modify them (const wo...
StateParameterMap & getLocalParameters()
Getter for the local parameter map.
bool isUnbreakable() const
void setOutput(std::string const &key, const Variant &value)
setOuput() sets an output parameter of this state.
StateBasePtr addState(StateBasePtr pNewState)
bool isOutputParameterSet(const std::string &key) const
StateBasePtr clone() const override
Generates a new copy of this state with the same statename, substates, transitions,...
bool addToInput(const std::string &key, const ContainerType &type, bool optional, VariantContainerBasePtr defaultValue=VariantContainerBasePtr())
Adds a key,type-pair to the input parameters.
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getOutput(const std::string &key) const
getOutput can be used to access a specific input parameter.
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getInput(const std::string &key) const
getInput can be used to access a specific input parameter.
StateBasePtr setInitState(StateBasePtr initState, ParameterMappingPtr initialStateMapping=ParameterMappingPtr())
Sets the initial substate of this state.
bool isLocalParameterSet(const std::string &key) const
friend class RemoteStateWrapper
TransitionIceBase & addTransition(EventPtr event, StateIceBasePtr sourceState, StateIceBasePtr destinationState, ParameterMappingIceBasePtr mappingToNextStatesInput=nullptr, ParameterMappingIceBasePtr mappingToParentStatesLocal=nullptr, ParameterMappingIceBasePtr mappingToParentStatesOutput=nullptr)
void setUseRunFunction(bool useRunFuntion)
setUseRunFunction can be used to configurate whether the thread with the async.
State & operator=(const State &source)
friend class FinalStateBase
VariantContainerBasePtr getLocalContainer(std::string const &key)
std::string getGlobalIdString() const
Getter for the global state identifier string.
StateBasePtr createEmptyCopy() const override
Generates a new copy of this state with the same overidden functions. stateName, substates,...
bool addToOutput(const std::string &key, VariantTypeId type, bool optional)
Adds a key,type-pair to the output parameters.
void setStateClassNameFromTypeName(const std::string &typeName)
virtual RemoteStatePtr addDynamicRemoteState(std::string instanceName)
Function to add a new dynamic remote substate to this state.
void setUnbreakable(bool setUnbreakable=true)
With this function the state can be made unbreakable.
StatePtr operator[](std::string const &stateName)
Function to jump directly into a state. Should only be called for statemachine-debugging.
virtual RemoteStatePtr addRemoteState(std::string stateName, std::string proxyName, std::string instanceName="")
Function to add a new remote substate to this state.
bool init(StatechartContextInterface *context, StatechartManager *manager)
Function to initialize this state. Must be called in the highest level of the hierarchy - and only th...
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getLocal(const std::string &key) const
getLocal can be used to access a specific input parameter.
void cancelSubstates()
Use this function in the onEnter() function, if you want to avoid that the substates (i....
bool addToLocal(const std::string &key, VariantTypeId type, VariantPtr defaultValue=VariantPtr())
Adds a key,type-pair to the local parameters.
TransitionIceBase & addTransitionFromAllStates(StateIceBasePtr destinationState, ParameterMappingIceBasePtr mappingToNextStatesInput=nullptr, ParameterMappingIceBasePtr mappingToParentStatesLocal=nullptr, ParameterMappingIceBasePtr mappingToParentStatesOutput=nullptr)
Function to add a new transition from all substates to destinationState.
bool isInputParameterSet(const std::string &key) const
Checks whether a given input parameter is set or not.
void inheritInputFromSubstate(std::string stateName)
void setLocal(std::string const &key, const Variant &value)
setLocal() sets a local parameter.
void setInput(std::string const &key, const Variant &value)
setInput() sets an input parameter.
unsigned int getId() const
Returns an id to this state, that is guaranteed to be unique in this process.
friend class RemoteStateOfferer
StateBasePtr getInitState() const
Getter for the initial state. The initial state is automatically entered, when this state is entered.
StateParameterMap & getOutputParameters() override
getter function to get the map of output parameters
The Variant class is described here: Variants.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< RemoteState > RemoteStatePtr
IceInternal::Handle< State > StatePtr
IceInternal::Handle< Variant > VariantPtr
IceInternal::Handle< Event > EventPtr
Typedef of EventPtr as IceInternal::Handle<Event> for convenience.
IceInternal::Handle< StateBase > StateBasePtr
IceInternal::Handle< ParameterMapping > ParameterMappingPtr