Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
hh::core::GraphSink< Outputs > Class Template Reference

Sink of the graph, only used in an outer graph. More...

#include "graph_sink.h"

Inheritance diagram for hh::core::GraphSink< Outputs >:
Inheritance graph
Collaboration diagram for hh::core::GraphSink< Outputs >:
Collaboration graph

Public Types

using ResultType_t = std::shared_ptr< std::variant< std::shared_ptr< Outputs >... > >
 Accessor to the output types.
 

Public Member Functions

 GraphSink ()
 Default constructor.
 
 ~GraphSink () override=default
 Default destructor.
 
void wakeUp () override
 Wake up implementation (notify one node waiting on the condition variable)
 
ResultType_t getBlockingResult ()
 Get a result from the sink, if none is available wait for it (block the current thread)
 
void print (Printer *printer)
 Gather sink information.
 
std::vector< std::pair< std::string const, std::string const > > ids () const override
 Node ids [nodeId, nodeGroupId] accessor.
 
- Public Member Functions inherited from hh::core::abstraction::NodeAbstraction
 NodeAbstraction (std::string name)
 Core node constructor using the core's name.
 
virtual ~NodeAbstraction ()=default
 DEfault destructor.
 
std::string const & name () const
 Accessor to the core's name.
 
virtual std::string id () const
 Core's id ('x' + address of abstraction) as string.
 
bool isRegistered () const
 Accessor to registration flag.
 
GraphNodeAbstractionbelongingGraph () const
 Belonging graph accessor.
 
virtual int deviceId () const
 Get the device identifier (got from belonging graph)
 
virtual size_t graphId () const
 Get the graph identifier (got from belonging graph)
 
std::chrono::nanoseconds const & executionDuration () const
 Execution duration.
 
std::chrono::time_point< std::chrono::system_clock > const & startExecutionTimeStamp () const
 Accessor to the starting execution timestamp.
 
void startExecutionTimeStamp (std::chrono::time_point< std::chrono::system_clock > const &startExecutionTimeStamp)
 Setter to the starting execution timestamp.
 
void incrementExecutionDuration (std::chrono::nanoseconds const &exec)
 Increment execution duration.
 
virtual void registerNode (GraphNodeAbstraction *belongingGraph)
 Register node to the given graph.
 
virtual std::vector< std::pair< std::string const, std::string const > > ids () const =0
 Node ids [nodeId, nodeGroupId] accessor.
 
virtual behavior::Nodenode () const =0
 Node accessor.
 
- Public Member Functions inherited from hh::core::abstraction::SlotAbstraction
 SlotAbstraction (std::shared_ptr< implementor::ImplementorSlot > concreteSlot)
 Constructor using a concrete slot implementation.
 
virtual ~SlotAbstraction ()=default
 Default destructor.
 
std::set< SlotAbstraction * > const & slots () const
 Const accessor to slots.
 
std::set< SlotAbstraction * > & slots ()
 Accessor to slots.
 
std::set< NotifierAbstraction * > const & connectedNotifiers () const
 Accessor to the NotifierAbstraction attached to this slot, protected with mutex.
 
void addNotifier (NotifierAbstraction *const notifier)
 Add a NotifierAbstraction to this slot.
 
void removeNotifier (NotifierAbstraction *const notifier)
 Remove a NotifierAbstraction to this slot.
 
virtual void wakeUp ()=0
 Wake up mechanism, called to notify the std::condition_variable.
 
bool hasNotifierConnected () const
 Test if there is at least one notifier connected.
 
void lockSlotMutex ()
 Lock mutex.
 
void unlockSlotMutex ()
 Unlock mutex.
 
- Public Member Functions inherited from hh::core::abstraction::ReceiverAbstraction< Outputs >
 ReceiverAbstraction (std::shared_ptr< implementor::ImplementorReceiver< Outputs > > concreteReceiver, std::shared_ptr< std::mutex > slotMutex)
 Constructor using a concrete implementation of a receiver implementor, and the mutex from the slot.
 
virtual ~ReceiverAbstraction ()=default
 Default destructor.
 
std::set< ReceiverAbstraction * > const & receivers () const
 Const accessor to receivers.
 
std::set< ReceiverAbstraction * > & receivers ()
 Accessor to receivers.
 
std::set< SenderAbstraction< Outputs > * > const & connectedSenders () const
 Accessor to the senders attached to this receiver.
 
void receive (std::shared_ptr< Outputs > const inputData)
 Receive a piece of data.
 
std::shared_ptr< Outputs > getInputData ()
 Get an input data from the concrete receiver implementation.
 
size_t numberElementsReceived () const
 Accessor to the current number of input data received and waiting to be processed.
 
size_t maxNumberElementsReceived () const
 Accessor to the maximum number of input data received and waiting to be processed.
 
bool empty () const
 Test if the receiver is empty.
 
void addSender (SenderAbstraction< Outputs > *const sender)
 Add a SenderAbstraction to the concrete receiver implementation.
 
void removeSender (SenderAbstraction< Outputs > *const sender)
 Remove a SenderAbstraction to the concrete receiver implementation.
 
void printEdgeInformation (Printer *printer)
 Add to the printer the edge information.
 

Private Member Functions

template<class Output >
void getOneAvailableResultForAType (bool &outputFound, ResultType_t &res)
 Test if there is an available output data for a data.
 
bool receiversEmpty ()
 Test if the receivers for all types are empty.
 
behavior::Nodenode () const override
 Getter to the node counterpart.
 

Additional Inherited Members

- Protected Member Functions inherited from hh::core::abstraction::SlotAbstraction
std::shared_ptr< std::mutex > const & mutex () const
 Protected accessor to mutex.
 
std::shared_ptr< std::condition_variable > const & slotConditionVariable () const
 Protected accessor to condition variable.
 
void copyInnerStructure (SlotAbstraction *copyableCore)
 Copy the inner structure of copyableCore into this.
 
- Protected Member Functions inherited from hh::core::abstraction::ReceiverAbstraction< Outputs >
void copyInnerStructure (ReceiverAbstraction< Outputs > *copyableCore)
 Copy inner structure of the receiver to this one.
 

Detailed Description

template<class ... Outputs>
class hh::core::GraphSink< Outputs >

Sink of the graph, only used in an outer graph.

Template Parameters
OutputsOutput list types of the graph

Definition at line 40 of file graph_sink.h.

Member Typedef Documentation

◆ ResultType_t

template<class ... Outputs>
using hh::core::GraphSink< Outputs >::ResultType_t = std::shared_ptr<std::variant<std::shared_ptr<Outputs>...> >

Accessor to the output types.

Definition at line 45 of file graph_sink.h.

Constructor & Destructor Documentation

◆ GraphSink()

template<class ... Outputs>
hh::core::GraphSink< Outputs >::GraphSink ( )
inline

Default constructor.

Definition at line 48 of file graph_sink.h.

◆ ~GraphSink()

template<class ... Outputs>
hh::core::GraphSink< Outputs >::~GraphSink ( )
overridedefault

Default destructor.

Member Function Documentation

◆ getBlockingResult()

template<class ... Outputs>
ResultType_t hh::core::GraphSink< Outputs >::getBlockingResult ( )
inline

Get a result from the sink, if none is available wait for it (block the current thread)

Returns
A variant of shared pointers containing an output data

Definition at line 63 of file graph_sink.h.

Here is the call graph for this function:

◆ getOneAvailableResultForAType()

template<class ... Outputs>
template<class Output >
void hh::core::GraphSink< Outputs >::getOneAvailableResultForAType ( bool &  outputFound,
ResultType_t res 
)
inlineprivate

Test if there is an available output data for a data.

If none as been previously found (outputFound == true) and if the receiver for this type is not empty, get a data from the receiver

Template Parameters
OutputType of the output data
Parameters
outputFoundFlag to avoid getting multiple output data in one run
resOutput data

Definition at line 102 of file graph_sink.h.

Here is the call graph for this function:

◆ ids()

template<class ... Outputs>
std::vector< std::pair< std::string const, std::string const > > hh::core::GraphSink< Outputs >::ids ( ) const
inlineoverridevirtual

Node ids [nodeId, nodeGroupId] accessor.

Returns
Node ids [nodeId, nodeGroupId]

Implements hh::core::abstraction::NodeAbstraction.

Definition at line 90 of file graph_sink.h.

Here is the call graph for this function:

◆ node()

template<class ... Outputs>
behavior::Node * hh::core::GraphSink< Outputs >::node ( ) const
inlineoverrideprivatevirtual

Getter to the node counterpart.

Returns
Nothing, throw an error because there is no Node attached to the core
Exceptions
std::runtime_errorbecause there is no Node attached to the core

Implements hh::core::abstraction::NodeAbstraction.

Definition at line 118 of file graph_sink.h.

◆ print()

template<class ... Outputs>
void hh::core::GraphSink< Outputs >::print ( Printer printer)
inline

Gather sink information.

Parameters
printerPrinter visitor gathering information on nodes

Definition at line 83 of file graph_sink.h.

Here is the call graph for this function:

◆ receiversEmpty()

template<class ... Outputs>
bool hh::core::GraphSink< Outputs >::receiversEmpty ( )
inlineprivate

Test if the receivers for all types are empty.

Returns
True if the receivers for all types are empty, else false

Definition at line 113 of file graph_sink.h.

Here is the caller graph for this function:

◆ wakeUp()

template<class ... Outputs>
void hh::core::GraphSink< Outputs >::wakeUp ( )
inlineoverridevirtual

Wake up implementation (notify one node waiting on the condition variable)

Implements hh::core::abstraction::SlotAbstraction.

Definition at line 59 of file graph_sink.h.

Here is the call graph for this function: