3#include <Dataflow/RaDataflow.hpp>
5#include <Core/Utils/Log.hpp>
6#include <Core/Utils/TypesUtils.hpp>
8#include <Dataflow/Core/Port.hpp>
19class RA_DATAFLOW_CORE_API PortBaseOut :
public PortBase
25 PortBaseOut() =
delete;
26 PortBaseOut(
const PortBaseOut& ) =
delete;
27 PortBaseOut& operator=(
const PortBaseOut& ) =
delete;
39 void set_data( T* data );
42 virtual void increase_link_count() {
44 CORE_ASSERT( m_linkCount >= 0,
"link count error" );
48 virtual void decrease_link_count() {
50 CORE_ASSERT( m_linkCount >= 0,
"link count error" );
52 virtual int link_count() {
return m_linkCount; }
61 int m_linkCount { 0 };
92 PortBaseOut(
node,
name, typeid( T ) ), m_data {
data } {
98 T&
data() {
return *m_data; }
110 T* m_data {
nullptr };
114template <
typename Type>
115using PortOutPtr = PortPtr<PortOut<Type>>;
116template <
typename Type>
117using PortOutRawPtr =
typename PortOutPtr<Type>::element_type*;
119using PortBaseOutRawPtr = PortRawPtr<PortBaseOut>;
120using PortBaseOutPtr = PortPtr<PortBaseOut>;
123T& PortBaseOut::data() {
124 auto thisOut =
dynamic_cast<PortOut<T>*
>( this );
125 if ( thisOut && thisOut->has_data() ) {
return thisOut->data(); }
127 using namespace Ra::Core::Utils;
128 LOG( Ra::Core::Utils::logERROR )
129 <<
"Unable to get data with type " << simplifiedDemangledType<T>() <<
" on port " <<
name()
135void PortBaseOut::set_data( T* data ) {
136 auto thisOut =
dynamic_cast<PortOut<T>*
>( this );
138 thisOut->set_data( data );
142 using namespace Ra::Core::Utils;
143 LOG( Ra::Core::Utils::logERROR )
144 <<
"Unable to set data with type " << simplifiedDemangledType( *data ) <<
" on port "
Base abstract class for all the nodes added and used by the node system.
Base class for nodes' ports A port is a strongly typed extremity of connections between nodes.
std::string port_typename() const
Gets the human readable type of the port object.
const std::string & name() const
Gets the port's name.
Node * node() const
Gets a pointer to the node this port belongs to.
Input port accepting data of type T.
Forward PortOut classes used by getLink and reflect.
PortOut(Node *node, const std::string &name)
bool has_data() override
Returns true if the pointer to the data is not null.
T & data()
Gets a reference to the data this ports points to.
hepler function to manage enum as underlying types in VariableSet