Loading [MathJax]/extensions/tex2jax.js
Radium Engine  1.5.28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Ra::Dataflow::Core::PortIn< T > Class Template Reference

Input port accepting data of type T. More...

#include <Dataflow/Core/PortIn.hpp>

+ Inheritance diagram for Ra::Dataflow::Core::PortIn< T >:
+ Collaboration diagram for Ra::Dataflow::Core::PortIn< T >:

Public Types

using DataType = T
 
- Public Types inherited from Ra::Core::Utils::Observable< const std::string &, const PortIn< T > &, bool >
using Observer
 Observer functor type.
 

Public Member Functions

bool has_data () override
 
T & data ()
 Gets the data pointed by the connected out port.
 
void set_default_value (const T &value)
 
T & default_value ()
 
bool has_default_value () const override
 
void insert (Ra::Core::VariableSet &v) override
 
bool is_linked () const override
 
template<typename B = T, std::enable_if_t< std::is_constructible< nlohmann::json, B >::value, bool > = true>
void to_json_impl (nlohmann::json &data)
 
template<typename B = T, std::enable_if_t<!std::is_constructible< nlohmann::json, B >::value, bool > = true>
void to_json_impl (nlohmann::json &data)
 
template<typename B = T, std::enable_if_t< std::is_assignable< nlohmann::json, B >::value, bool > = true>
void from_json_impl (const nlohmann::json &data)
 
template<typename B = T, std::enable_if_t<!std::is_assignable< nlohmann::json, B >::value, int > = true>
void from_json_impl (const nlohmann::json &data)
 
void to_json (nlohmann::json &data) override
 
void from_json (const nlohmann::json &data) override
 
Constructors

delete default constructors.

 PortIn (const PortIn &)=delete
 
PortInoperator= (const PortIn &)=delete
 
 PortIn (Node *node, const std::string &name)
 
 PortIn (Node *node, const std::string &name, const T &value)
 
Manage the connection with a PortOut.
bool accept (PortBaseOut *portOut) const override
 
bool accept (PortOut< T > *portOut) const
 
bool connect (PortBaseOut *portOut) override
 
bool connect (PortOut< T > *portOut)
 
bool disconnect () override
 
PortBaseOut * link () override
 
- Public Member Functions inherited from Ra::Core::Utils::Observable< const std::string &, const PortIn< T > &, bool >
 Observable ()=default
 Default constructor ... do nothing ;)
 
 Observable (const Observable &)=delete
 
Observableoperator= (const Observable &)=delete
 
void copyObserversTo (Observable &other) const
 explicit copy of all attached observers the other Observable
 
int attach (Observer observer)
 
int attachMember (T *object, void(T::*observer)(Args...))
 
void notify (Args... p) const
 Notify (i.e. call) each attached observer with argument p.
 
void detachAll ()
 Detach all observers.
 
void detach (int observerId)
 

Detailed Description

template<typename T>
class Ra::Dataflow::Core::PortIn< T >

Input port accepting data of type T.

Forward PortIn classes used by getLink and reflect.

An input port does not staore the data but is an accessor to the data stored on the connected output port. An Input port is observable and notify its observers at each connect/disconnect event.

Template Parameters
TThe accepted data type

Definition at line 17 of file PortOut.hpp.

Member Typedef Documentation

◆ DataType

template<typename T >
using Ra::Dataflow::Core::PortIn< T >::DataType = T

Definition at line 74 of file PortIn.hpp.

Constructor & Destructor Documentation

◆ PortIn() [1/2]

template<typename T >
Ra::Dataflow::Core::PortIn< T >::PortIn ( Node * node,
const std::string & name )
inline

Constructor.

Parameters
nodeThe pointer to the node associated with the port.
nameThe name of the port.

Definition at line 87 of file PortIn.hpp.

◆ PortIn() [2/2]

template<typename T >
Ra::Dataflow::Core::PortIn< T >::PortIn ( Node * node,
const std::string & name,
const T & value )
inline

Parameters
valuedefault value of the port

Definition at line 92 of file PortIn.hpp.

Member Function Documentation

◆ accept() [1/2]

template<typename T >
bool Ra::Dataflow::Core::PortIn< T >::accept ( PortBaseOut * portOut) const
override

Definition at line 216 of file PortIn.hpp.

◆ accept() [2/2]

template<typename T >
bool Ra::Dataflow::Core::PortIn< T >::accept ( PortOut< T > * portOut) const

Definition at line 221 of file PortIn.hpp.

◆ connect() [1/2]

template<typename T >
bool Ra::Dataflow::Core::PortIn< T >::connect ( PortBaseOut * portOut)
override

Definition at line 226 of file PortIn.hpp.

◆ connect() [2/2]

template<typename T >
bool Ra::Dataflow::Core::PortIn< T >::connect ( PortOut< T > * portOut)

Definition at line 237 of file PortIn.hpp.

◆ data()

template<typename T >
T & Ra::Dataflow::Core::PortIn< T >::data ( )

Gets the data pointed by the connected out port.

It checks if the data is available. If it is not, it returns the default value. Fails if note link nor has a default value, check with has_data beforehand if needed.

Returns
T& The reference to the data.

Definition at line 200 of file PortIn.hpp.

◆ default_value()

template<typename T >
T & Ra::Dataflow::Core::PortIn< T >::default_value ( )
inline

Definition at line 125 of file PortIn.hpp.

◆ disconnect()

template<typename T >
bool Ra::Dataflow::Core::PortIn< T >::disconnect ( )
override

Definition at line 248 of file PortIn.hpp.

◆ from_json()

template<typename T >
void Ra::Dataflow::Core::PortIn< T >::from_json ( const nlohmann::json & data)
inlineoverridevirtual

Reimplemented from Ra::Dataflow::Core::PortBase.

Definition at line 165 of file PortIn.hpp.

◆ from_json_impl() [1/2]

template<typename T >
template<typename B = T, std::enable_if_t< std::is_assignable< nlohmann::json, B >::value, bool > = true>
void Ra::Dataflow::Core::PortIn< T >::from_json_impl ( const nlohmann::json & data)
inline

Definition at line 150 of file PortIn.hpp.

◆ from_json_impl() [2/2]

template<typename T >
template<typename B = T, std::enable_if_t<!std::is_assignable< nlohmann::json, B >::value, int > = true>
void Ra::Dataflow::Core::PortIn< T >::from_json_impl ( const nlohmann::json & data)
inline

Definition at line 158 of file PortIn.hpp.

◆ has_data()

template<typename T >
bool Ra::Dataflow::Core::PortIn< T >::has_data ( )
inlineoverridevirtual

Returns true if the port is linked to an output port that has data or if it has a default value.

Implements Ra::Dataflow::Core::PortBase.

Definition at line 210 of file PortIn.hpp.

◆ has_default_value()

template<typename T >
bool Ra::Dataflow::Core::PortIn< T >::has_default_value ( ) const
inlineoverride

Definition at line 126 of file PortIn.hpp.

◆ insert()

template<typename T >
void Ra::Dataflow::Core::PortIn< T >::insert ( Ra::Core::VariableSet & v)
inlineoverride

Definition at line 127 of file PortIn.hpp.

◆ is_linked()

template<typename T >
bool Ra::Dataflow::Core::PortIn< T >::is_linked ( ) const
inlineoverride

Definition at line 132 of file PortIn.hpp.

◆ link()

template<typename T >
PortBaseOut * Ra::Dataflow::Core::PortIn< T >::link ( )
inlineoverride

Definition at line 121 of file PortIn.hpp.

◆ set_default_value()

template<typename T >
void Ra::Dataflow::Core::PortIn< T >::set_default_value ( const T & value)
inline

Definition at line 124 of file PortIn.hpp.

◆ to_json()

template<typename T >
void Ra::Dataflow::Core::PortIn< T >::to_json ( nlohmann::json & data)
inlineoverridevirtual

Reimplemented from Ra::Dataflow::Core::PortBase.

Definition at line 161 of file PortIn.hpp.

◆ to_json_impl() [1/2]

template<typename T >
template<typename B = T, std::enable_if_t< std::is_constructible< nlohmann::json, B >::value, bool > = true>
void Ra::Dataflow::Core::PortIn< T >::to_json_impl ( nlohmann::json & data)
inline

Definition at line 136 of file PortIn.hpp.

◆ to_json_impl() [2/2]

template<typename T >
template<typename B = T, std::enable_if_t<!std::is_constructible< nlohmann::json, B >::value, bool > = true>
void Ra::Dataflow::Core::PortIn< T >::to_json_impl ( nlohmann::json & data)
inline

Definition at line 141 of file PortIn.hpp.


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