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 >; \
258 : UN_DataNumber(
value ) {}
262 : UN_DataNumber( static_cast<
ValueType>( value ))
268 {
return exintValue(); }
286 #define UN_DATA_ID( Class ) \
287 class Class : public UN_DataID \
290 constexpr explicit Class( UN_DataID data_id = UN_DataID() ) \
291 : UN_DataID( data_id ) {} \
294 using Class##List = UT_Array< Class >; \
295 using Class##Remap = UN_DataIDRemapT< Class >; \
310 static constexpr UN_NodeID UN_ROOT_NODE_ID( UN_ID_ZERO );
311 static constexpr UN_SubnetID UN_ROOT_SUBNET_ID( UN_ID_ZERO );
314 static inline
bool UNisRoot( UN_NodeID node_id )
315 {
return node_id == UN_ROOT_NODE_ID; }
316 static inline bool UNisRoot( UN_SubnetID subnet_id )
317 {
return subnet_id == UN_ROOT_SUBNET_ID; }
345 bool combine_id_zero =
false )
346 : myNewStartID( new_id_start.exintValue() )
347 , myShouldCombineIDZero( combine_id_zero )
348 , myOldEndID( old_id_end.exintValue() )
356 {
return myNewStartID; }
360 {
return myOldEndID; }
370 {
return myNewStartID.
isValid(); }
379 else if( old_id >= myOldEndID )
381 else if( myShouldCombineIDZero && old_id == UN_ID_ZERO )
385 - (myShouldCombineIDZero ? 1 : 0) );
392 - (myShouldCombineIDZero ? 1 : 0) );
419 bool myShouldCombineIDZero =
false;
427 template <
typename ID>
441 bool combine_id_zero =
false )
449 {
return ID(UN_DataIDRemap::operator[]( old_id )); }
452 ID
at( ID old_id )
const
465 : myDataIDRemap( std::move( data_id_remap ))
466 , myDataIndexSpans( std::move( data_idx_spans ))
471 {
return myDataIndexSpans; }
476 {
return myDataIDRemap; }
497 UN_NodeID root_destination_node,
498 UN_NodeIDRemap &&node_id_remap,
499 UN_SubnetIDRemap &&subnet_id_remap,
500 UN_PortIDRemap &&port_id_remap,
501 UN_PortIDRemap &&wire_id_remap )
502 : myRootDstNode( root_destination_node )
503 , myNodeIDRemap( std::move(node_id_remap) )
504 , mySubnetIDRemap( std::move(subnet_id_remap) )
505 , myPortIDRemap( std::move(port_id_remap) )
506 , myWireIDRemap( std::move(wire_id_remap) )
515 const UN_NodeIDRemap &
nodeIDRemap()
const {
return myNodeIDRemap; }
517 const UN_PortIDRemap &
portIDRemap()
const {
return myPortIDRemap; }
518 const UN_WireIDRemap &
wireIDRemap()
const {
return myWireIDRemap; }
525 UN_NodeID myRootDstNode;
528 UN_NodeIDRemap myNodeIDRemap;
529 UN_SubnetIDRemap mySubnetIDRemap;
530 UN_PortIDRemap myPortIDRemap;
531 UN_WireIDRemap myWireIDRemap;
541 : myIDRemapInfo( std::move( id_remap_info ))
546 {
return myIDRemapInfo; }
554 #define UN_NUMBER_FORMATTER(IdOrIndexType) \
555 inline size_t format(char *buffer, size_t buffer_size, const IdOrIndexType &v) \
557 UT::Format::Writer w(buffer, buffer_size); \
558 UT::Format::Formatter f; \
559 return f.format(w, #IdOrIndexType "({})", {v.exintValue()}); \
561 inline size_t format(char *buffer, size_t buffer_size, \
562 const UT_Array<IdOrIndexType> &v) \
564 UT::Format::Writer w(buffer, buffer_size); \
565 UT::Format::Formatter f; \
566 size_t bytesWritten = w("UT_Array<" #IdOrIndexType ">([", \
567 sizeof("UT_Array<" #IdOrIndexType ">([")-1); \
569 for (auto &&item : v) \
571 bytesWritten += f.format(w, first ? "{}" : ", {}", \
572 {item.exintValue()}); \
575 bytesWritten += w("])", 2); \
576 return bytesWritten; \
602 template <
typename T>
struct DefaultClearer;
611 static const bool clearNeedsDestruction =
false;
614 #define UN_ID_CLEARER(ID) \
615 template <> struct DefaultClearer<ID> : public DefaultClearer<UN_DataID> {};
630 static const bool clearNeedsDestruction =
false;
633 #define UN_INDEX_CLEARER(ID) \
634 template<> struct DefaultClearer<ID>: public DefaultClearer<UN_DataIndex>{};
655 static constexpr
UT_StringLit UN_UNDEFINED_PORT_TYPE_NAME;
659 static constexpr
UT_StringLit UN_UNDEFINED_PARM_TYPE_NAME;
constexpr exint exintValue() const
Returns an exint value of this number.
constexpr UN_DataID(exint value)
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)
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.
__hostdev__ void setValue(uint32_t offset, bool v)
#define UN_INDEX_CLEARER(ID)
UN_DataID nextDataID() const
Returns the data ID that should be used for the data created next time.
constexpr UN_DataID(ValueType value=INVALID_NUMBER)
Constructs the ID object given the numerical value.
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.
static void clearConstruct(UN_DataID *p)
#define UN_DATA_INDEX(Class)
UN_PortKind
Differentiates between input and output ports.
static bool isClear(const UN_DataID &v)
Package of remappings for various data ID types (nodes, ports, subnets).
ID operator[](ID old_id) const
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
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)
#define UN_ID_CLEARER(ID)
static void clear(UN_DataIndex &v)
static void clear(UN_DataID &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
Information about the result of a merge from another graph.
static constexpr ValueType INVALID_NUMBER
UN_DataIndex(UN_DataSize size)
For past-end array index.
constexpr bool operator<=(const UN_DataNumber &other) const
Comparison operators.
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.
#define UN_DATA_ID(Class)
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_IDRemapInfo(UN_NodeID root_destination_node, UN_NodeIDRemap &&node_id_remap, UN_SubnetIDRemap &&subnet_id_remap, UN_PortIDRemap &&port_id_remap, UN_PortIDRemap &&wire_id_remap)
void clear()
Resets the ID to an invalid value.
SYS_FORCE_INLINE bool isstring() const
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.