HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_PortData Class Reference

#include <UN_PortData.h>

+ Inheritance diagram for UN_PortData:

Classes

class  IDIterator
 Iterator for traversing valid port IDs. More...
 
class  OrderedIDIterator
 Iterator for traversing valid port IDs in an ascending order. More...
 

Public Types

using IDRange = UT_IteratorRange< IDIterator >
 Returns a range for iterating valid port IDs. More...
 
using OrderedIDRange = UT_IteratorRange< OrderedIDIterator >
 Returns a range for iterating valid port IDs. More...
 
- Public Types inherited from UN_Data
using IDRange = UN_DataIndexMap::IDRange
 Returns a range for iterating valid IDs. More...
 
using OrderedIDRange = UN_DataIndexMap::OrderedIDRange
 Returns a range for iterating valid IDs in an ascending order. More...
 

Public Member Functions

 UN_PortData (UN_CustomPortDataPtr custom_data=UN_CustomPortDataPtr())
 Constructors and destructors. More...
 
 ~UN_PortData ()=default
 
 UN_PortData (UN_PortData &&)
 
UN_PortDataoperator= (UN_PortData &&)
 
void setCapacityIfNeeded (UN_DataSize min_capacity)
 
UN_PortIDRemap merge (const UN_PortData &src_port_data)
 
UN_OptionsPtr asOptionsClassic (UN_PortID port_id, bool include_name=true) const
 Returns the options object representing this port data. More...
 
UN_PortID addPort ()
 
void clearPort (UN_PortID port_id)
 Clears the data for the given port to the default state. More...
 
bool removePort (UN_PortID port_id)
 
void removeAllPorts (bool reset_next_id)
 
bool isValid (UN_PortID port_id) const
 
IDRange idRange () const
 
OrderedIDRange orderedIDRange () const
 
UN_PortIDList portIDs () const
 Returns a list of all the valid port IDs in the graph. More...
 
UN_PortIDList sortedPortIDs () const
 Returns a list of all the valid port IDs in the graph. More...
 
void setKind (UN_PortID port_id, UN_PortKind port_kind)
 Sets the port's kind indicating whether it is an input or an output. More...
 
UN_PortKind kind (UN_PortID port_id) const
 Returns the port's kind indicating whether it is an input or an output. More...
 
const UT_StringHoldername (UN_PortID port_id) const
 Returns the port name that identifies it on the node. More...
 
void setTypeName (UN_PortID port_id, const UT_StringRef &type_name)
 Sets the name of the port's type. More...
 
const UT_StringHoldertypeName (UN_PortID port_id) const
 Returns the name of the port's type. More...
 
void setLabel (UN_PortID port_id, const UT_StringRef &label)
 Sets the port's label. More...
 
const UT_StringHolderlabel (UN_PortID port_id) const
 Returns the port's label. More...
 
template<typename OP >
void updateTags (UN_PortID port_id, const OP &op)
 
void setTags (UN_PortID port_id, const UT_StringArray &tags)
 Sets new tags on a port via copy-assignment. More...
 
void setTags (UN_PortID port_id, UT_StringArray &&tags)
 Sets new tags on a port via move-assignment. More...
 
const UT_StringArraytags (UN_PortID port_id) const
 Returns port's tags. More...
 
UT_StringArray stealTags (UN_PortID port_id)
 Returns port's tags moved from the data buffer entry. More...
 
template<typename T >
void setGenericData (UN_GenericBufferID buf_id, UN_PortID port_id, const T &value)
 Sets the data value in a generic buffer for a given port. More...
 
template<typename T >
void setGenericData (UN_GenericBufferID buf_id, UN_PortID port_id, T &&value)
 Sets the data value in a generic buffer via move. More...
 
template<typename T >
const TgenericDataRef (UN_GenericBufferID buf_id, UN_PortID port_id) const
 Returns a const ref to the data value in a generic buffer. More...
 
template<typename T >
T genericDataVal (UN_GenericBufferID buf_id, UN_PortID port_id) const
 Returns a copy of a data value from a generic buffer. More...
 
template<typename T >
T stealGenericData (UN_GenericBufferID buf_id, UN_PortID port_id)
 Moves the data value out of a generic buffer. More...
 
template<typename T , typename OP >
void updateGenericData (UN_GenericBufferID buf_id, UN_PortID port_id, const OP &op)
 Updates the data value in a generic buffer in-place via a callable. More...
 
void setCheckValidPortNames (bool flag)
 Asserts that the port names are alphanumeric. More...
 
void setCheckValidPortTypeNames (bool flag)
 Asserts that the port type names are alphanumeric. More...
 
UN_CustomPortDatacustomPortData ()
 Returns port's custom data container, if one was provided. More...
 
const UN_CustomPortDatacustomPortData () const
 Returns port's custom data container, if one was provided. More...
 
void merge (UN_PortID port_id, const UT_OptionEntry &port_entry)
 Configure the port based on the information in the given option entry. More...
 
void merge (UN_PortID parm_id, const UN_Options &port_opts)
 Configure the port based on the information in the given option entry. More...
 
- Public Member Functions inherited from UN_Data
 UN_Data (UN_CustomDataPtr custom_data=UN_CustomDataPtr())
 Constructors and destructors. More...
 
 ~UN_Data ()=default
 
 UN_Data (UN_Data &&)
 Move operators. More...
 
UN_Dataoperator= (UN_Data &&)
 
IDRange idRange () const
 
OrderedIDRange orderedIDRange () const
 
UN_DataIDList dataIDs () const
 Returns a list of all the valid IDs in this container. More...
 
UN_DataIDList sortedDataIDs () const
 Returns a sorted list of all the valid IDs in this container. More...
 
UN_DataSize size () const
 Returns the number of valid data items in the buffer. More...
 
UN_DataSize indexSize () const
 
UN_DataSize idSize () const
 
template<typename D >
UN_GenericBufferID addGenericBuffer (const UT_StringRef &name, UN_GenericBufferType type, const D &default_value)
 
UN_GenericBufferType genericBufferType (UN_GenericBufferID id) const
 Returns the type of the generic buffer identified by the given ID. More...
 
UN_GenericBufferID findGenericBuffer (const UT_StringRef &name) const
 
const UT_StringHoldergenericBufferName (UN_GenericBufferID id) const
 Returns the name of the generic buffer identified by the given ID. More...
 
UN_CustomDatacustomData ()
 Returns the custom data container, if one was provided. More...
 
const UN_CustomDatacustomData () const
 Returns the custom data container, if one was provided. More...
 

Static Public Attributes

static const UT_StringArray theDefTags
 

Protected Member Functions

 UN_PortData (const UN_PortData &)=default
 
UN_PortDataoperator= (const UN_PortData &)=default
 
void setName (UN_PortID port_id, const UT_StringRef &name)
 Sets the port name that identifies it on the node. More...
 
UN_PortIndex portIndex (UN_PortID id) const
 Returns the port's data index into the data buffer arrays. More...
 
- Protected Member Functions inherited from UN_Data
 UN_Data (const UN_Data &)
 
UN_Dataoperator= (const UN_Data &)
 
UN_DataMergeInfo mergeData (const UN_Data &src_data, bool combine_id_zero=false)
 
std::pair< UN_DataID,
UN_DataIndex
addData ()
 
std::pair< UN_DataID,
UN_DataIndex
findOrAddData (UN_DataID data_id)
 
bool removeData (UN_DataID data_id)
 
void removeAllData (bool reset_next_id)
 
bool isValid (UN_DataID data_id) const
 
UN_DataIndex dataIndex (UN_DataID id) const
 
UN_DataSize dataBufferSize () const
 
UN_DataSize freeDataBufferSize () const
 
UN_DataSize usedDataBufferSize () const
 
template<typename V , typename B >
void setData (B &buffer, UN_DataID id, const V &value)
 Helper method to copy-assign the value to an entry in the data buffer. More...
 
template<typename V , typename B >
void setData (B &buffer, UN_DataID id, V &&value)
 Helper method to move-assign the value to an entry in the data buffer. More...
 
template<typename V , typename B >
const V & getDataRef (const B &buffer, UN_DataID id, const V &default_value) const
 Helper method to return a const ref to an entry in the data buffer. More...
 
template<typename V , typename B >
getDataVal (const B &buffer, UN_DataID id, const V &default_value) const
 
template<typename V , typename B >
stealData (B &buffer, UN_DataID id, const V &default_value)
 Helper method to return a value moved from an entry in the data buffer. More...
 
template<typename OP , typename B >
void updateData (B &buffer, UN_DataID id, const OP &op)
 
template<typename T >
void setGenericData (UN_GenericBufferID buf_id, UN_DataID id, const T &value)
 Sets the data value in a generic buffer for a given data ID. More...
 
template<typename T >
void setGenericData (UN_GenericBufferID buf_id, UN_DataID id, T &&value)
 Sets the data value in a generic buffer via move. More...
 
template<typename T >
const TgenericDataRef (UN_GenericBufferID buf_id, UN_DataID id) const
 Returns a const ref to the data value in a generic buffer. More...
 
template<typename T >
T genericDataVal (UN_GenericBufferID buf_id, UN_DataID id) const
 
template<typename T >
T stealGenericData (UN_GenericBufferID buf_id, UN_DataID id)
 Moves the data value out of a generic buffer. More...
 
template<typename T , typename OP >
void updateGenericData (UN_GenericBufferID buf_id, UN_DataID id, const OP &op)
 Updates the data value in a generic buffer in-place via a callable. More...
 
void addGenericData (UN_DataIndex index)
 Adds a data slot at the given index to all generic buffers. More...
 
void clearGenericData (UN_DataIndex index)
 Clears the generic data at the given index to defaults. More...
 
void removeAllGenericData ()
 Removes all data from all generic buffers. More...
 
void setGenericDataCapacityIfNeeded (UN_DataSize min_capacity)
 Grows all generic buffers to the given minimum capacity. More...
 
void mergeGenericData (const UN_Data &src, const UN_DataMergeInfo &merge_info)
 Merges generic data from another UN_Data container. More...
 
bool isGenericDataSizeConsistent (UN_DataSize expected_size) const
 Returns true if all generic buffers have the expected size. More...
 

Protected Attributes

friend UN_GraphData
 

Detailed Description

Container of data for all the ports in the graph.

NOTE: This class is generally not trivially relocatable, because its base class (UN_Data) is not trivially relocatable (see comment there).

Definition at line 31 of file UN_PortData.h.

Member Typedef Documentation

Returns a range for iterating valid port IDs.

Definition at line 146 of file UN_PortData.h.

Returns a range for iterating valid port IDs.

Definition at line 154 of file UN_PortData.h.

Constructor & Destructor Documentation

UN_PortData::UN_PortData ( UN_CustomPortDataPtr  custom_data = UN_CustomPortDataPtr())

Constructors and destructors.

UN_PortData::~UN_PortData ( )
default
UN_PortData::UN_PortData ( UN_PortData &&  )
UN_PortData::UN_PortData ( const UN_PortData )
protecteddefault

Member Function Documentation

UN_PortID UN_PortData::addPort ( )

Adds a slot for a new port in this container. Returns an ID that should be used to refer to this new port for accessing its data (eg, name, connection wire, etc).

UN_OptionsPtr UN_PortData::asOptionsClassic ( UN_PortID  port_id,
bool  include_name = true 
) const

Returns the options object representing this port data.

Parameters
include_nameIf true, the result will contain the entry for the node name; otherwise, the name will be skipped.
void UN_PortData::clearPort ( UN_PortID  port_id)

Clears the data for the given port to the default state.

UN_CustomPortData* UN_PortData::customPortData ( )
inline

Returns port's custom data container, if one was provided.

Definition at line 56 of file UN_PortData.h.

const UN_CustomPortData* UN_PortData::customPortData ( ) const
inline

Returns port's custom data container, if one was provided.

Definition at line 61 of file UN_PortData.h.

template<typename T >
const T& UN_PortData::genericDataRef ( UN_GenericBufferID  buf_id,
UN_PortID  port_id 
) const
inline

Returns a const ref to the data value in a generic buffer.

Definition at line 298 of file UN_PortData.h.

template<typename T >
T UN_PortData::genericDataVal ( UN_GenericBufferID  buf_id,
UN_PortID  port_id 
) const
inline

Returns a copy of a data value from a generic buffer.

Definition at line 304 of file UN_PortData.h.

IDRange UN_PortData::idRange ( ) const
inline

Definition at line 147 of file UN_PortData.h.

bool UN_PortData::isValid ( UN_PortID  port_id) const
inline

Returns true if the given ID refers to a valid port entry in the data buffers. Ie, such a port exists and is valid.

Definition at line 112 of file UN_PortData.h.

UN_PortKind UN_PortData::kind ( UN_PortID  port_id) const
inline

Returns the port's kind indicating whether it is an input or an output.

Definition at line 189 of file UN_PortData.h.

const UT_StringHolder& UN_PortData::label ( UN_PortID  port_id) const
inline

Returns the port's label.

Definition at line 236 of file UN_PortData.h.

UN_PortIDRemap UN_PortData::merge ( const UN_PortData src_port_data)

Merges another port data container into this one. Returns a mapping between the port IDs in the merge source and destination (this) data buffers.

void UN_PortData::merge ( UN_PortID  port_id,
const UT_OptionEntry port_entry 
)

Configure the port based on the information in the given option entry.

void UN_PortData::merge ( UN_PortID  parm_id,
const UN_Options port_opts 
)

Configure the port based on the information in the given option entry.

const UT_StringHolder& UN_PortData::name ( UN_PortID  port_id) const
inline

Returns the port name that identifies it on the node.

Definition at line 210 of file UN_PortData.h.

UN_PortData& UN_PortData::operator= ( UN_PortData &&  )
UN_PortData& UN_PortData::operator= ( const UN_PortData )
protecteddefault
OrderedIDRange UN_PortData::orderedIDRange ( ) const
inline

Definition at line 155 of file UN_PortData.h.

UN_PortIDList UN_PortData::portIDs ( ) const
inline

Returns a list of all the valid port IDs in the graph.

Definition at line 162 of file UN_PortData.h.

UN_PortIndex UN_PortData::portIndex ( UN_PortID  id) const
inlineprotected

Returns the port's data index into the data buffer arrays.

Definition at line 330 of file UN_PortData.h.

void UN_PortData::removeAllPorts ( bool  reset_next_id)

Frees the data slots occupied by all the ports.

Parameters
'reset_next_id'If true, the node ID generator is reset to zero.
bool UN_PortData::removePort ( UN_PortID  port_id)

Removes the port from this container and frees the data slot it occupied. After calling this method the container will have no knowledge of the port by this ID. Returns true on successs; false if the port was not found.

void UN_PortData::setCapacityIfNeeded ( UN_DataSize  min_capacity)

Increases the capacity of the data buffer arrays to the given minimum, unless the capacity is already greater or equal to that minimum, in which case the capacity remains unchanged.

void UN_PortData::setCheckValidPortNames ( bool  flag)
inline

Asserts that the port names are alphanumeric.

Definition at line 321 of file UN_PortData.h.

void UN_PortData::setCheckValidPortTypeNames ( bool  flag)
inline

Asserts that the port type names are alphanumeric.

Definition at line 325 of file UN_PortData.h.

template<typename T >
void UN_PortData::setGenericData ( UN_GenericBufferID  buf_id,
UN_PortID  port_id,
const T value 
)
inline

Sets the data value in a generic buffer for a given port.

Definition at line 286 of file UN_PortData.h.

template<typename T >
void UN_PortData::setGenericData ( UN_GenericBufferID  buf_id,
UN_PortID  port_id,
T &&  value 
)
inline

Sets the data value in a generic buffer via move.

Definition at line 292 of file UN_PortData.h.

void UN_PortData::setKind ( UN_PortID  port_id,
UN_PortKind  port_kind 
)
inline

Sets the port's kind indicating whether it is an input or an output.

Definition at line 178 of file UN_PortData.h.

void UN_PortData::setLabel ( UN_PortID  port_id,
const UT_StringRef label 
)
inline

Sets the port's label.

Definition at line 230 of file UN_PortData.h.

void UN_PortData::setName ( UN_PortID  port_id,
const UT_StringRef name 
)
inlineprotected

Sets the port name that identifies it on the node.

Definition at line 202 of file UN_PortData.h.

void UN_PortData::setTags ( UN_PortID  port_id,
const UT_StringArray tags 
)
inline

Sets new tags on a port via copy-assignment.

Definition at line 260 of file UN_PortData.h.

void UN_PortData::setTags ( UN_PortID  port_id,
UT_StringArray &&  tags 
)
inline

Sets new tags on a port via move-assignment.

Definition at line 266 of file UN_PortData.h.

void UN_PortData::setTypeName ( UN_PortID  port_id,
const UT_StringRef type_name 
)
inline

Sets the name of the port's type.

Definition at line 216 of file UN_PortData.h.

UN_PortIDList UN_PortData::sortedPortIDs ( ) const
inline

Returns a list of all the valid port IDs in the graph.

Definition at line 169 of file UN_PortData.h.

template<typename T >
T UN_PortData::stealGenericData ( UN_GenericBufferID  buf_id,
UN_PortID  port_id 
)
inline

Moves the data value out of a generic buffer.

Definition at line 310 of file UN_PortData.h.

UT_StringArray UN_PortData::stealTags ( UN_PortID  port_id)
inline

Returns port's tags moved from the data buffer entry.

Definition at line 278 of file UN_PortData.h.

const UT_StringArray& UN_PortData::tags ( UN_PortID  port_id) const
inline

Returns port's tags.

Definition at line 272 of file UN_PortData.h.

const UT_StringHolder& UN_PortData::typeName ( UN_PortID  port_id) const
inline

Returns the name of the port's type.

Definition at line 224 of file UN_PortData.h.

template<typename T , typename OP >
void UN_PortData::updateGenericData ( UN_GenericBufferID  buf_id,
UN_PortID  port_id,
const OP &  op 
)
inline

Updates the data value in a generic buffer in-place via a callable.

Definition at line 315 of file UN_PortData.h.

template<typename OP >
void UN_PortData::updateTags ( UN_PortID  port_id,
const OP &  op 
)
inline

Updates the port tags in-place. Usage: updateTags(id, [&t](auto &tags) { tags.append(t); });

Definition at line 254 of file UN_PortData.h.

Member Data Documentation

const UT_StringArray UN_PortData::theDefTags
inlinestatic

Definition at line 379 of file UN_PortData.h.

friend UN_PortData::UN_GraphData
protected

This container can have large data, so generally, forbid the costly copy operations to the public. Knowledgable friends and derived classes can still use them.

Definition at line 45 of file UN_PortData.h.


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