3rdParty/boost/1.78.0/libs/statechart/doc/reference.html
|
|
|
ConceptsSchedulerFifoWorkerExceptionTranslatorStateBaseSimpleStateStateEventstate_machine.hppClass template state_machineasynchronous_state_machine.hppClass template asynchronous_state_machineevent_processor.hppClass template event_processorfifo_scheduler.hppClass template fifo_schedulerexception_translator.hppClass template exception_translatornull_exception_translator.hppClass null_exception_translator simple_state.hppEnum history_modeClass template simple_statestate.hppClass template stateshallow_history.hppClass template shallow_historydeep_history.hppClass template deep_history event_base.hppClass event_baseevent.hppClass template event transition.hppClass template transitionin_state_reaction.hppClass template in_state_reactiontermination.hppClass template terminationdeferral.hppClass template deferralcustom_reaction.hppClass template custom_reactionresult.hppClass result
A Scheduler type defines the following:
event_processor<> subtypes and how the lifetime of such objects is managedevent_processor<> subtype objects can share the same queue and scheduler threadevent_processor<> subtype objects and what happens when such an event is processedevent_processor<> subtype objects propagates an exceptionFor a Scheduler type S and an object cpc of type const S::processor_context the following expressions must be well-formed and have the indicated results:
| Expression | Type | Result |
| cpc.my_scheduler() | S & | A reference to the scheduler |
| cpc.my_handle() | S::processor_handle | The handle identifying the event_processor<> subtype object |
To protect against abuse, all members of S::processor_context should be declared private. As a result, event_processor<> must be a friend of S::processor_context.
A FifoWorker type defines the following:
For a FifoWorker type F, an object f of that type, a const object cf of that type, a parameterless function object w of arbitrary type and an unsigned long value n the following expressions/statements must be well-formed and have the indicated results:
| Expression/Statement | Type | Effects/Result |
| F::work_item | boost::function0< void > | |
| F() or F( false ) | F | Constructs a non-blocking (see below) object of the FifoWorker type. In single-threaded builds the second expression is not well-formed |
| F( true ) | F | Constructs a blocking (see below) object of the FifoWorker type. Not well-formed in single-threaded builds |
| f.queue_work_item( w ); | | Constructs and queues an object of type F::work_item, passing w as the only argument |
| f.terminate(); | | Creates and queues an object of type F::work_item that, when later executed in operator()(), leads to a modification of internal state so that terminated() henceforth returns true |
| cf.terminated(); | bool | true if terminate() has been called and the resulting work item has been executed in operator()(). Returns false otherwise
Must only be called from the thread that also calls operator()() |
| f( n ); | unsigned long | Enters a loop that, with each cycle, dequeues and calls operator()() on the oldest work item in the queue.
The loop is left and the number of executed work items returned if one or more of the following conditions are met:
f.terminated() == truen != 0 and the number of work items that have been processed since operator()() was called equals nIf the queue is empty and none of the above conditions are met then the thread calling operator()() is put into a wait state until f.queue_work_item() is called from another thread.
Must only be called from exactly one thread
|
| f(); | unsigned long | Has exactly the same semantics as f( n ); with n == 0 (see above) |
An ExceptionTranslator type defines how C++ exceptions occurring during state machine operation are translated to exception events.
For an ExceptionTranslator object et, a parameterless function object a of arbitrary type returning result and a function object eh of arbitrary type taking a const event_base & parameter and returning result the following expression must be well-formed and have the indicated results:
| Expression | Type | Effects/Result |
| et( a, eh ); | result |
return a();a() propagates an exception, the exception is caughteh, passing a suitable stack-allocated model of the Event concepteh|
A StateBase type is the common base of all states of a given state machine type. state_machine<>::state_base_type is a model of the StateBase concept.
For a StateBase type S and a const object cs of that type the following expressions must be well-formed and have the indicated results:
| Expression | Type | Result |
| cs.outer_state_ptr() | const S * | 0 if cs is an outermost state, a pointer to the direct outer state of cs otherwise |
| cs.dynamic_type() | S::id_type | A value unambiguously identifying the most-derived type of cs. S::id_type values are comparable with operator==() and operator!=(). An unspecified collating order can be established with std::less< S::id_type >. In contrast to typeid( cs ), this function is available even on platforms that do not support C++ RTTI (or have been configured to not support it) |
| cs.custom_dynamic_type_ptr< Type >() | const Type * | A pointer to the custom type identifier or 0. If != 0, Type must match the type of the previously set pointer. This function is only available if BOOST_STATECHART_USE_NATIVE_RTTI is not defined |
A SimpleState type defines one state of a particular state machine.
For a SimpleState type S and a pointer pS pointing to an object of type S allocated with new the following expressions/statements must be well-formed and have the indicated effects/results:
| Expression/Statement | Type | Effects/Result/Notes |
| simple_state< S, C, I, h > * pB = pS; | | simple_state< S, C, I, h > must be an unambiguous public base of S. See simple_state<> documentation for the requirements and semantics of C, I and h |
| new S() | S * | Enters the state S. Certain functions must not be called from S::S(), see simple_state<> documentation for more information |
| pS->exit(); | | Exits the state S (first stage). The definition of an exit member function within models of the SimpleState concept is optional since simple_state<> already defines the following public member: void exit() {}. exit() is not called when a state is exited while an exception is pending, see simple_state<>::terminate() for more information |
| delete pS; | | Exits the state S (second stage) |
| S::reactions | An mpl::list<> that is either empty or contains instantiations of the custom_reaction, in_state_reaction, deferral, termination or transition class templates. If there is only a single reaction then it can also be typedefed directly, without wrapping it into an mpl::list<> | The declaration of a reactions member typedef within models of the SimpleState concept is optional since simple_state<> already defines the following public member: typedef mpl::list<> reactions; |
A State is a refinement of SimpleState (that is, except for the default constructor a State type must also satisfy SimpleState requirements). For a State type S, a pointer pS of type S * pointing to an object of type S allocated with new, and an object mc of type `state< S, C, I, h
``::my_context` the following expressions/statements must be well-formed:
| Expression/Statement | Type | Effects/Result/Notes |
| state< S, C, I, h > * pB = pS; | | state< S, C, I, h > must be an unambiguous public base of S. See state<> documentation for the requirements and semantics of C, I and h |
| new S( mc ) | S * | Enters the state S. No restrictions exist regarding the functions that can be called from S::S() (in contrast to the constructors of models of the SimpleState concept). mc must be forwarded to state< S, C, I, h >::state() |
A Event type defines an event for which state machines can define reactions.
For a Event type E and a pointer pCE of type const E * pointing to an object of type E allocated with new the following expressions/statements must be well-formed and have the indicated effects/results:
| Expression/Statement | Type | Effects/Result/Notes |
| const event< E > * pCB = pCE; | | event< E > must be an unambiguous public base of E |
| new E( *pCE ) | E * | Makes a copy of pE |
state_machineThis is the base class template of all synchronous state machines.
state_machine parameters| Template parameter | Requirements | Semantics | Default |
| MostDerived | The most-derived subtype of this class template | | |
| InitialState | A model of the SimpleState or State concepts. The Context argument passed to the simple_state<> or state<> base of InitialState must be MostDerived. That is, InitialState must be an outermost state of this state machine | The state that is entered when state_machine<> ::initiate() is called | |
| Allocator | A model of the standard Allocator concept | Allocator::rebind<>::other is used to allocate and deallocate all simple_state subtype objects and internal objects of dynamic storage duration | std::allocator< void > |
| ExceptionTranslator | A model of the ExceptionTranslator concept | see ExceptionTranslator concept | null_exception_translator |
state_machine synopsisnamespace boost
{
namespace statechart
{
template<
class MostDerived,
class InitialState,
class Allocator = std::allocator< void >,
class ExceptionTranslator = null_exception_translator >
class state_machine : noncopyable
{
public:
typedef MostDerived outermost_context_type;
void[initiate](#initiate)();
void[terminate](#terminate)();
bool[terminated](#terminated)() const;
void[process\_event](#process_event)( const[event\_base](#Classevent_base)& );
template< class Target >
Target[state\_cast](#state_cast)() const;
template< class Target >
Target[state\_downcast](#state_downcast)() const;
// a model of the[StateBase](#StateBase)concept
typedef_implementation-defined_state_base_type;
// a model of the standard Forward Iterator concept
typedef_implementation-defined_state_iterator;
state_iterator[state\_begin](#state_begin)() const;
state_iterator[state\_end](#state_end)() const;
void[unconsumed\_event](#unconsumed_event)( const[event\_base](#Classevent_base)& ) {}
protected:[state\_machine](#state_machine)();[~state\_machine](#state_machinedtor)();
void[post\_event](#post_event2)(
const intrusive_ptr< const[event\_base](#Classevent_base)> & );
void[post\_event](#post_event3)( const[event\_base](#Classevent_base)& );
const event_base *[triggering\_event](#triggering_event1)() const;
};
}
}
state_machine constructor and destructorstate\_machine();
Effects : Constructs a non-running state machine
~state\_machine();
Effects : Destructs the currently active outermost state and all its direct and indirect inner states. Innermost states are destructed first. Other states are destructed as soon as all their direct and indirect inner states have been destructed. The inner states of each state are destructed according to the number of their orthogonal region. The state in the orthogonal region with the highest number is always destructed first, then the state in the region with the second-highest number and so on
Note : Does not attempt to call any exit member functions
state_machine modifier functionsvoidinitiate();
Effects :
Calls terminate()
Constructs a function object action with a parameter-less operator()() returning result that
enters (constructs) the state specified with the InitialState template parameter
enters the tree formed by the direct and indirect inner initial states of InitialState depth first. The inner states of each state are entered according to the number of their orthogonal region. The state in orthogonal region 0 is always entered first, then the state in region 1 and so on
Constructs a function object exceptionEventHandler with an operator()() returning result and accepting an exception event parameter that processes the passed exception event, with the following differences to the processing of normal events:
exit member functions are calledexceptionEventHandler function object (that is, ExceptionTranslator is not used to translate exceptions thrown while processing an exception event)result object is returned equal to the one returned by simple_state<>::discard_event()action and exceptionEventHandler to ExceptionTranslator::operator()(). If ExceptionTranslator::operator()() throws an exception, the exception is propagated to the caller. If the caller catches the exception, the currently active outermost state and all its direct and indirect inner states are destructed. Innermost states are destructed first. Other states are destructed as soon as all their direct and indirect inner states have been destructed. The inner states of each state are destructed according to the number of their orthogonal region. The state in the orthogonal region with the highest number is always destructed first, then the state in the region with the second-highest number and so on. Continues with step 5 otherwise (the return value is discarded)process_event()). Returns to the caller if there are no more posted eventsThrows : Any exceptions propagated from ExceptionTranslator::operator()(). Exceptions never originate in the library itself but only in code supplied through template parameters:
Allocator::rebind<>::other::allocate()react member functionsexit member functionsvoidterminate();
Effects :
action with a parameter-less operator()() returning result that terminates the currently active outermost state, discards all remaining events and clears all history informationexceptionEventHandler with an operator()() returning result and accepting an exception event parameter that processes the passed exception event, with the following differences to the processing of normal events:exit member functions are calledexceptionEventHandler function object (that is, ExceptionTranslator is not used to translate exceptions thrown while processing an exception event)result object is returned equal to the one returned by simple_state<>::discard_event()action and exceptionEventHandler to ExceptionTranslator::operator()(). If ExceptionTranslator::operator()() throws an exception, the exception is propagated to the caller. If the caller catches the exception, the currently active outermost state and all its direct and indirect inner states are destructed. Innermost states are destructed first. Other states are destructed as soon as all their direct and indirect inner states have been destructed. The inner states of each state are destructed according to the number of their orthogonal region. The state in the orthogonal region with the highest number is always destructed first, then the state in the region with the second-highest number and so on. Otherwise, returns to the callerThrows : Any exceptions propagated from ExceptionTranslator::operator(). Exceptions never originate in the library itself but only in code supplied through template parameters:
Allocator::rebind<>::other::allocate()react member functionsexit member functionsvoidprocess\_event( const[event\_base](#Classevent_base)& );
Effects :
Selects the passed event as the current event (henceforth referred to as currentEvent)
Starts a new reaction search
Selects an arbitrary but in this reaction search not yet visited state from all the currently active innermost states. If no such state exists then continues with step 10
Constructs a function object action with a parameter-less operator()() returning result that does the following:
Searches a reaction suitable for currentEvent, starting with the current innermost state and moving outward until a state defining a reaction for the event is found. Returns simple_state<>::forward_event() if no reaction has been found
Executes the found reaction. If the reaction result is equal to the return value of simple_state<>::forward_event() then resumes the reaction search (step a). Returns the reaction result otherwise
Constructs a function object exceptionEventHandler returning result and accepting an exception event parameter that processes the passed exception event, with the following differences to the processing of normal events:
exit member functions are calledexceptionEventHandler function object (that is, ExceptionTranslator is not used to translate exceptions thrown while processing an exception event)result object is returned equal to the one returned by simple_state<>::discard_event()action and exceptionEventHandler to ExceptionTranslator::operator()(). If ExceptionTranslator::operator()() throws an exception, the exception is propagated to the caller. If the caller catches the exception, the currently active outermost state and all its direct and indirect inner states are destructed. Innermost states are destructed first. Other states are destructed as soon as all their direct and indirect inner states have been destructed. The inner states of each state are destructed according to the number of their orthogonal region. The state in the orthogonal region with the highest number is always destructed first, then the state in the region with the second-highest number and so on. Otherwise continues with step 7ExceptionTranslator::operator()() is equal to the one of simple_state<>::forward_event() then continues with step 3ExceptionTranslator::operator()() is equal to the one of simple_state<>::defer_event() then the return value of currentEvent.intrusive_from_this() is stored in the deferred events queue. Continues with step 11ExceptionTranslator::operator()() is equal to the one of simple_state<>::discard_event() then continues with step 11static_cast< MostDerived * >( this )->unconsumed_event( currentEvent ). If unconsumed_event() throws an exception, the exception is propagated to the caller. Such an exception never leads to the destruction of any states (in contrast to exceptions propagated from ExceptionTranslator::operator()())currentEvent and continues with step 2. Returns to the caller otherwiseThrows : Any exceptions propagated from MostDerived::unconsumed_event() or ExceptionTranslator::operator(). Exceptions never originate in the library itself but only in code supplied through template parameters:
Allocator::rebind<>::other::allocate()react member functionsexit member functionsMostDerived::unconsumed_event()voidpost\_event(
const intrusive_ptr< const[event\_base](#Classevent_base)> & );
Effects : Pushes the passed event into the posted events queue
Throws : Any exceptions propagated from Allocator::allocate()
voidpost\_event( const[event\_base](#Classevent_base)& evt );
Effects : post_event( evt.intrusive_from_this() );
Throws : Any exceptions propagated from Allocator::allocate()
voidunconsumed\_event( const[event\_base](#Classevent_base)& evt );
Effects : None
Note : This function (or, if present, the equally named derived class member function) is called by process_event() whenever a dispatched event did not trigger a reaction, see process_event() effects, point 10 for more information.
state_machine observer functionsboolterminated() const;
Returns : true, if the machine is terminated. Returns false otherwise
Note : Is equivalent to state_begin() == state_end()
template< class Target >
Targetstate\_cast() const;
Returns : Depending on the form of Target either a reference or a pointer to const if at least one of the currently active states can successfully be dynamic_cast to Target. Returns 0 for pointer targets and throws std::bad_cast for reference targets otherwise. Target can take either of the following forms: const Class * or const Class &
Throws : std::bad_cast if Target is a reference type and none of the active states can be dynamic_cast to Target
Note : The search sequence is the same as for process_event()
template< class Target >
Targetstate\_downcast() const;
Requires : For reference targets the compiler must support partial specialization of class templates, otherwise a compile-time error will result. The type denoted by Target must be a model of the SimpleState or State concepts
Returns : Depending on the form of Target either a reference or a pointer to const if Target is equal to the most-derived type of a currently active state. Returns 0 for pointer targets and throws std::bad_cast for reference targets otherwise. Target can take either of the following forms: const Class * or const Class &
Throws : std::bad_cast if Target is a reference type and none of the active states has a most derived type equal to Target
Note : The search sequence is the same as for process_event()
state_iteratorstate\_begin() const;
state_iteratorstate\_end() const;
Return : Iterator objects, the range [state_begin(), state_end()) refers to all currently active innermost states. For an object i of type state_iterator, *i returns a const state_base_type & and i.operator->() returns a const state_base_type *
Note : The position of a given innermost state in the range is arbitrary. It may change with each call to a modifier function. Moreover, all iterators are invalidated whenever a modifier function is called
const event_base *triggering\_event();
Returns : A pointer to the event that triggered the reaction that is currently being executed. Returns 0 if no reaction is being executed or if the current reaction was triggered by either initiate() or terminate()
asynchronous_state_machineThis is the base class template of all asynchronous state machines.
asynchronous_state_machine parameters| Template parameter | Requirements | Semantics | Default |
| MostDerived | The most-derived subtype of this class template | | |
| InitialState | A model of the SimpleState or State concepts. The Context argument passed to the simple_state<> or state<> base of InitialState must be MostDerived. That is, InitialState must be an outermost state of this state machine | The state that is entered when the state machine is initiated through the Scheduler object | |
| Scheduler | A model of the Scheduler concept | see Scheduler concept | fifo_scheduler<> |
| Allocator | A model of the standard Allocator concept | | std::allocator< void > |
| ExceptionTranslator | A model of the ExceptionTranslator concept | see ExceptionTranslator concept | null_exception_translator |
asynchronous_state_machine synopsisnamespace boost
{
namespace statechart
{
template<
class MostDerived,
class InitialState,
class Scheduler = fifo_scheduler<>,
class Allocator = std::allocator< void >,
class ExceptionTranslator = null_exception_translator >
class asynchronous_state_machine :
public state_machine<
MostDerived, InitialState, Allocator, ExceptionTranslator >,
public event_processor< Scheduler >
{
protected:
typedef asynchronous_state_machine my_base;
asynchronous_state_machine(
typename event_processor< Scheduler >::my_context ctx );
~asynchronous_state_machine();
};
}
}
asynchronous_state_machine constructor and destructorasynchronous_state_machine(
typename event_processor< Scheduler >::my_context ctx );
Effects : Constructs a non-running asynchronous state machine
Note : Users cannot create asynchronous_state_machine<> subtype objects directly. This can only be done through an object of the Scheduler class
~asynchronous_state_machine();
Effects : Destructs the state machine
Note : Users cannot destruct asynchronous_state_machine<> subtype objects directly. This can only be done through an object of the Scheduler class
event_processorThis is the base class template of all types that process events. asynchronous_state_machine<> is just one possible event processor implementation.
event_processor parameters| Template parameter | Requirements | Semantics |
| Scheduler | A model of the Scheduler concept | see Scheduler concept |
event_processor synopsisnamespace boost
{
namespace statechart
{
template< class Scheduler >
class event_processor
{
public:
virtual[~event\_processor](#event_processordtor)();
Scheduler &[my\_scheduler](#my_scheduler)() const;
typedef typename Scheduler::processor_handle
processor_handle;
processor_handle[my\_handle](#my_handle)() const;
void[initiate](#event_processor::initiate)();
void[process\_event](#event_processor::process_event)( const event_base & evt );
void[terminate](#event_processor::terminate)();
protected:
typedef const typename Scheduler::processor_context &
my_context;[event\_processor](#event_processor)( my_context ctx );
private:
virtual void initiate_impl() = 0;
virtual void process_event_impl(
const event_base & evt ) = 0;
virtual void terminate_impl() = 0;
};
}
}
event_processor constructor and destructorevent\_processor( my_context ctx );
Effects : Constructs an event processor object and stores copies of the reference returned by myContext.my_scheduler() and the object returned by myContext.my_handle()
Note : Users cannot create event_processor<> subtype objects directly. This can only be done through an object of the Scheduler class
virtual~event\_processor();
Effects : Destructs an event processor object
Note : Users cannot destruct event_processor<> subtype objects directly. This can only be done through an object of the Scheduler class
event_processor modifier functionsvoidinitiate();
Effects : initiate_impl(); Throws : Any exceptions propagated from the implementation of initiate_impl()
voidprocess\_event( const event_base & evt );
Effects : process_event_impl( evt ); Throws : Any exceptions propagated from the implementation of process_event_impl()
voidterminate();
Effects : terminate_impl(); Throws : Any exceptions propagated from the implementation of terminate_impl()
event_processor observer functionsScheduler &my\_scheduler() const;
Returns : The Scheduler reference obtained in the constructor
processor_handlemy\_handle() const;
Returns : The processor_handle object obtained in the constructor
fifo_schedulerThis class template is a model of the Scheduler concept.
fifo_scheduler parameters| Template parameter | Requirements | Semantics | Default |
| FifoWorker | A model of the FifoWorker concept | see FifoWorker concept | fifo_worker<> |
| Allocator | A model of the standard Allocator concept | | std::allocator< void > |
fifo_scheduler synopsisnamespace boost
{
namespace statechart
{
template<
class FifoWorker = fifo_worker<>,
class Allocator = std::allocator< void > >
class fifo_scheduler : noncopyable
{
public:[fifo\_scheduler](#fifo_scheduler::fifo_scheduler)( bool waitOnEmptyQueue = false );
typedef_implementation-defined_processor_handle;
class processor_context : noncopyable
{
processor_context(
fifo_scheduler & scheduler,
const processor_handle & theHandle );
fifo_scheduler & my_scheduler() const;
const processor_handle & my_handle() const;
friend class fifo_scheduler;
friend class event_processor< fifo_scheduler >;
};
template< class Processor >
processor_handle[create\_processor](#create_processor)();
template< class Processor, typename Param1 >
processor_handle[create\_processor](#create_processor1)( Param1 param1 );
// More create_processor overloads
void[destroy\_processor](#destroy_processor)( processor_handle processor );
void[initiate\_processor](#initiate_processor)( processor_handle processor );
void[terminate\_processor](#terminate_processor)( processor_handle processor );
typedef intrusive_ptr< const event_base > event_ptr_type;
void[queue\_event](#queue_event)(
const processor_handle & processor,
const event_ptr_type & pEvent );
typedef typename FifoWorker::work_item work_item;
void[queue\_work\_item](#queue_work_item)( const work_item & item );
void[terminate](#fifo_scheduler::terminate)();
bool[terminated](#fifo_scheduler::terminated)() const;
unsigned long[operator()](#operatorfuncall)(
unsigned long maxEventCount = 0 );
};
}
}
fifo_scheduler constructorfifo\_scheduler( bool waitOnEmptyQueue = false );
Effects : Constructs a fifo_scheduler<> object. In multi-threaded builds, waitOnEmptyQueue is forwarded to the constructor of a data member of type FifoWorker. In single-threaded builds, the FifoWorker data member is default-constructed
Note : In single-threaded builds the fifo_scheduler<> constructor does not accept any parameters and operator()() thus always returns to the caller when the event queue is empty
fifo_scheduler modifier functionstemplate< class Processor >
processor_handlecreate\_processor();
Requires : The Processor type must be a direct or indirect subtype of the event_processor class template
Effects : Creates and passes to FifoWorker::queue_work_item() an object of type FifoWorker::work_item that, when later executed in FifoWorker::operator()(), leads to a call to the constructor of Processor, passing an appropriate processor_context object as the only argument
Returns : A processor_handle object that henceforth identifies the created event processor object
Throws : Any exceptions propagated from FifoWorker::work_item() and FifoWorker::queue_work_item()
Caution : The current implementation of this function makes an (indirect) call to global operator new(). Unless global operator new() is replaced, care must be taken when to call this function in applications with hard real-time requirements
template< class Processor, typename Param1 >
processor_handlecreate\_processor( Param1 param1 );
Requires : The Processor type must be a direct or indirect subtype of the event_processor class template
Effects : Creates and passes to FifoWorker::queue_work_item() an object of type FifoWorker::work_item that, when later executed in FifoWorker::operator()(), leads to a call to the constructor of Processor, passing an appropriate processor_context object and param1 as arguments
Returns : A processor_handle object that henceforth identifies the created event processor object
Throws : Any exceptions propagated from FifoWorker::work_item() and FifoWorker::queue_work_item()
Note : boost::ref() and boost::cref() can be used to pass arguments by reference rather than by copy. fifo_scheduler<> has 5 additional create_processor<> overloads, allowing to pass up to 6 custom arguments to the constructors of event processors
Caution : The current implementation of this and all other overloads make (indirect) calls to global operator new(). Unless global operator new() is replaced, care must be taken when to call these overloads in applications with hard real-time requirements
voiddestroy\_processor( processor_handle processor );
Requires : processor was obtained from a call to one of the create_processor<>() overloads on the same fifo_scheduler<> object
Effects : Creates and passes to FifoWorker::queue_work_item() an object of type FifoWorker::work_item that, when later executed in FifoWorker::operator()(), leads to a call to the destructor of the event processor object associated with processor. The object is silently discarded if the event processor object has been destructed before
Throws : Any exceptions propagated from FifoWorker::work_item() and FifoWorker::queue_work_item()
Caution : The current implementation of this function leads to an (indirect) call to global operator delete() (the call is made when the last processor_handle object associated with the event processor object is destructed). Unless global operator delete() is replaced, care must be taken when to call this function in applications with hard real-time requirements
voidinitiate\_processor( processor_handle processor );
Requires : processor was obtained from a call to one of the create_processor() overloads on the same fifo_scheduler<> object
Effects : Creates and passes to FifoWorker::queue_work_item() an object of type FifoWorker::work_item that, when later executed in FifoWorker::operator()(), leads to a call to initiate() on the event processor object associated with processor. The object is silently discarded if the event processor object has been destructed before
Throws : Any exceptions propagated from FifoWorker::work_item() and FifoWorker::queue_work_item()
voidterminate\_processor( processor_handle processor );
Requires : processor was obtained from a call to one of the create_processor<>() overloads on the same fifo_scheduler<> object
Effects : Creates and passes to FifoWorker::queue_work_item() an object of type FifoWorker::work_item that, when later executed in FifoWorker::operator()(), leads to a call to terminate() on the event processor object associated with processor. The object is silently discarded if the event processor object has been destructed before
Throws : Any exceptions propagated from FifoWorker::work_item() and FifoWorker::queue_work_item()
voidqueue\_event(
const processor_handle & processor,
const event_ptr_type & pEvent );
Requires : pEvent.get() != 0 and processor was obtained from a call to one of the create_processor<>() overloads on the same fifo_scheduler<> object
Effects : Creates and passes to FifoWorker::queue_work_item() an object of type FifoWorker::work_item that, when later executed in FifoWorker::operator()(), leads to a call to process_event( *pEvent ) on the event processor object associated with processor. The object is silently discarded if the event processor object has been destructed before
Throws : Any exceptions propagated from FifoWorker::work_item() and FifoWorker::queue_work_item()
voidqueue\_work\_item( const work_item & item );
Effects : FifoWorker::queue_work_item( item );
Throws : Any exceptions propagated from the above call
voidterminate();
Effects : FifoWorker::terminate()
Throws : Any exceptions propagated from the above call
unsigned longoperator()( unsigned long maxEventCount = 0 );
Requires : Must only be called from exactly one thread
Effects : FifoWorker::operator()( maxEventCount )
Returns : The return value of the above call
Throws : Any exceptions propagated from the above call
fifo_scheduler observer functionsboolterminated() const;
Requires : Must only be called from the thread that also calls operator()()
Returns : FifoWorker::terminated();
exception_translatorThis class template is a model of the ExceptionTranslator concept.
exception_translator parameters| Template parameter | Requirements | Semantics | Default |
| ExceptionEvent | A model of the Event concept | The type of event that is dispatched when an exception is propagated into the framework | exception_thrown |
exception_translator synopsis & semanticsnamespace boost
{
namespace statechart
{
class exception_thrown : public event< exception_thrown > {};
template< class ExceptionEvent = exception_thrown >
class exception_translator
{
public:
template< class Action, class ExceptionEventHandler >
result operator()(
Action action,
ExceptionEventHandler eventHandler )
{
try
{
return action();
}
catch( ... )
{
return eventHandler( ExceptionEvent() );
}
}
};
}
}
null_exception_translatorThis class is a model of the ExceptionTranslator concept.
null_exception_translator synopsis & semanticsnamespace boost
{
namespace statechart
{
class null_exception_translator
{
public:
template< class Action, class ExceptionEventHandler >
result operator()(
Action action, ExceptionEventHandler )
{
return action();
}
};
}
}
history_modeDefines the history type of a state.
namespace boost
{
namespace statechart
{
enum history_mode
{
has_no_history,
has_shallow_history,
has_deep_history,
has_full_history // shallow & deep
};
}
}
simple_stateThis is the base class template for all models of the SimpleState concept. Such models must not call any of the following simple_state<> member functions from their constructors:
void **post\_event** (
const intrusive_ptr< const event_base > & );
void **post\_event** ( const event_base & );
template<
class HistoryContext,_implementation-defined-unsigned-integer-type_ orthogonalPosition >
void **clear\_shallow\_history** ();
template<
class HistoryContext,_implementation-defined-unsigned-integer-type_ orthogonalPosition >
void **clear\_deep\_history** ();
outermost_context_type & **outermost\_context** ();
const outermost_context_type & **outermost\_context** () const;
template< class OtherContext >
OtherContext & **context** ();
template< class OtherContext >
const OtherContext & **context** () const;
template< class Target >
Target **state\_cast** () const;
template< class Target >
Target **state\_downcast** () const;
state_iterator **state\_begin** () const;
state_iterator **state\_end** () const;
const event_base ***triggering\_event** () const;
States that need to call any of these member functions from their constructors must derive from the state class template.
simple_state parameters| Template parameter | Requirements | Semantics | Default |
| MostDerived | The most-derived subtype of this class template | | |
| Context | A most-derived direct or indirect subtype of the state_machine or asynchronous_state_machine class templates or a model of the SimpleState or State concepts or an instantiation of the simple_state<>::orthogonal class template. Must be a complete type | Defines the states' position in the state hierarchy | |
| InnerInitial | An mpl::list<> containing models of the SimpleState or State concepts or instantiations of the shallow_history or deep_history class templates. If there is only a single inner initial state that is not a template instantiation then it can also be passed directly, without wrapping it into an mpl::list<>. The Context argument passed to the simple_state<> or state<> base of each state in the list must correspond to the orthogonal region it belongs to. That is, the first state in the list must pass MostDerived::orthogonal< 0 >, the second MostDerived::orthogonal< 1 > and so forth. MostDerived::orthogonal< 0 > and MostDerived are synonymous | Defines the inner initial state for each orthogonal region. By default, a state does not have inner states | unspecified |
| historyMode | One of the values defined in the history_mode enumeration | Defines whether the state saves shallow, deep or both histories upon exit | has_no_history |
simple_state synopsisnamespace boost
{
namespace statechart
{
template<
class MostDerived,
class Context,
class InnerInitial =_unspecified_,
history_mode historyMode = has_no_history >
class simple_state :_implementation-defined_{
public:
// by default, a state has no reactions
typedef mpl::list<> reactions;
// see template parameters
template<_implementation-defined-unsigned-integer-type_ innerOrthogonalPosition >
struct orthogonal
{
//_implementation-defined_};
typedef typename Context::outermost_context_type
outermost_context_type;
outermost_context_type &[outermost\_context](#outermost_context)();
const outermost_context_type &[outermost\_context](#outermost_contextconst)() const;
template< class OtherContext >
OtherContext &[context](#context)();
template< class OtherContext >
const OtherContext &[context](#contextconst)() const;
template< class Target >
Target[state\_cast](#simple_state::state_cast)() const;
template< class Target >
Target[state\_downcast](#simple_state::state_downcast)() const;
// a model of the StateBase concept
typedef_implementation-defined_state_base_type;
// a model of the standard Forward Iterator concept
typedef_implementation-defined_state_iterator;
state_iterator[state\_begin](#simple_state::state_begin)() const;
state_iterator[state\_end](#simple_state::state_end)() const;
const event_base *[triggering\_event](#triggering_event0)() const;
void[post\_event](#post_event0)(
const intrusive_ptr< const[event\_base](#Classevent_base)> & );
void[post\_event](#post_event1)( const[event\_base](#Classevent_base)& );[result](#Classresult)[discard\_event](#discard_event)();[result](#Classresult)[forward\_event](#forward_event)();[result](#Classresult)[defer\_event](#defer_event)();
template< class DestinationState >[result](#Classresult)[transit](#transit1)();
template<
class DestinationState,
class TransitionContext,
class Event >[result](#Classresult)[transit](#transit2)(
void ( TransitionContext::* )( const Event & ),
const Event & );[result](#Classresult)[terminate](#simple_state::terminate)();
template<
class HistoryContext,_implementation-defined-unsigned-integer-type_ orthogonalPosition >
void[clear\_shallow\_history](#clear_shallow_history)();
template<
class HistoryContext,_implementation-defined-unsigned-integer-type_ orthogonalPosition >
void[clear\_deep\_history](#clear_deep_history)();
static id_type[static\_type](#static_type)();
template< class CustomId >
static const CustomId *[custom\_static\_type\_ptr](#custom_static_type_ptr)();
template< class CustomId >
static void[custom\_static\_type\_ptr](#custom_static_type_ptr1)( const CustomId * );
// see[transit](#transit1)() or[terminate](#simple_state::terminate)() effects
void exit() {}
protected:[simple\_state](#simple_state)();[~simple\_state](#simple_statedtor)();
};
}
}
simple_state constructor and destructorsimple\_state();
Effects : Constructs a state object
~simple\_state();
Effects : If the state has deferral reactions of which at least one has been triggered during the lifetime of the state then the contents of the deferred events queue is moved to the front of the posted events queue.
simple_state modifier functionsvoidpost\_event(
const intrusive_ptr< const[event\_base](#Classevent_base)> & pEvt );
Requires : If called from a constructor of a direct or indirect subtype then the most-derived type must directly or indirectly derive from the state class template . All direct and indirect callers must be exception-neutral
Effects : outermost_context().post_event( pEvt );
Throws : Whatever the above call throws
voidpost\_event( const[event\_base](#Classevent_base)& evt );
Requires : If called from a constructor of a direct or indirect subtype then the most-derived type must directly or indirectly derive from the state class template . All direct and indirect callers must be exception-neutral
Effects : outermost_context().post_event( evt );
Throws : Whatever the above call throws
[result](#Classresult)discard\_event();
Requires : Must only be called from within react member functions, which are called by custom_reaction<> instantiations. All direct and indirect callers must be exception-neutral
Effects : Instructs the state machine to discard the current event and to continue with the processing of the remaining events (see state_machine<>::process_event() for details)
Returns : A result object. The user-supplied react member function must return this object to its caller
[result](#Classresult)forward\_event();
Requires : Must only be called from within react member functions, which are called by custom_reaction<> instantiations. All direct and indirect callers must be exception-neutral
Effects : Instructs the state machine to forward the current event to the next state (see state_machine<>::process_event() for details)
Returns : A result object. The user-supplied react member function must return this object to its caller
[result](#Classresult)defer\_event();
Requires : Must only be called from within react member functions, which are called by custom_reaction<> instantiations. All direct and indirect callers must be exception-neutral
Effects : Instructs the state machine to defer the current event and to continue with the processing of the remaining events (see state_machine<>::process_event() for details)
Returns : A result object. The user-supplied react member function must return this object to its caller
Throws : Any exceptions propagated from Allocator::rebind<>::other::allocate() (the template parameter passed to the base class of outermost_context_type)
template< class DestinationState >[result](#Classresult)transit();
Requires : Must only be called from within react member functions, which are called by custom_reaction<> instantiations. All direct and indirect callers must be exception-neutral
Effects :
Exits all currently active direct and indirect inner states of the innermost common context of this state and DestinationState. Innermost states are exited first. Other states are exited as soon as all their direct and indirect inner states have been exited. The inner states of each state are exited according to the number of their orthogonal region. The state in the orthogonal region with the highest number is always exited first, then the state in the region with the second-highest number and so on.
The process of exiting a state consists of the following steps:
If there is an exception pending that has not yet been handled successfully then only step 5 is executed
Calls the exit member function (see synopsis) of the most-derived state object. If exit() throws then steps 3 and 4 are not executed
If the state has shallow history then shallow history information is saved
If the state is an innermost state then deep history information is saved for all direct and indirect outer states that have deep history
The state object is destructed
Enters (constructs) the state that is both a direct inner state of the innermost common context and either the DestinationState itself or a direct or indirect outer state of DestinationState
Enters (constructs) the tree formed by the direct and indirect inner states of the previously entered state down to the DestinationState and beyond depth first. The inner states of each state are entered according to the number of their orthogonal region. The state in orthogonal region 0 is always entered first, then the state in region 1 and so on
Instructs the state machine to discard the current event and to continue with the processing of the remaining events (see state_machine<>::process_event() for details)
Returns : A result object. The user-supplied react member function must return this object to its caller
Throws : Any exceptions propagated from:
Allocator::rebind<>::other::allocate() (the template parameter passed to the base class of outermost_context_type)exit member functionsCaution : Inevitably destructs this state before returning to the calling react member function, which must therefore not attempt to access anything except stack objects before returning to its caller
template<
class DestinationState,
class TransitionContext,
class Event >[result](#Classresult)transit(
void ( TransitionContext::* )( const Event & ),
const Event & );
Requires : Must only be called from within react member functions, which are called by custom_reaction<> instantiations. All direct and indirect callers must be exception-neutral
Effects :
Exits all currently active direct and indirect inner states of the innermost common context of this state and DestinationState. Innermost states are exited first. Other states are exited as soon as all their direct and indirect inner states have been exited. The inner states of each state are exited according to the number of their orthogonal region. The state in the orthogonal region with the highest number is always exited first, then the state in the region with the second-highest number and so on.
The process of exiting a state consists of the following steps:
If there is an exception pending that has not yet been handled successfully then only step 5 is executed
Calls the exit member function (see synopsis) of the most-derived state object. If exit() throws then steps 3 and 4 are not executed
If the state has shallow history then shallow history information is saved
If the state is an innermost state then deep history information is saved for all direct and indirect outer states that have deep history
The state object is destructed
Executes the passed transition action, forwarding the passed event
Enters (constructs) the state that is both a direct inner state of the innermost common context and either the DestinationState itself or a direct or indirect outer state of DestinationState
Enters (constructs) the tree formed by the direct and indirect inner states of the previously entered state down to the DestinationState and beyond depth first. The inner states of each state are entered according to the number of their orthogonal region. The state in orthogonal region 0 is always entered first, then the state in region 1 and so on
Instructs the state machine to discard the current event and to continue with the processing of the remaining events (see state_machine<>::process_event() for details)
Returns : A result object. The user-supplied react member function must return this object to its caller
Throws : Any exceptions propagated from:
Allocator::rebind<>::other::allocate() (the template parameter passed to the base class of outermost_context_type)exit member functionsCaution : Inevitably destructs this state before returning to the calling react member function, which must therefore not attempt to access anything except stack objects before returning to its caller
[result](#Classresult)terminate();
Requires : Must only be called from within react member functions, which are called by custom_reaction<> instantiations. All direct and indirect callers must be exception-neutral
Effects : Exits this state and all its direct and indirect inner states. Innermost states are exited first. Other states are exited as soon as all their direct and indirect inner states have been exited. The inner states of each state are exited according to the number of their orthogonal region. The state in the orthogonal region with the highest number is always exited first, then the state in the region with the second-highest number and so on.
The process of exiting a state consists of the following steps:
exit member function (see synopsis) of the most-derived state object. If exit() throws then steps 3 and 4 are not executedAlso instructs the state machine to discard the current event and to continue with the processing of the remaining events (see state_machine<>::process_event() for details)
Returns : A result object. The user-supplied react member function must return this object to its caller
Throws : Any exceptions propagated from:
Allocator::rebind<>::other::allocate() (the template parameter passed to the base class of outermost_context_type, used to allocate space to save history)exit member functionsNote : If this state is the only currently active inner state of its direct outer state then the direct outer state is terminated also. The same applies recursively for all indirect outer states
Caution : Inevitably destructs this state before returning to the calling react member function, which must therefore not attempt to access anything except stack objects before returning to its caller
template<
class HistoryContext,_implementation-defined-unsigned-integer-type_ orthogonalPosition >
voidclear\_shallow\_history();
Requires : If called from a constructor of a direct or indirect subtype then the most-derived type must directly or indirectly derive from the state class template. The historyMode argument passed to the simple_state<> or state<> base of HistoryContext must be equal to has_shallow_history or has_full_history
Effects : Clears the shallow history of the orthogonal region specified by orthogonalPosition of the state specified by HistoryContext
Throws : Any exceptions propagated from Allocator::rebind<>::other::allocate() (the template parameter passed to the base class of outermost_context_type)
template<
class HistoryContext,_implementation-defined-unsigned-integer-type_ orthogonalPosition >
voidclear\_deep\_history();
Requires : If called from a constructor of a direct or indirect subtype then the most-derived type must directly or indirectly derive from the state class template. The historyMode argument passed to the simple_state<> or state<> base of HistoryContext must be equal to has_deep_history or has_full_history
Effects : Clears the deep history of the orthogonal region specified by orthogonalPosition of the state specified by HistoryContext
Throws : Any exceptions propagated from Allocator::rebind<>::other::allocate() (the template parameter passed to the base class of outermost_context_type)
simple_state observer functionsoutermost_context_type &outermost\_context();
Requires : If called from a constructor of a direct or indirect subtype then the most-derived type must directly or indirectly derive from the state class template. If called from a destructor of a direct or indirect subtype then the state_machine<> subclass portion must still exist
Returns : A reference to the outermost context, which is always the state machine this state belongs to
const outermost_context_type &outermost\_context() const;
Requires : If called from a constructor of a direct or indirect subtype then the most-derived type must directly or indirectly derive from the state class template. If called from a destructor of a direct or indirect subtype then the state_machine<> subclass portion must still exist
Returns : A reference to the const outermost context, which is always the state machine this state belongs to
template< class OtherContext >
OtherContext &context();
Requires : If called from a constructor of a direct or indirect subtype then the most-derived type must directly or indirectly derive from the state class template. If called from a destructor of a direct or indirect subtype with a state_machine<> subtype as argument then the state_machine<> subclass portion must still exist
Returns : A reference to a direct or indirect context or any public base type of the contexts
template< class OtherContext >
const OtherContext &context() const;
Requires : If called from a constructor of a direct or indirect subtype then the most-derived type must directly or indirectly derive from the state class template. If called from a destructor of a direct or indirect subtype with a state_machine<> subtype as argument then the state_machine<> subclass portion must still exist
Returns : A reference to a const direct or indirect context or any public base type of the contexts
template< class Target >
Targetstate\_cast() const;
Requires : If called from a constructor of a direct or indirect subtype then the most-derived type must directly or indirectly derive from the state class template
Returns : Has exactly the same semantics as state_machine<>::state_cast<>()
Throws : Has exactly the same semantics as state_machine<>::state_cast<>()
Note : The result is unspecified if this function is called when the machine is unstable
template< class Target >
Targetstate\_downcast() const;
Requires : If called from a constructor of a direct or indirect subtype then the most-derived type must directly or indirectly derive from the state class template. Moreover, state_machine<>::state_downcast<>() requirements also apply
Returns : Has exactly the same semantics as state_machine<>::state_downcast<>()
Throws : Has exactly the same semantics as state_machine<>::state_downcast<>()
Note : The result is unspecified if this function is called when the machine is unstable
state_iteratorstate\_begin() const;
state_iteratorstate\_end() const;
Require : If called from a constructor of a direct or indirect subtype then the most-derived type must directly or indirectly derive from the state class template
Return : Have exactly the same semantics as state_machine<>::state_begin() and state_machine<>::state_end()
Note : The result is unspecified if these functions are called when the machine is unstable
const event_base *triggering\_event();
Returns : Has exactly the same semantics as state_machine<>::triggering_event()
simple_state static functionsstatic id_typestatic\_type();
Returns : A value unambiguously identifying the type of MostDerived
Note : id_type values are comparable with operator==() and operator!=(). An unspecified collating order can be established with `std::less< id_type
`
template< class CustomId >
static const CustomId *custom\_static\_type\_ptr();
Requires : If a custom type identifier has been set then CustomId must match the type of the previously set pointer
Returns : The pointer to the custom type identifier for MostDerived or 0
Note : This function is not available if BOOST_STATECHART_USE_NATIVE_RTTI is defined
template< class CustomId >
static voidcustom\_static\_type\_ptr( const CustomId \* );
Effects : Sets the pointer to the custom type identifier for MostDerived
Note : This function is not available if BOOST_STATECHART_USE_NATIVE_RTTI is defined
stateThis is the base class template for all models of the State concept. Such models typically need to call at least one of the following simple_state<> member functions from their constructors:
void **post\_event** (
const intrusive_ptr< const event_base > & );
void **post\_event** ( const event_base & );
template<
class HistoryContext,_implementation-defined-unsigned-integer-type_ orthogonalPosition >
void **clear\_shallow\_history** ();
template<
class HistoryContext,_implementation-defined-unsigned-integer-type_ orthogonalPosition >
void **clear\_deep\_history** ();
outermost_context_type & **outermost\_context** ();
const outermost_context_type & **outermost\_context** () const;
template< class OtherContext >
OtherContext & **context** ();
template< class OtherContext >
const OtherContext & **context** () const;
template< class Target >
Target **state\_cast** () const;
template< class Target >
Target **state\_downcast** () const;
state_iterator **state\_begin** () const;
state_iterator **state\_end** () const;
const event_base ***triggering\_event** () const;
States that do not need to call any of these member functions from their constructors should rather derive from the simple_state class template, what saves the implementation of the forwarding constructor.
state synopsisnamespace boost
{
namespace statechart
{
template<
class MostDerived,
class Context,
class InnerInitial =_unspecified_,
history_mode historyMode = has_no_history >
class state : public simple_state<
MostDerived, Context, InnerInitial, historyMode >
{
protected:
struct my_context
{
//_implementation-defined_};
typedef state my_base;
state( my_context ctx );
~state();
};
}
}
Direct and indirect subtypes of state<> must provide a constructor with the same signature as the state<> constructor, forwarding the context parameter.
shallow_historyThis class template is used to specify a shallow history transition target or a shallow history inner initial state.
shallow_history parameters| Template parameter | Requirements | Semantics |
| DefaultState | A model of the SimpleState or State concepts. The type passed as Context argument to the simple_state<> or state<> base of DefaultState must itself pass has_shallow_history or has_full_history as historyMode argument to its simple_state<> or state<> base | The state that is entered if shallow history is not available |
shallow_history synopsisnamespace boost
{
namespace statechart
{
template< class DefaultState >
class shallow_history
{
//_implementation-defined_};
}
}
deep_historyThis class template is used to specify a deep history transition target or a deep history inner initial state. The current deep history implementation has some limitations.
deep_history parameters| Template parameter | Requirements | Semantics |
| DefaultState | A model of the SimpleState or State concepts. The type passed as Context argument to the simple_state<> or state<> base of DefaultState must itself pass has_deep_history or has_full_history as historyMode argument to its simple_state<> or state<> base | The state that is entered if deep history is not available |
deep_history synopsisnamespace boost
{
namespace statechart
{
template< class DefaultState >
class deep_history
{
//_implementation-defined_};
}
}
event_baseThis is the common base of all events.
event_base synopsisnamespace boost
{
namespace statechart
{
class event_base
{
public:
intrusive_ptr< const event_base >[intrusive\_from\_this](#intrusive_from_this)() const;
typedef_implementation-defined_id_type;
id_type[dynamic\_type](#event_base::dynamic_type)() const;
template< typename CustomId >
const CustomId *[custom\_dynamic\_type\_ptr](#event_base::custom_dynamic_type_ptr)() const;
protected:[event\_base](#event_base)(_unspecified-parameter_ );
virtual[~event\_base](#event_basedtor)();
};
}
}
event_base constructor and destructorevent\_base(_unspecified-parameter_ );
Effects : Constructs the common base portion of an event
virtual~event\_base();
Effects : Destructs the common base portion of an event
event_base observer functionsintrusive_ptr< const event_base >intrusive\_from\_this() const;
Returns : Another `intrusive_ptr< const event_base
referencingthis**if**thisis already referenced by anintrusive_ptr<>. Otherwise, returns anintrusive_ptr< const event_base >` referencing a newly created copy of the most-derived object
id_typedynamic\_type() const;
Returns : A value unambiguously identifying the most-derived type
Note : id_type values are comparable with operator==() and operator!=(). An unspecified collating order can be established with `std::less< id_type
. In contrast totypeid( cs )`, this function is available even on platforms that do not support C++ RTTI (or have been configured to not support it)
template< typename CustomId >
const CustomId *custom\_dynamic\_type\_ptr() const;
Requires : If a custom type identifier has been set then CustomId must match the type of the previously set pointer
Returns : A pointer to the custom type identifier or 0
Note : This function is not available if BOOST_STATECHART_USE_NATIVE_RTTI is defined
eventThis is the base class template of all events.
event parameters| Template parameter | Requirements | Semantics | Default |
| MostDerived | The most-derived subtype of this class template | | |
| Allocator | A model of the standard Allocator concept | Allocator::rebind< MostDerived >::other is used to allocate and deallocate all event subtype objects of dynamic storage duration, see operator new | std::allocator< void > |
event synopsisnamespace boost
{
namespace statechart
{
template< class MostDerived, class Allocator = std::allocator< void > >
class event :_implementation-defined_{
public:
static void *[operator new](#event::operatornew)( std::size_t size );
static void *[operator new](#event::operatornew2)( std::size_t size, void * p );
static void[operator delete](#event::operatordelete)( void * pEvent );
static id_type[static\_type](#event::static_type)();
template< class CustomId >
static const CustomId *[custom\_static\_type\_ptr](#event::custom_static_type_ptr)();
template< class CustomId >
static void[custom\_static\_type\_ptr](#event::custom_static_type_ptr1)( const CustomId * );
protected:[event](#event::event)();
virtual[~event](#eventdtor)();
};
}
}
event constructor and destructorevent();
Effects : Constructs an event
virtual~event();
Effects : Destructs an event
event static functionsstatic void *operator new( std::size_t size );
Effects : `Allocator::rebind< MostDerived
::other().allocate( 1, static_cast< MostDerived * >( 0 ) );`
Returns : The return value of the above call
Throws : Whatever the above call throws
static void *operator new( std::size_t size, void * p );
Effects : None
Returns : p
static voidoperator delete( void * pEvent );
Effects : `Allocator::rebind< MostDerived
::other().deallocate( static_cast< MostDerived * >( pEvent ), 1 );`
static id_typestatic\_type();
Returns : A value unambiguously identifying the type of MostDerived
Note : id_type values are comparable with operator==() and operator!=(). An unspecified collating order can be established with `std::less< id_type
`
template< class CustomId >
static const CustomId *custom\_static\_type\_ptr();
Requires : If a custom type identifier has been set then CustomId must match the type of the previously set pointer
Returns : The pointer to the custom type identifier for MostDerived or 0
Note : This function is not available if BOOST_STATECHART_USE_NATIVE_RTTI is defined
template< class CustomId >
static voidcustom\_static\_type\_ptr( const CustomId \* );
Effects : Sets the pointer to the custom type identifier for MostDerived
Note : This function is not available if BOOST_STATECHART_USE_NATIVE_RTTI is defined
transitionThis class template is used to specify a transition reaction. Instantiations of this template can appear in the reactions member typedef in models of the SimpleState and State concepts.
transition parameters| Template parameter | Requirements | Semantics | Default |
| Event | A model of the Event concept or the class event_base | The event triggering the transition. If event_base is specified, the transition is triggered by all models of the Event concept | |
| Destination | A model of the SimpleState or State concepts, any of their public base types or an instantiation of the shallow_history or deep_history class templates. The source state (the state for which this transition is defined) and Destination must have a common direct or indirect context | The destination state to make a transition to | |
| TransitionContext | A common context of the source and Destination state | The state of which the transition action is a member | unspecified |
| pTransitionAction | A pointer to a member function of TransitionContext. The member function must accept a const Event & parameter and return void | The transition action that is executed during the transition. By default no transition action is executed | unspecified |
transition synopsisnamespace boost
{
namespace statechart
{
template<
class Event,
class Destination,
class TransitionContext =_unspecified_,
void ( TransitionContext::*pTransitionAction )(
const Event & ) =_unspecified_>
class transition
{
//_implementation-defined_};
}
}
transition semanticsWhen executed, one of the following calls to a member function of the state for which the reaction was defined is made:
transit< Destination >(), if no transition action was specifiedtransit< Destination >( pTransitionAction, currentEvent ), if a transition action was specifiedin_state_reactionThis class template is used to specify an in-state reaction. Instantiations of this template can appear in the reactions member typedef in models of the SimpleState and State concepts.
in_state_reaction parameters| Template parameter | Requirements | Semantics | Default |
| Event | A model of the Event concept or the class event_base | The event triggering the in-state reaction. If event_base is specified, the in-state reaction is triggered by all models of the Event concept | |
| ReactionContext | Either the state defining the in-state reaction itself, one of its direct or indirect contexts or any of their public base types | The state of which the action is a member | unspecified |
| pAction | A pointer to a member function of ReactionContext. The member function must accept a const Event & parameter and return void | The action that is executed during the in-state reaction | unspecified |
in_state_reaction synopsisnamespace boost
{
namespace statechart
{
template<
class Event,
class ReactionContext =_unspecified_,
void ( ReactionContext::*pAction )(
const Event & ) =_unspecified_>
class in_state_reaction
{
//_implementation-defined_};
}
}
in_state_reaction semanticsWhen executed then the following happens:
pAction is called, passing the triggering event as the only argumentdiscard_event member function of the state for which the reaction was definedterminationThis class template is used to specify a termination reaction. Instantiations of this template can appear in the reactions member typedef in models of the SimpleState and State concepts.
termination parameters| Template parameter | Requirements | Semantics |
| Event | A model of the Event concept or the class event_base | The event triggering the termination. If event_base is specified, the termination is triggered by all models of the Event concept |
termination synopsisnamespace boost
{
namespace statechart
{
template< class Event >
class termination
{
//_implementation-defined_};
}
}
termination semanticsWhen executed, a call is made to the terminate member function of the state for which the reaction was defined.
deferralThis class template is used to specify a deferral reaction. Instantiations of this template can appear in the reactions member typedef in models of the SimpleState and State concepts.
deferral parameters| Template parameter | Requirements | Semantics |
| Event | A model of the Event concept or the class event_base | The event triggering the deferral. If event_base is specified, the deferral is triggered by all models of the Event concept |
deferral synopsisnamespace boost
{
namespace statechart
{
template< class Event >
class deferral
{
//_implementation-defined_};
}
}
deferral semanticsWhen executed, a call is made to the defer_event member function of the state for which the reaction was defined.
custom_reactionThis class template is used to specify a custom reaction. Instantiations of this template can appear in the reactions member typedef in models of the SimpleState and State concepts.
custom_reaction parameters| Template parameter | Requirements | Semantics |
| Event | A model of the Event concept or the class event_base | The event triggering the custom reaction. If event_base is specified, the custom reaction is triggered by all models of the Event concept |
custom_reaction synopsisnamespace boost
{
namespace statechart
{
template< class Event >
class custom_reaction
{
//_implementation-defined_};
}
}
custom_reaction semanticsWhen executed, a call is made to the user-supplied react member function of the state for which the reaction was defined. The react member function must have the following signature:
[result](#Classresult)react( const Event & );
and must call exactly one of the following reaction functions and return the obtained result object:
[result](#Classresult)[discard\_event](#discard_event)();[result](#Classresult)[forward\_event](#forward_event)();[result](#Classresult)[defer\_event](#defer_event)();
template< class DestinationState >[result](#Classresult)[transit](#transit1)();
template<
class DestinationState,
class TransitionContext,
class Event >[result](#Classresult)[transit](#transit2)(
void ( TransitionContext::* )( const Event & ),
const Event & );[result](#Classresult)[terminate](#simple_state::terminate)();
resultDefines the nature of the reaction taken in a user-supplied react member function (called when a custom_reaction is executed). Objects of this type are always obtained by calling one of the reaction functions and must be returned from the react member function immediately.
namespace boost
{
namespace statechart
{
class result
{
public:[result](#result0)( const result & other );[~result](#resultdtor)();
private:
// Result objects are not assignable
result & operator=( const result & other );
};
}
}
result constructor and destructorresult( const result & other );
Requires : other is not consumed
Effects : Copy-constructs a new result object and marks other as consumed. That is, result has destructive copy semantics
~result();
Requires : this is marked as consumed
Effects : Destructs the result object
Revised 06 November, 2010
Copyright © 2003-2010 Andreas Huber Dönni
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)