Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
StateFlow.hxx File Reference
#include <unistd.h>
#include <type_traits>
#include <functional>
#include <sys/stat.h>
#include "executor/Service.hxx"
#include "executor/Timer.hxx"
#include "utils/Buffer.hxx"
#include "utils/Queue.hxx"
#include "utils/LinkedObject.hxx"

Go to the source code of this file.

Classes

class  StateFlowBase
 Base class for state machines. More...
 
class  StateFlowBase::Action
 Return type for a state flow callback. More...
 
class  StateFlowBase::StateFlowTimer
 Use this timer class to deliver the timeout notification to a stateflow. More...
 
struct  StateFlowBase::StateFlowSelectHelper
 Use this class to read from an fd using select() in a state flow. More...
 
struct  StateFlowBase::StateFlowTimedSelectHelper
 Use this class to read from an fd with select and timeout. More...
 
class  StateFlowWithQueue
 A state flow that has an incoming message queue, pends on that queue, and runs a flow for every message that comes in from that queue. More...
 
class  FlowInterface< MessageType >
 Abstract class for message recipients. More...
 
class  FlowInterface< MessageType >::GenericHandler
 
class  UntypedStateFlow< QueueType >
 State flow base class with queue but generic message type. More...
 
class  TypedStateFlow< MessageType, Base >
 Helper class in the StateFlow hierarchy. More...
 
class  StateFlow< MessageType, QueueType >
 State flow with a given typed input queue. More...
 

Macros

#define STATE(_fn)
 Turns a function name into an argument to be supplied to functions expecting a state.
 
#define STATE_FLOW_STATE(_state)   Action _state()
 Declare a state callback in a StateFlow.
 
#define STATE_FLOW_START(_name, _message, _priorities)
 Begin the definition of a StateFlow.
 
#define STATE_FLOW_START_WITH_TIMER(_name, _priorities)
 Begin the definition of a StateFlow that includes timeouts.
 
#define STATE_FLOW_END()   }
 End the definition of a StateFlow.
 

Detailed Description

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Defines a type of state machine flow used within class Service.

Author
Stuart W Baker
Date
25 December 2013

Definition in file StateFlow.hxx.

Macro Definition Documentation

◆ STATE

#define STATE (   _fn)
Value:
&std::remove_reference<decltype(*this)>::type::_fn)
Action(StateFlowBase::* Callback)()
State Flow callback prototype.

Turns a function name into an argument to be supplied to functions expecting a state.

Usage: Action foo() { ... return wait_and_call(STATE(next_state)); } Action next_state() { ... }

This macro exists to avoid writing a lot of boilerplate to correctly with c++ syntax reference state functions.

Parameters
_fnis the name of a state function on the current class.

Definition at line 61 of file StateFlow.hxx.

◆ STATE_FLOW_END

#define STATE_FLOW_END ( )    }

End the definition of a StateFlow.

Definition at line 145 of file StateFlow.hxx.

◆ STATE_FLOW_START

#define STATE_FLOW_START (   _name,
  _message,
  _priorities 
)
Value:
class _name : public StateFlow<_message, _priorities> \
{ \
public: \
_name(Service *service) : StateFlow<_priorities, _priorities>(service) \
{ \
} \
\
private: \
STATE_FLOW_STATE(entry); \
\
_name(); \
\
DISALLOW_COPY_AND_ASSIGN(_name)
Collection of related state machines that pend on incoming messages.
State flow with a given typed input queue.

Begin the definition of a StateFlow.

Parameters
_namethe class name of the StateFlow derived object
_messageis the type of message that this stateflow can receive.
_prioritiesnumber of input queue priorities

Definition at line 75 of file StateFlow.hxx.

◆ STATE_FLOW_START_WITH_TIMER

#define STATE_FLOW_START_WITH_TIMER (   _name,
  _priorities 
)

Begin the definition of a StateFlow that includes timeouts.

Parameters
_namethe class name of the StateFlow derived object
_prioritiesnumber of input queue priorities

Definition at line 94 of file StateFlow.hxx.

◆ STATE_FLOW_STATE

#define STATE_FLOW_STATE (   _state)    Action _state()

Declare a state callback in a StateFlow.

Parameters
_statethe method name of the StateFlow state callback

Definition at line 68 of file StateFlow.hxx.