12 #ifndef __UN_PortData_h__
13 #define __UN_PortData_h__
75 void merge( UN_PortID port_id,
77 void merge( UN_PortID parm_id,
89 bool include_name =
true )
const;
104 bool removePort( UN_PortID port_id );
108 void removeAllPorts(
bool reset_next_id );
127 {
return UN_PortID( UN_DataIndexMap::IDIterator::operator*() ); }
141 {
return UN_PortID( UN_DataIndexMap::OrderedIDIterator::operator*() ); }
150 return IDRange( id_range.begin(), id_range.end() );
165 return reinterpret_cast<UN_PortIDList&&
>( std::move(
dataIDs() ));
172 return reinterpret_cast<UN_PortIDList&&
>( std::move(
sortedDataIDs() ));
191 auto index = portIndex( port_id );
204 UT_ASSERT( !myCheckValidPortNames || UN_Utils::isValidPortName( name ));
205 setData( myName, port_id, name );
219 || UN_Utils::isValidPortTypeName( type_name ));
220 setData( myTypeName, port_id, type_name );
232 setData( myLabel, port_id, label );
253 template <
typename OP>
262 setData( myTags, port_id, tags );
268 setData( myTags, port_id, std::move(tags) );
274 return getDataRef( myTags, port_id, theDefTags );
280 return stealData( myTags, port_id, theDefTags );
299 UN_PortID port_id )
const
300 {
return UN_Data::genericDataRef<T>( buf_id, port_id ); }
305 {
return UN_Data::genericDataVal<T>( buf_id, port_id ); }
311 {
return UN_Data::stealGenericData<T>( buf_id, port_id ); }
314 template<
typename T,
typename OP>
317 { UN_Data::updateGenericData<T>( buf_id, port_id,
op ); }
322 { myCheckValidPortNames = flag; }
326 { myCheckValidPortTypeNames = flag; }
351 void addCoreData( UN_PortIndex port_index );
354 void clearCoreData( UN_PortIndex port_index );
358 void removeCoreData()
363 void removeAllCoreData();
366 void setCoreDataCapacityIfNeeded(
UN_DataSize min_capacity );
369 bool isCoreDataSizeConsistent(
UN_DataSize expected_size )
const;
370 bool isCoreDataSizeConsistent()
const
371 {
return isCoreDataSizeConsistent( myKind.size() ); }
375 bool isDataSizeConsistent()
const;
383 static constexpr
bool UN_INPUT_PORT =
true;
384 static constexpr
bool UN_OUTPUT_PORT =
false;
385 static constexpr
bool UN_DEFAULT_PORT_KIND =
387 UN_PortData::UN_INPUT_PORT;
403 bool myCheckValidPortNames =
false;
406 bool myCheckValidPortTypeNames =
false;
const UT_StringHolder & typeName(UN_PortID port_id) const
Returns the name of the port's type.
#define SYS_STATIC_ASSERT(expr)
void setName(UN_PortID port_id, const UT_StringRef &name)
Sets the port name that identifies it on the node.
void setTags(UN_PortID port_id, UT_StringArray &&tags)
Sets new tags on a port via move-assignment.
GLuint GLsizei const GLchar * label
UN_PortIDList sortedPortIDs() const
Returns a list of all the valid port IDs in the graph.
UT_StringArray stealTags(UN_PortID port_id)
Returns port's tags moved from the data buffer entry.
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.
GLsizei const GLfloat * value
void setTags(UN_PortID port_id, const UT_StringArray &tags)
Sets new tags on a port via copy-assignment.
bool isValid(UN_DataID data_id) const
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.
value_type operator*() const
const UT_StringHolder & name(UN_PortID port_id) const
Returns the port name that identifies it on the node.
void setTypeName(UN_PortID port_id, const UT_StringRef &type_name)
Sets the name of the port's type.
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
void setCheckValidPortNames(bool flag)
Asserts that the port names are alphanumeric.
Iterator for traversing valid data IDs in the map.
UN_Data & operator=(UN_Data &&)
static const UT_StringArray theDefTags
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
UN_DataIndex dataIndex(UN_DataID id) const
void setCheckValidPortTypeNames(bool flag)
Asserts that the port type names are alphanumeric.
void updateTags(UN_PortID port_id, const OP &op)
V stealData(B &buffer, UN_DataID id, const V &default_value)
Helper method to return a value moved from an entry in the data buffer.
bool isValid(UN_PortID port_id) const
UN_PortKind kind(UN_PortID port_id) const
Returns the port's kind indicating whether it is an input or an output.
const T & genericDataRef(UN_GenericBufferID buf_id, UN_PortID port_id) const
Returns a const ref to the data value in a generic buffer.
Iterator for traversing valid port IDs in an ascending order.
UN_CustomData * customData()
Returns the custom data container, if one was provided.
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.
static const UT_StringHolder theEmptyString
OrderedIDRange orderedIDRange() const
constexpr std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size(){return subtype_count< typename std::tuple_element< I, T >::type >::value+tuple_type_size< T, I+1 >);}template< typename T > struct type_count< T, typename std::enable_if< is_tuple_like< T >::value >::type >{static constexpr int value{tuple_type_size< T, 0 >)};};template< typename T > struct subtype_count{static constexpr int value{is_mutable_container< T >::value?expected_max_vector_size:type_count< T >::value};};template< typename T, typename Enable=void > struct type_count_min{static const int value{0};};template< typename T >struct type_count_min< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_tuple_like< T >::value &&!is_wrapper< T >::value &&!is_complex< T >::value &&!std::is_void< T >::value >::type >{static constexpr int value{type_count< T >::value};};template< typename T > struct type_count_min< T, typename std::enable_if< is_complex< T >::value >::type >{static constexpr int value{1};};template< typename T >struct type_count_min< T, typename std::enable_if< is_wrapper< T >::value &&!is_complex< T >::value &&!is_tuple_like< T >::value >::type >{static constexpr int value{subtype_count_min< typename T::value_type >::value};};template< typename T, std::size_t I >constexpr typename std::enable_if< I==type_count_base< T >::value, int >::type tuple_type_size_min(){return 0;}template< typename T, std::size_t I > constexpr typename std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size_min(){return subtype_count_min< typename std::tuple_element< I, T >::type >::value+tuple_type_size_min< T, I+1 >);}template< typename T > struct type_count_min< T, typename std::enable_if< is_tuple_like< T >::value >::type >{static constexpr int value{tuple_type_size_min< T, 0 >)};};template< typename T > struct subtype_count_min{static constexpr int value{is_mutable_container< T >::value?((type_count< T >::value< expected_max_vector_size)?type_count< T >::value:0):type_count_min< T >::value};};template< typename T, typename Enable=void > struct expected_count{static const int value{0};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_wrapper< T >::value &&!std::is_void< T >::value >::type >{static constexpr int value{1};};template< typename T > struct expected_count< T, typename std::enable_if< is_mutable_container< T >::value >::type >{static constexpr int value{expected_max_vector_size};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&is_wrapper< T >::value >::type >{static constexpr int value{expected_count< typename T::value_type >::value};};enum class object_category:int{char_value=1, integral_value=2, unsigned_integral=4, enumeration=6, boolean_value=8, floating_point=10, number_constructible=12, double_constructible=14, integer_constructible=16, string_assignable=23, string_constructible=24, other=45, wrapper_value=50, complex_number=60, tuple_value=70, container_value=80,};template< typename T, typename Enable=void > struct classify_object{static constexpr object_category value{object_category::other};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, char >::value &&std::is_signed< T >::value &&!is_bool< T >::value &&!std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::integral_value};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value &&!std::is_same< T, char >::value &&!is_bool< T >::value >::type >{static constexpr object_category value{object_category::unsigned_integral};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_same< T, char >::value &&!std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::char_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_bool< T >::value >::type >{static constexpr object_category value{object_category::boolean_value};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_floating_point< T >::value >::type >{static constexpr object_category value{object_category::floating_point};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&std::is_assignable< T &, std::string >::value >::type >{static constexpr object_category value{object_category::string_assignable};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&(type_count< T >::value==1)&&std::is_constructible< T, std::string >::value >::type >{static constexpr object_category value{object_category::string_constructible};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::enumeration};};template< typename T > struct classify_object< T, typename std::enable_if< is_complex< T >::value >::type >{static constexpr object_category value{object_category::complex_number};};template< typename T > struct uncommon_type{using type=typename std::conditional<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&!std::is_constructible< T, std::string >::value &&!is_complex< T >::value &&!is_mutable_container< T >::value &&!std::is_enum< T >::value, std::true_type, std::false_type >::type;static constexpr bool value=type::value;};template< typename T >struct classify_object< T, typename std::enable_if<(!is_mutable_container< T >::value &&is_wrapper< T >::value &&!is_tuple_like< T >::value &&uncommon_type< T >::value)>::type >{static constexpr object_category value{object_category::wrapper_value};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::number_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&!is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::integer_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::double_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< is_tuple_like< T >::value &&((type_count< T >::value >=2 &&!is_wrapper< T >::value)||(uncommon_type< T >::value &&!is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value)||(uncommon_type< T >::value &&type_count< T >::value >=2))>::type >{static constexpr object_category value{object_category::tuple_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_mutable_container< T >::value >::type >{static constexpr object_category value{object_category::container_value};};template< typename T, enable_if_t< classify_object< T >::value==object_category::char_value, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"CHAR";}template< typename T, enable_if_t< classify_object< T >::value==object_category::integral_value||classify_object< T >::value==object_category::integer_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"INT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::unsigned_integral, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"UINT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::floating_point||classify_object< T >::value==object_category::number_constructible||classify_object< T >::value==object_category::double_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"FLOAT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::enumeration, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"ENUM";}template< typename T, enable_if_t< classify_object< T >::value==object_category::boolean_value, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"BOOLEAN";}template< typename T, enable_if_t< classify_object< T >::value==object_category::complex_number, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"COMPLEX";}template< typename T, enable_if_t< classify_object< T >::value >=object_category::string_assignable &&classify_object< T >::value<=object_category::other, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"TEXT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::container_value||classify_object< T >::value==object_category::wrapper_value, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value==1, detail::enabler >=detail::dummy >inline std::string type_name(){return type_name< typename std::decay< typename std::tuple_element< 0, T >::type >::type >);}template< typename T, std::size_t I >inline typename std::enable_if< I==type_count_base< T >::value, std::string >::type tuple_name(){return std::string{};}template< typename T, std::size_t I >inline typename std::enable_if<(I< type_count_base< T >::value), std::string >::type tuple_name(){auto str=std::string{type_name< typename std::decay< typename std::tuple_element< I, T >::type >::type >)}+ ','+tuple_name< T, I+1 >);if(str.back()== ',') str.pop_back();return str;}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler > > std::string type_name()
Recursively generate the tuple type name.
T stealGenericData(UN_GenericBufferID buf_id, UN_PortID port_id)
Moves the data value out of a generic buffer.
UNI_PortKind
Specifies the port kind, ie, wheter it is an input or an output port.
UN_DataIDList dataIDs() const
Returns a list of all the valid IDs in this container.
void setLabel(UN_PortID port_id, const UT_StringRef &label)
Sets the port's label.
Data buffer specialization for boolean (bit) values.
UN_CustomPortData * customPortData()
Returns port's custom data container, if one was provided.
GLuint const GLchar * name
UN_DataIndexMap::IDRange IDRange
Returns a range for iterating valid IDs.
void updateData(B &buffer, UN_DataID id, const OP &op)
Maintains a mapping from data ID to data index in the data buffer.
void setGenericData(UN_GenericBufferID buf_id, UN_PortID port_id, T &&value)
Sets the data value in a generic buffer via move.
A map of string to various well defined value types.
OrderedIDIterator(const UN_DataIndexMap::OrderedIDIterator &id_iterator)
Iterator for traversing valid data IDs in the map in an ordered fashion.
IDIterator(const UN_DataIndexMap::IDIterator &id_iterator)
UT_UniquePtr< UN_CustomPortData > UN_CustomPortDataPtr
T genericDataVal(UN_GenericBufferID buf_id, UN_PortID port_id) const
Returns a copy of a data value from a generic buffer.
void setData(B &buffer, UN_DataID id, const V &value)
Helper method to copy-assign the value to an entry in the data buffer.
UN_PortIDList portIDs() const
Returns a list of all the valid port IDs in the graph.
const UT_StringArray & tags(UN_PortID port_id) const
Returns port's tags.
UN_PortIndex portIndex(UN_PortID id) const
Returns the port's data index into the data buffer arrays.
value_type operator*() const
UN_DataSize size() const
Returns the number of valid data items in the buffer.
UN_DataIDList sortedDataIDs() const
Returns a sorted list of all the valid IDs in this container.
const UT_StringHolder & label(UN_PortID port_id) const
Returns the port's label.
UN_DataIndexMap::OrderedIDRange OrderedIDRange
Returns a range for iterating valid IDs in an ascending order.
const UN_CustomPortData * customPortData() const
Returns port's custom data container, if one was provided.
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.
void setKind(UN_PortID port_id, UN_PortKind port_kind)
Sets the port's kind indicating whether it is an input or an output.
OrderedIDRange orderedIDRange() const
UT_UniquePtr< UN_Options > UN_OptionsPtr
Iterator for traversing valid port IDs.