GNode library (C++)
Loading...
Searching...
No Matches
gnode::Port Class Referenceabstract

Abstract base class representing a port in a node. More...

#include <port.hpp>

Inheritance diagram for gnode::Port:

Public Member Functions

 Port ()=default
 Default constructor for Port.
 
 Port (std::string label)
 Constructs a Port with the specified label.
 
virtual ~Port ()=default
 Virtual destructor for Port.
 
std::string get_data_type () const
 Retrieves the type name of the data handled by this port.
 
std::string get_label () const
 Retrieves the label of the port.
 
virtual std::shared_ptr< BaseDataget_data_shared_ptr_downcasted () const
 Retrieves a shared pointer to the data associated with the port after downcasting.
 
virtual PortType get_port_type () const =0
 Pure virtual function to get the type of the port (IN or OUT).
 
virtual void * get_value_ref_void () const =0
 Retrieves a void* reference to the data value stored in this output port.
 
virtual void set_data (std::shared_ptr< BaseData >)
 Sets the data associated with the port.
 

Protected Attributes

std::string data_type
 A string representing the type name.
 

Private Attributes

std::string label = "no label"
 The label of the port.
 

Detailed Description

Abstract base class representing a port in a node.

The Port class provides a common interface for input and output ports. Each port has a label and can hold data.

Constructor & Destructor Documentation

◆ Port() [1/2]

gnode::Port::Port ( )
default

Default constructor for Port.

◆ Port() [2/2]

gnode::Port::Port ( std::string  label)
inline

Constructs a Port with the specified label.

Parameters
labelA string representing the label of the port.

◆ ~Port()

virtual gnode::Port::~Port ( )
virtualdefault

Virtual destructor for Port.

Member Function Documentation

◆ get_data_shared_ptr_downcasted()

virtual std::shared_ptr< BaseData > gnode::Port::get_data_shared_ptr_downcasted ( ) const
inlinevirtual

Retrieves a shared pointer to the data associated with the port after downcasting.

Returns
A shared pointer to the BaseData, or nullptr if not applicable.

Reimplemented in gnode::Output< T >.

◆ get_data_type()

std::string gnode::Port::get_data_type ( ) const
inline

Retrieves the type name of the data handled by this port.

Returns
A string representing the type name.

◆ get_label()

std::string gnode::Port::get_label ( ) const
inline

Retrieves the label of the port.

Returns
A string representing the port's label.

◆ get_port_type()

virtual PortType gnode::Port::get_port_type ( ) const
pure virtual

Pure virtual function to get the type of the port (IN or OUT).

This function must be implemented by derived classes to indicate whether the port is an input (PortType::IN) or an output (PortType::OUT).

Returns
The port type (PortType::IN or PortType::OUT).

Implemented in gnode::Input< T >, and gnode::Output< T >.

◆ get_value_ref_void()

virtual void * gnode::Port::get_value_ref_void ( ) const
pure virtual

Retrieves a void* reference to the data value stored in this output port.

Returns
A void* pointer to the data value.

Implemented in gnode::Input< T >, and gnode::Output< T >.

◆ set_data()

virtual void gnode::Port::set_data ( std::shared_ptr< BaseData )
inlinevirtual

Sets the data associated with the port.

Parameters
dataA shared pointer to the BaseData to set.

Reimplemented in gnode::Input< T >.

Member Data Documentation

◆ data_type

std::string gnode::Port::data_type
protected

A string representing the type name.

◆ label

std::string gnode::Port::label = "no label"
private

The label of the port.


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