Hedgehog  0.0.0
A library to generate hybrid pipeline workflow systems
hh::StateManager< StateOutput, StateInputs > Class Template Reference

Hedgehog graph's node, used to manage an AbstractState. More...

#include "state_manager.h"

Inheritance diagram for hh::StateManager< StateOutput, StateInputs >:
Inheritance graph
Collaboration diagram for hh::StateManager< StateOutput, StateInputs >:
Collaboration graph

Public Member Functions

 StateManager ()=delete
 Deleted default constructor.
 
template<class StateType , class IsCompatibleState = typename std::enable_if_t< std::is_base_of_v<AbstractState<StateOutput, StateInputs...>, StateType> >>
 StateManager (std::shared_ptr< StateType > const state)
 Constructor for a StateManager with state as mandatory parameter. More...
 
template<class StateType , class IsCompatibleState = typename std::enable_if_t< std::is_base_of_v<AbstractState<StateOutput, StateInputs...>, StateType> >>
 StateManager (std::shared_ptr< StateType > const state, bool automaticStart)
 Constructor for an StateManager with state and automatic start as mandatory parameter. More...
 
template<class StateType , class IsCompatibleState = typename std::enable_if_t< std::is_base_of_v<AbstractState<StateOutput, StateInputs...>, StateType> >>
 StateManager (std::string_view const name, std::shared_ptr< StateType > const state, bool automaticStart=false)
 Constructor for a StateManager with name and state as mandatory parameter, and automatic start as optional parameter. More...
 
std::shared_ptr< AbstractTask< StateOutput, StateInputs... > > copy () override
 Default override of the copy method, copy the name, the state and the automatic start. More...
 
- Public Member Functions inherited from hh::behavior::StateManagerExecuteDefinition< StateInputs, StateOutput, StateInputs... >
 StateManagerExecuteDefinition ()=delete
 Deleted default constructor.
 
 StateManagerExecuteDefinition (std::shared_ptr< AbstractState< StateOutput, StateInputs... >> const &state)
 Constructor for an AbstractStateManager with name, state, and automaticStart as mandatory parameters. More...
 
virtual ~StateManagerExecuteDefinition ()=default
 Default StateManagerExecute destructor.
 
void execute (std::shared_ptr< StateInputs > input) final
 Default execute method definition. More...
 
- Public Member Functions inherited from hh::behavior::BaseStateManager< StateOutput, StateInputs... >
 BaseStateManager ()
 DEfault constructor, set the base property for a state manager.
 
- Public Member Functions inherited from hh::AbstractTask< StateOutput, StateInputs... >
 AbstractTask ()
 AbstractTask default constructor. More...
 
 AbstractTask (std::string_view const &name)
 Create a task with a custom name. More...
 
 AbstractTask (std::string_view const &name, size_t numberThreads)
 Create a task with a custom name and the task's cluster size. More...
 
 AbstractTask (std::string_view const &name, size_t numberThreads, bool automaticStart)
 Create a task with a custom name, the task's cluster size, and the automatic start. More...
 
 AbstractTask (std::string_view const name, size_t numberThreads, core::NodeType nodeType, bool automaticStart)
 Internal constructor needed to create nodes that derive from AbstractTask. More...
 
 AbstractTask (AbstractTask< StateOutput, TaskInputs ... > *rhs)
 Copy constructor. More...
 
virtual ~AbstractTask ()=default
 Default destructor.
 
void addResult (std::shared_ptr< StateOutput > output)
 Add an output data. More...
 
std::string_view name ()
 Task's name accessor. More...
 
size_t numberThreads ()
 Task's number of threads accessor. More...
 
bool automaticStart ()
 Task's automatic start accessor. More...
 
core::NodeType nodeType ()
 Task's node type accessor. More...
 
int deviceId ()
 Task's device ID accessor. More...
 
int graphId ()
 Task's graph ID accessor. More...
 
std::shared_ptr< core::CoreNodecore () final
 Task's core accessor. More...
 
std::shared_ptr< AbstractMemoryManager< StateOutput > > const & memoryManager () const
 Task's memory manager accessor. More...
 
virtual void initialize ()
 Initialize method called before AbstractTask::Execute loop.
 
virtual void shutdown ()
 Shutdown method called after AbstractTask::Execute loop, when AbstractTask::canTerminate evaluates to true.
 
void connectMemoryManager (std::shared_ptr< AbstractMemoryManager< StateOutput >> mm)
 Connect a memory manager to the task. More...
 
std::shared_ptr< StateOutput > getManagedMemory ()
 Memory manager accessor. More...
 
bool canTerminate () override
 Method called to test the task;s termination, by default, the test is: no input nodes connected and, no data waiting to be treated. More...
 
- Public Member Functions inherited from hh::behavior::Node
virtual std::string extraPrintingInformation () const
 Adds node information to print in the dot file. More...
 
- Public Member Functions inherited from hh::behavior::Execute< TaskInputs >
virtual void execute (std::shared_ptr< TaskInputs >)=0
 Virtual declaration of execute function for a data of type Input.
 

Protected Member Functions

std::shared_ptr< AbstractState< StateOutput, StateInputs... > > const & state () const
 Managed state accessor. More...
 

Private Attributes

std::shared_ptr< AbstractState< StateOutput, StateInputs... > > state_ = nullptr
 State to manage.
 

Additional Inherited Members

- Public Types inherited from hh::behavior::MultiReceivers< TaskInputs... >
using inputs_t = std::tuple< Inputs... >
 Tuple with the list of input types.
 
- Public Types inherited from hh::behavior::Sender< StateOutput >
using output_t = StateOutput
 Output Type.
 

Detailed Description

template<class StateOutput, class ... StateInputs>
class hh::StateManager< StateOutput, StateInputs >

Hedgehog graph's node, used to manage an AbstractState.

To locally manage a computation, an AbstractStateManager with an AbstractState is used. An AbstractStateManager is a Hedgehog graphs's node so it can be linked to any other nodes in a graph. The default order of execution is:

  1. The StateManager will acquire a data,
  2. The StateManager will lock the AbstractState (with AbstractState::stateMutex_),
  3. The StateManager will send the data to the possessed AbstractState,
  4. The compatible Execute::execute is called with the data,
  5. During the call of Execute::execute, if the method AbstractState::push is invoked the "result data" is stored in a ready list AbstractState::readyList_,
  6. When the Execute::execute has returned, the waiting list is emptied as output of the AbstractStateManager,
  7. The StateManager will unlock the AbstractState (with AbstractState::stateMutex_).
    Virtual functions
    AbstractTask::copy (only used if the AbstractStateManager is in an ExecutionPipeline)
    AbstractTask::initialize
    AbstractTask::shutdown
    Node::canTerminate
    Node::extraPrintingInformation
    Template Parameters
    StateOutputState output type
    StateInputsState input types

Definition at line 117 of file state_manager.h.

Constructor & Destructor Documentation

◆ StateManager() [1/3]

template<class StateOutput , class ... StateInputs>
template<class StateType , class IsCompatibleState = typename std::enable_if_t< std::is_base_of_v<AbstractState<StateOutput, StateInputs...>, StateType> >>
hh::StateManager< StateOutput, StateInputs >::StateManager ( std::shared_ptr< StateType > const  state)
inlineexplicit

Constructor for a StateManager with state as mandatory parameter.

By default the node name is "StateManager", and there is no automatic start

Template Parameters
StateTypeUser defined state type
IsCompatibleStateType defined if the object given is a compatible State (derived from State with the same StateOutput and StateInputs)
Parameters
stateState to manage

Definition at line 140 of file state_manager.h.

◆ StateManager() [2/3]

template<class StateOutput , class ... StateInputs>
template<class StateType , class IsCompatibleState = typename std::enable_if_t< std::is_base_of_v<AbstractState<StateOutput, StateInputs...>, StateType> >>
hh::StateManager< StateOutput, StateInputs >::StateManager ( std::shared_ptr< StateType > const  state,
bool  automaticStart 
)
inline

Constructor for an StateManager with state and automatic start as mandatory parameter.

The default node name is "StateManager"

Template Parameters
StateTypeUser defined state type
IsCompatibleStateType defined if the object given is a compatible State (derived from State with the same StateOutput and StateInputs)
Parameters
stateState to manage
automaticStartNode automatic start

Definition at line 157 of file state_manager.h.

Here is the call graph for this function:

◆ StateManager() [3/3]

template<class StateOutput , class ... StateInputs>
template<class StateType , class IsCompatibleState = typename std::enable_if_t< std::is_base_of_v<AbstractState<StateOutput, StateInputs...>, StateType> >>
hh::StateManager< StateOutput, StateInputs >::StateManager ( std::string_view const  name,
std::shared_ptr< StateType > const  state,
bool  automaticStart = false 
)
inline

Constructor for a StateManager with name and state as mandatory parameter, and automatic start as optional parameter.

Template Parameters
StateTypeUser defined state type
IsCompatibleStateType defined if the object given is a compatible State (derived from State with the same StateOutput and StateInputs)
Parameters
nameNode name
stateState to manage
automaticStartNode automatic start

Definition at line 177 of file state_manager.h.

Here is the call graph for this function:

Member Function Documentation

◆ copy()

template<class StateOutput , class ... StateInputs>
std::shared_ptr<AbstractTask<StateOutput, StateInputs...> > hh::StateManager< StateOutput, StateInputs >::copy ( )
inlineoverridevirtual

Default override of the copy method, copy the name, the state and the automatic start.

Returns
A copy of the current StateManager with the same name, state and with the automatic start.

Reimplemented from hh::AbstractTask< StateOutput, StateInputs... >.

Definition at line 187 of file state_manager.h.

Here is the call graph for this function:

◆ state()

template<class StateOutput , class ... StateInputs>
std::shared_ptr<AbstractState<StateOutput, StateInputs...> > const& hh::StateManager< StateOutput, StateInputs >::state ( ) const
inlineprotected

Managed state accessor.

Returns
Managed state

Definition at line 196 of file state_manager.h.


The documentation for this class was generated from the following file: