12 #ifndef __UN_Include_h__
13 #define __UN_Include_h__
59 constexpr
explicit operator bool()
const
87 {
return myValue == other.myValue; }
89 {
return myValue != other.myValue; }
91 {
return myValue < other.myValue; }
93 {
return myValue <= other.myValue; }
95 {
return myValue > other.myValue; }
97 {
return myValue >= other.myValue; }
211 : myStart(start), mySize(size)
229 #define UN_DATA_INDEX(Class) \
230 class Class : public UN_DataIndex \
233 explicit Class( UN_DataIndex data_index = UN_DataIndex() ) \
234 : UN_DataIndex( data_index ) {} \
237 using Class##List = UT_Array< Class >; \
267 #define UN_DATA_ID( SubClass, BaseClass ) \
268 using SubClass = BaseClass; \
269 using SubClass##List = BaseClass##List; \
270 using SubClass##Remap = UN_DataIDRemapT< SubClass >; \
278 UN_DATA_ID( UN_StickyNoteID,UNI_StickyNoteID )
283 template <typename HANDLE, typename GRAPH_DATA, typename ID_RANGE>
285 UNhandleArray( GRAPH_DATA *graph_data, const ID_RANGE &data_ids )
289 for(
auto &&data_id : data_ids )
290 result.append( HANDLE( graph_data, data_id ));
301 static constexpr UN_DataID UN_ID_ZERO(
UN_DataID(0) );
302 static constexpr UN_NodeID UN_ROOT_NODE_ID( UN_ID_ZERO );
303 static constexpr UN_SubnetID UN_ROOT_SUBNET_ID( UN_ID_ZERO );
306 static inline bool UNisRoot( UN_NodeID node_id )
307 {
return node_id == UN_ROOT_NODE_ID; }
308 static inline bool UNisRoot( UN_SubnetID subnet_id )
309 {
return subnet_id == UN_ROOT_SUBNET_ID; }
336 UN_DataID new_id_start,
337 bool combine_id_zero =
false )
338 : myNewStartID( new_id_start.exintValue() )
339 , myShouldCombineIDZero( combine_id_zero )
340 , myOldEndID( old_id_end.exintValue() )
348 {
return myNewStartID; }
352 {
return myOldEndID; }
362 {
return myNewStartID.
isValid(); }
373 else if( myShouldCombineIDZero && old_id == UN_ID_ZERO )
377 - (myShouldCombineIDZero ? 1 : 0) );
384 - (myShouldCombineIDZero ? 1 : 0) );
394 UN_DataID old_offset, UN_DataID new_offset )
402 UN_DataID myNewStartID;
411 bool myShouldCombineIDZero =
false;
414 UN_DataID myOldEndID;
419 template <
typename ID>
433 bool combine_id_zero =
false )
441 {
return ID(UN_DataIDRemap::operator[]( old_id )); }
444 ID
at( ID old_id )
const
457 : myDataIDRemap( std::move( data_id_remap ))
458 , myDataIndexSpans( std::move( data_idx_spans ))
463 {
return myDataIndexSpans; }
468 {
return myDataIDRemap; }
489 UN_NodeID root_destination_node,
490 UN_NodeIDRemap &&node_id_remap,
491 UN_SubnetIDRemap &&subnet_id_remap,
492 UN_PortIDRemap &&port_id_remap,
493 UN_WireIDRemap &&wire_id_remap,
494 UN_StickyNoteIDRemap &&sticky_note_id_remap )
495 : myRootDstNode( root_destination_node )
496 , myNodeIDRemap( std::move(node_id_remap) )
497 , mySubnetIDRemap( std::move(subnet_id_remap) )
498 , myPortIDRemap( std::move(port_id_remap) )
499 , myWireIDRemap( std::move(wire_id_remap) )
500 , myStickyNoteIDRemap( std::move(sticky_note_id_remap) )
509 const UN_NodeIDRemap &
nodeIDRemap()
const {
return myNodeIDRemap; }
511 const UN_PortIDRemap &
portIDRemap()
const {
return myPortIDRemap; }
512 const UN_WireIDRemap &
wireIDRemap()
const {
return myWireIDRemap; }
514 {
return myStickyNoteIDRemap; }
521 UN_NodeID myRootDstNode;
524 UN_NodeIDRemap myNodeIDRemap;
525 UN_SubnetIDRemap mySubnetIDRemap;
526 UN_PortIDRemap myPortIDRemap;
527 UN_WireIDRemap myWireIDRemap;
528 UN_StickyNoteIDRemap myStickyNoteIDRemap;
538 : myIDRemapInfo( std::move( id_remap_info ))
543 {
return myIDRemapInfo; }
551 #define UN_NUMBER_FORMATTER(IdOrIndexType) \
553 UTformatBuffer(char *buffer, size_t buffer_size, const IdOrIndexType &v) \
555 UT::Format::Writer w(buffer, buffer_size); \
556 UT::Format::Formatter f; \
557 return f.format(w, #IdOrIndexType "({})", {v.exintValue()}); \
560 UTformatBuffer(char *buffer, size_t buffer_size, \
561 const UT_Array<IdOrIndexType> &v) \
563 UT::Format::Writer w(buffer, buffer_size); \
564 UT::Format::Formatter f; \
565 size_t bytesWritten = w("UT_Array<" #IdOrIndexType ">([", \
566 sizeof("UT_Array<" #IdOrIndexType ">([")-1); \
568 for (auto &&item : v) \
570 bytesWritten += f.format(w, first ? "{}" : ", {}", \
571 {item.exintValue()}); \
574 bytesWritten += w("])", 2); \
575 return bytesWritten; \
594 template <
typename T>
struct DefaultClearer;
602 static const bool clearNeedsDestruction =
false;
605 #define UN_INDEX_CLEARER(ID) \
606 template<> struct DefaultClearer<ID>: public DefaultClearer<UN_DataIndex>{};
622 static constexpr
UT_StringLit UN_UNDEFINED_PORT_TYPE_NAME;
626 static constexpr
UT_StringLit UN_UNDEFINED_PARM_TYPE_NAME;
631 {
return type_name.isstring(); }
constexpr exint exintValue() const
Returns an exint value of this number.
UN_DataIndex operator+(UN_DataSize offset)
Some arithmetic operators that make sense on indices.
const UN_IDRemapInfo & idRemapInfo()
Returns the object that contains mapping between data IDs after merge.
#define SYS_STATIC_ASSERT(expr)
UN_IDRemapInfo(UN_NodeID root_destination_node, UN_NodeIDRemap &&node_id_remap, UN_SubnetIDRemap &&subnet_id_remap, UN_PortIDRemap &&port_id_remap, UN_WireIDRemap &&wire_id_remap, UN_StickyNoteIDRemap &&sticky_note_id_remap)
static bool isClear(const UN_DataIndex &v)
void clear()
Resets the index to an invalid value.
UN_DataIndexSpan(UN_DataIndex start, UN_DataSize size)
Construct the data index span range object given.
UN_DataIDRemap(UN_DataID old_id_end, UN_DataID new_id_start, bool combine_id_zero=false)
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
constexpr size_t SYShash(const SYS_Flicks f)
UN_DataIndex operator-(UN_DataSize offset)
Some arithmetic operators that make sense on indices.
UN_GraphMergeInfo()=default
Constructors.
UN_DataNumber & operator++()
Basic arithmetic operators.
UN_DataIndex(ValueType value=INVALID_NUMBER)
Constructs the index object given the numerical value.
GLsizei const GLfloat * value
const UN_SubnetIDRemap & subnetIDRemap() const
UN_DataIndex operator-=(UN_DataSize offset)
Some arithmetic operators that make sense on indices.
friend size_t hash_value(const UN_DataNumber &data_number)
Hash function for use of UN_DataNumber as a key in the UT_Map class.
static void clearConstruct(UN_DataIndex *p)
UN_NodeID rootDstNode() const
UN_DataIndex operator+=(UN_DataSize offset)
Some arithmetic operators that make sense on indices.
UN_DataIndex start() const
Returns the first index in the range.
#define UN_NUMBER_FORMATTER(IdOrIndexType)
For debug printouts, etc:
constexpr bool operator!=(const UN_DataNumber &other) const
Comparison operators.
constexpr bool operator>=(const UN_DataNumber &other) const
Comparison operators.
UN_DataIDRemapT(ID old_id_end, ID new_id_start, bool combine_id_zero=false)
Convenience constructor. See UN_DataIDRemap.
Adaptor of the UN_DataIDRemap to specific data types.
**But if you need a result
#define UN_INDEX_CLEARER(ID)
UN_DataID nextDataID() const
Returns the data ID that should be used for the data created next time.
static UN_DataID remapIDFromOffsets(UN_DataID old_id, UN_DataID old_offset, UN_DataID new_offset)
const UN_DataIDRemap & dataIDRemap() const
UN_IDRemapInfo()=default
Constructors.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
#define UN_DATA_INDEX(Class)
Package of remappings for various data ID types (nodes, ports, subnets).
ID operator[](ID old_id) const
#define UN_DATA_ID(SubClass, BaseClass)
UN_DataIDRemap()=default
Default constructor.
UN_DataNumber operator++(int)
Basic arithmetic operators.
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.
const UT_Array< UN_DataIndexSpan > & dataIndexSpans() const
Returns the continous index ranges that can be block-copied.
const UN_WireIDRemap & wireIDRemap() const
UNI_PortKind
Specifies the port kind, ie, wheter it is an input or an output port.
UN_DataIDRemapT()=default
Default constructor.
constexpr bool isValid() const
Returns true if this data number is valid; false otherwise.
UN_DataMergeInfo(UN_DataIDRemap &&data_id_remap, UT_Array< UN_DataIndexSpan > &&data_idx_spans)
Constructor.
constexpr UN_DataNumber(ValueType value=INVALID_NUMBER)
static void clear(UN_DataIndex &v)
constexpr bool operator==(const UN_DataNumber &other) const
Comparison operators.
UN_DataID newStartOffset() const
UN_DataID oldEndOffset() const
Returns the limit for the old IDs source range.
UN_GraphMergeInfo(UN_IDRemapInfo &&id_remap_info)
constexpr bool operator<(const UN_DataNumber &other) const
Comparison operators.
A map of string to various well defined value types.
const UN_NodeIDRemap & nodeIDRemap() const
const UN_PortIDRemap & portIDRemap() const
const UN_StickyNoteIDRemap & stickyNoteIDRemap() const
Information about the result of a merge from another graph.
static constexpr ValueType INVALID_NUMBER
constexpr bool isValid() const
Returns true if this ID is valid; false otherwise.
UN_DataIndex(UN_DataSize size)
For past-end array index.
constexpr bool operator<=(const UN_DataNumber &other) const
Comparison operators.
constexpr exint exintValue() const
Returns an exint value of this ID.
UN_DataIndex(exint value)
constexpr bool operator>(const UN_DataNumber &other) const
Comparison operators.
UN_DataSize size() const
Returns the number of IDs reserved by this merge map.
void setValue(ValueType value)
Sets the numerical value of this number.
constexpr ValueType value() const
Returns the numerical value of this number.
UN_DataID operator[](UN_DataID old_id) const
UN_DataIDRemapT(const UN_DataIDRemap &remap_base)
Convenience constructor that takes an instance of the base class.
UN_DataSize(ValueType value=ValueType(0))
Constructs the size object given the numerical value.
UT_UniquePtr< UN_Options > UN_OptionsPtr
UN_DataSize size() const
Returns the number of indices in the range.