HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_NodeData.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UN_NodeData.h ( UN Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UN_NodeData_h__
13 #define __UN_NodeData_h__
14 
15 #include "UN_API.h"
16 #include "UN_Data.h"
17 #include "UN_Utils.h"
18 #include <UT/UT_Color.h>
19 class UN_GraphData;
20 class UN_NodeData;
21 
22 // ============================================================================
25 
26 /// Convenience typedef for a generic data buffer reference on node data.
29 
30 // ============================================================================
31 /// Container of data for all the nodes in the graph.
32 ///
33 /// NOTE: This class is generally not trivially relocatable, because
34 /// its base class (UN_Data) is not trivially relocatable (see comment there).
35 
36 class UN_API UN_NodeData : public UN_Data
37 {
38 public:
39  /// Constructors and destructors.
41  ~UN_NodeData() = default;
42 
45 
46 protected:
47  /// This container can have large data, so generally, forbid
48  /// the costly copy operations to the public.
49  /// Knowledgable friends and derived classes can still use them.
50  friend UN_GraphData;
51  UN_NodeData(const UN_NodeData &) = default;
52  UN_NodeData & operator=(const UN_NodeData &) = default;
53 
54 public:
55  /// Increases the capacity of the data buffer arrays to the given minimum,
56  /// unless the capacity is already greater or equal to that minimum,
57  /// in which case the capacity remains unchanged.
58  void setCapacityIfNeeded(UN_DataSize min_capacity);
59 
60  /// @{ Returns node's custom data container, if one was provided.
62  {
64  }
65 
67  {
68  return UTverify_cast<const UN_CustomNodeData*>( customData() );
69  }
70  /// @}
71 
72  /// Merges another node data container into this one.
73  /// Returns a mapping between the data IDs in the merge source
74  /// and destination (this) data buffers.
75  UN_NodeIDRemap merge( const UN_NodeData &src_node_data );
76 
77  /// Sets the attributes of the node, based on the information given in
78  /// the options dictionary. Leaves other attributes of this node intact.
79  void merge( UN_NodeID node_id,
80  const UN_Options &node_opts );
81 
82  /// Returns the options object representing node's properties,
83  /// such as name, type, category, and also parameters and ports, but
84  /// not the children.
85  /// This can be then used for serialization to JSON, etc.
86  UN_OptionsPtr asOptions( UN_NodeID node_id ) const;
87 
88 
89  /// Adds a slot for a new node in this container.
90  /// Returns an ID that should be used to refer to this new node
91  /// for accessing its data (eg, name, label, etc).
92  UN_NodeID addNode();
93 
94  /// Adds a root node to the container, or returns one if it already exists.
95  UN_NodeID findOrAddRootNode();
96 
97 protected:
98  // These methods require careful coodrination with other nodes,
99  // or with a root node. Only UN_GraphData knows how to do that correctly.
100  friend UN_GraphData;
101 
102  /// Clears the data for the given node to the default state.
103  void clearNode( UN_NodeID node_id );
104 
105  /// Removes the node from this container and frees the
106  /// data slot it occupied. After calling this method,
107  /// the container will have no knowledge of the node by this ID.
108  /// Returns true on successs; false if the node was not found.
109  bool removeNode( UN_NodeID node_id );
110 
111  /// Frees the data slots occupied by all the nodes.
112  /// @param 'reset_next_id' If true, the node ID generator is reset to zero.
113  void removeAllNodes( bool reset_next_id );
114 
115 public:
116  /// Returns true if the given ID refers to a valid node entry
117  /// in the data buffers. Ie, such a node exists and is valid.
118  bool isValid( UN_NodeID node_id ) const
119  { return UN_Data::isValid( node_id ); }
120 
121 
122  /// Iterator for traversing valid node IDs.
124  {
125  public:
126  using value_type = UN_NodeID;
127 
129  : UN_DataIndexMap::IDIterator( id_iterator )
130  {}
131 
133  { return UN_NodeID( UN_DataIndexMap::IDIterator::operator*() ); }
134  };
135 
136  /// Iterator for traversing valid node IDs in an ascending order.
138  {
139  public:
140  using value_type = UN_NodeID;
141 
143  : UN_DataIndexMap::OrderedIDIterator( id_iterator )
144  {}
145 
147  { return UN_NodeID( UN_DataIndexMap::OrderedIDIterator::operator*() ); }
148  };
149 
150 
151  /// Returns a range for iterating valid node IDs.
152  /// Does not include the root node.
154  IDRange idRange() const;
155 
156  /// Returns a range for iterating valid node IDs.
157  /// Does not include the root node.
160 
161  /// Returns a list of all the valid node IDs in the graph.
162  /// Does not include the root node.
163  UN_NodeIDList nodeIDs() const
164  {
165  SYS_STATIC_ASSERT( sizeof(UN_NodeID) == sizeof(UN_DataID) );
166  auto node_ids =
167  reinterpret_cast<UN_NodeIDList&&>( std::move( dataIDs() ));
168  node_ids.findAndRemove( UN_ROOT_NODE_ID );
169  return node_ids;
170  }
171 
172  /// Returns a list of all the valid node IDs in the graph.
173  /// Does not include the root node.
174  UN_NodeIDList sortedNodeIDs() const
175  {
176  SYS_STATIC_ASSERT( sizeof(UN_NodeID) == sizeof(UN_DataID) );
177  auto node_ids =
178  reinterpret_cast<UN_NodeIDList&&>( std::move( sortedDataIDs() ));
179  node_ids.findAndRemove( UN_ROOT_NODE_ID );
180  return node_ids;
181  }
182 
183 protected:
184  /// Sets the node name that differentiates it among its siblings.
185  /// Only the friend UN_GraphData can call it because it may need to
186  /// enforce a unique node name.
187  void setName( UN_NodeID node_id, const UT_StringRef &name )
188  {
189  UT_ASSERT( !myCheckValidNodeNames
190  || UN_Utils::isValidNodeName( name, myNodeNameSafeChars ));
191  setData( myName, node_id, name );
192  }
193 
194  /// Sets the node's category that groups it with other nodes
195  /// that are operationally compatible (and connectable).
196  /// Only the friend UN_GraphData can call it because it makes little
197  /// sense to change the category of a node without also changing the
198  /// node type, the parent child type categories, and other aspects
199  /// of the graph.
200  void setCategoryName( UN_NodeID node_id, const UT_StringRef &category_name )
201  {
202  UT_ASSERT( UN_Utils::isValidCategoryName( category_name ));
203  setData( myCategoryName, node_id, category_name );
204  }
205 
206  /// Sets the node's signature.
207  /// Node signature determines node inputs and outputs, and their types.
208  void setSignatureName(UN_NodeID node_id, const UT_StringRef &signature_name)
209  {
210  setData( mySignatureName, node_id, signature_name );
211  }
212 
213 
214 public:
215  /// Returns the name that identifies the node among its siblings.
216  const UT_StringHolder & name( UN_NodeID node_id ) const
217  {
218  return getDataRef( myName, node_id, UT_StringHolder::theEmptyString );
219  }
220 
221 
222  /// Sets the node's type that determines its functional behavour.
223  void setTypeName( UN_NodeID node_id, const UT_StringRef &type_name )
224  {
225  setData( myTypeName, node_id, type_name );
226  }
227 
228  /// Returns the name of node's type that determines its functional behavour.
229  const UT_StringHolder & typeName( UN_NodeID node_id ) const
230  {
231  return getDataRef(myTypeName, node_id, UT_StringHolder::theEmptyString);
232  }
233 
234  /// Returns the node's category that groups it with other nodes
235  /// that are operationally compatible (and connectable).
236  const UT_StringHolder & categoryName( UN_NodeID node_id ) const
237  {
238  return getDataRef( myCategoryName, node_id,
240  }
241 
242  /// Returns the node's signature.
243  const UT_StringHolder & signatureName( UN_NodeID node_id ) const
244  {
245  return getDataRef( mySignatureName, node_id, theDefSignatureName );
246  }
247 
248  /// Sets the node's comment.
249  void setComment( UN_NodeID node_id, const UT_StringRef &comment )
250  {
251  setData( myComment, node_id, comment );
252  }
253 
254  /// Returns the node's comment.
255  const UT_StringHolder & comment( UN_NodeID node_id ) const
256  {
257  return getDataRef( myComment, node_id, theDefComment );
258  }
259 
260  /// Sets the node's location in the graph editor.
261  void setPosition( UN_NodeID node_id, const UT_Vector2D &position )
262  {
263  setData( myPosition, node_id, position );
264  }
265 
266  /// Returns the node's location in the graph editor.
267  const UT_Vector2D & position( UN_NodeID node_id ) const
268  {
269  return getDataRef( myPosition, node_id, theDefPos );
270  }
271 
272  /// Sets the node's color in the graph editor.
273  void setColor( UN_NodeID node_id, const UT_Color &color )
274  {
275  setData( myColor, node_id, color );
276  }
277 
278  /// Returns the node's color in the graph editor.
279  const UT_Color & color( UN_NodeID node_id ) const
280  {
281  return getDataRef( myColor, node_id, theDefColor );
282  }
283 
284  // TODO: FIXME: consider refactoring buffers into UN-friendly objects
285  // for reuse. Eg UN_StringArrayBuffer, wchich would have
286  // set(), get(), steal(), and update(). Then UN_NodeData class
287  // would just return that buffer object.
288  // The calls would loo like node_data.tags().set(id, val);
289  //
290  // Another variation would be to return a data entry handle
291  // that has set(), get(), steal(), and update() methods.
292  // node_data.tags(id).set(val).
293 
294  /// Updates the node tags in-place.
295  /// Usage: updateTags(id, [&t](auto &tags) { tags.append(t); });
296  template <typename OP>
297  void updateTags( UN_NodeID node_id, const OP &op )
298  {
299  updateData( myTags, node_id, op );
300  }
301 
302  /// Sets new tags on a node via copy-assignment.
303  void setTags( UN_NodeID node_id, const UT_StringArray &tags )
304  {
305  setData( myTags, node_id, tags );
306  }
307 
308  /// Sets new tags on a node via move-assignment.
309  void setTags( UN_NodeID node_id, UT_StringArray &&tags )
310  {
311  setData( myTags, node_id, std::move(tags) );
312  }
313 
314  /// Returns node tags.
315  const UT_StringArray & tags( UN_NodeID node_id ) const
316  {
317  return getDataRef( myTags, node_id, theDefTags );
318  }
319 
320  /// Returns node tags moved from the data buffer entry.
321  UT_StringArray stealTags( UN_NodeID node_id )
322  {
323  return stealData( myTags, node_id, theDefTags );
324  }
325 
326  /// Updates node tags in-place.
327  /// Usage: updateMetadata(id, [&k, &v](auto &m) { m[k] = v); });
328  template <typename OP>
329  void updateMetadata( UN_NodeID node_id, const OP &op )
330  {
331  updateData( myMetadata, node_id, op );
332  }
333 
334  /// Simpler method to update a single metadata value in-place.
335  void updateMetadata( UN_NodeID node_id,
336  const UT_StringHolder &key,
338  {
339  updateData(myMetadata, node_id, [&key, &value](UT_OptionsHolder &m)
340  {
341  m.update( [&key, &value](UT_Options &options)
342  {
343  options.setOption(key, std::move(value));
344  });
345  });
346  }
347 
348  /// Sets node's new metadata via copy-assignment.
349  void setMetadata( UN_NodeID node_id, const UN_MetadataHolder &metadata )
350  {
351  setData( myMetadata, node_id, metadata );
352  }
353 
354  /// Sets node's new metadata via move-assignment.
355  void setMetadata( UN_NodeID node_id, UN_MetadataHolder &&metadata )
356  {
357  setData( myMetadata, node_id, std::move(metadata) );
358  }
359 
360  /// Returns nodes's metadata.
361  const UN_MetadataHolder & metadata( UN_NodeID node_id ) const
362  {
363  return getDataRef( myMetadata, node_id, theDefMetadata );
364  }
365 
366  /// Returns node's metadata moved from the data buffer entry.
367  UN_MetadataHolder stealMetadata( UN_NodeID node_id )
368  {
369  return stealData( myMetadata, node_id, theDefMetadata );
370  }
371 
372 
373  /// Adds a new named generic data buffer and returns a lightweight
374  /// reference that bundles the buffer ID with this container.
375  template<typename D>
379  const D &default_value )
380  {
381  return { *this, addGenericBuffer(name, type, default_value) };
382  }
383 
384  /// Sets the data value in a generic buffer for a given node.
385  template<typename T>
386  void setGenericData( UN_GenericBufferID buf_id, UN_NodeID node_id,
387  const T &value )
388  { UN_Data::setGenericData( buf_id, node_id, value ); }
389 
390  /// Sets the data value in a generic buffer via move.
391  template<typename T>
392  void setGenericData( UN_GenericBufferID buf_id, UN_NodeID node_id,
393  T &&value )
394  { UN_Data::setGenericData( buf_id, node_id, std::forward<T>(value) ); }
395 
396  /// Returns a const ref to the data value in a generic buffer.
397  template<typename T>
399  UN_NodeID node_id ) const
400  { return UN_Data::genericDataRef<T>( buf_id, node_id ); }
401 
402  /// Returns a copy of a data value from a generic buffer.
403  template<typename T>
404  T genericDataVal( UN_GenericBufferID buf_id, UN_NodeID node_id ) const
405  { return UN_Data::genericDataVal<T>( buf_id, node_id ); }
406 
407 
408  /// Moves the data value out of a generic buffer.
409  template<typename T>
410  T stealGenericData( UN_GenericBufferID buf_id, UN_NodeID node_id )
411  { return UN_Data::stealGenericData<T>( buf_id, node_id ); }
412 
413  /// Updates the data value in a generic buffer in-place via a callable.
414  template<typename T, typename OP>
415  void updateGenericData( UN_GenericBufferID buf_id, UN_NodeID node_id,
416  const OP &op )
417  { UN_Data::updateGenericData<T>( buf_id, node_id, op ); }
418 
419 
420  /// Asserts that the node names are alphanumeric.
421  void setCheckValidNodeNames( bool flag )
422  { myCheckValidNodeNames = flag; }
423 
424  /// A set of additional characters that are legal in node names.
425  void setNodeNameSafeChars( const UT_StringRef &safe_chars )
426  { myNodeNameSafeChars = safe_chars; }
427 
428 protected:
429  /// Returns the node's data index into the data buffer arrays.
430  UN_NodeIndex nodeIndex( UN_NodeID id ) const
431  {
432  return UN_NodeIndex( UN_Data::dataIndex( id ));
433  }
434 
435 private:
436  /// Returns the current size of the internals data buffers.
437  /// The number of valid entries (slots) in data buffers is less than
438  /// or equal to that number, since some data slots may be free.
439  UN_DataSize coreDataBufferSize() const
440  {
441  UN_DataSize size( myName.size() );
442  UT_ASSERT( isCoreDataSizeConsistent( size ));
443  return size;
444  }
445 
446  /// Helper that adds a new data slot for the given node.
447  UN_NodeID addNodeData( UN_NodeID node_id, UN_NodeIndex node_index );
448 
449 
450  /// Handles merging of another node data container into this one.
451  void mergeCoreData( const UN_NodeData &src,
452  const UN_DataMergeInfo &merge_info );
453 
454  /// Adds a new data slot to accommodate a new data piece at the given index.
455  void addCoreData( UN_NodeIndex node_index );
456 
457  /// Clears the data for the given node to the default state.
458  void clearCoreData( UN_NodeIndex node_index );
459 
460  /// Frees the data slot occupied by the given node,
461  /// clearing it if necessary.
462  void removeCoreData() //, index)
463  // Nothing urgent to free; will clear lazily
464  { UT_ASSERT( isDataSizeConsistent() ); }
465 
466  /// Frees all the data slots.
467  void removeAllCoreData();
468 
469  /// Sets the capacity of core data buffers if needed.
470  void setCoreDataCapacityIfNeeded( UN_DataSize min_capacity );
471 
472  /// @{ Returns true if the sizes of all core data buffers are equal.
473  bool isCoreDataSizeConsistent( UN_DataSize expected_size ) const;
474  bool isCoreDataSizeConsistent() const
475  { return isCoreDataSizeConsistent( myName.size() ); }
476  /// @}
477 
478  /// Returns true if the sizes of data buffers and index map are equal.
479  bool isDataSizeConsistent() const;
480 
481 public:
482  // The default values for the UN node data.
483  // TODO: FIXME: the (1,1,1) is what APEX_Node had as a default color.
484  // Revisit it and decide what the default color for generic
485  // UN nodes should be.
487  static inline const UT_StringHolder theDefComment;
488  static inline const UT_StringArray theDefTags;
489  static inline const UN_MetadataHolder theDefMetadata;
490  static inline const auto theDefColor = UT_Color( UT_RGB, 1.0F, 1.0F, 1.0F );
491  static inline const auto theDefPos = UT_Vector2D(0.0);
492 
493 private:
494  /// The name of the node.
495  UN_StringDataBuffer myName;
496 
497  /// An identifier that determines node's functional behaviour.
498  UN_StringDataBuffer myTypeName;
499 
500  /// The name of the unique group this node belongs to.
501  /// Nodes in the same category can be connected to each other, have
502  /// the same input/output types, and be processed in a similar way.
503  /// Ie, a category is similar to a language (eg, VEX, MaterialX) that
504  /// imposes data types, connectivity rules, auto-conversion, etc.
505  UN_StringDataBuffer myCategoryName;
506 
507  /// Node's signature.
508  UN_StringDataBuffer mySignatureName;
509 
510  /// Node's comment.
511  UN_StringDataBuffer myComment;
512 
513  /// Node's position.
514  UN_Vector2DDataBuffer myPosition;
515 
516  /// Node's color (an RGB float triplet).
517  UN_ColorDataBuffer myColor;
518 
519  /// Node's tags.
521 
522  /// Node's metadata.
523  UN_MetaDataBuffer myMetadata;
524 
525  /// Extra characters that are legal in the node names,
526  /// in addition to the standard C-var style alphanumerics.
527  UT_StringHolder myNodeNameSafeChars;
528 
529  /// Check an assertion that the node names are alphanumeric.
530  bool myCheckValidNodeNames = false;
531 };
532 
533 
534 #endif
535 
IDRange idRange() const
Definition: UN_Data.h:55
UN_GenericBufferType
Supported types for generic data buffers.
UT_UniquePtr< UN_CustomNodeData > UN_CustomNodeDataPtr
Definition: UN_NodeData.h:24
void setMetadata(UN_NodeID node_id, const UN_MetadataHolder &metadata)
Sets node's new metadata via copy-assignment.
Definition: UN_NodeData.h:349
#define SYS_STATIC_ASSERT(expr)
void updateMetadata(UN_NodeID node_id, const OP &op)
Definition: UN_NodeData.h:329
const UT_StringHolder & signatureName(UN_NodeID node_id) const
Returns the node's signature.
Definition: UN_NodeData.h:243
const UT_Vector2D & position(UN_NodeID node_id) const
Returns the node's location in the graph editor.
Definition: UN_NodeData.h:267
UN_NodeIndex nodeIndex(UN_NodeID id) const
Returns the node's data index into the data buffer arrays.
Definition: UN_NodeData.h:430
const T & genericDataRef(UN_GenericBufferID buf_id, UN_NodeID node_id) const
Returns a const ref to the data value in a generic buffer.
Definition: UN_NodeData.h:398
UN_GenericNodeDataBufferRef addGenericNodeDataBuffer(const UT_StringRef &name, UN_GenericBufferType type, const D &default_value)
Definition: UN_NodeData.h:377
void setSignatureName(UN_NodeID node_id, const UT_StringRef &signature_name)
Definition: UN_NodeData.h:208
void setGenericData(UN_GenericBufferID buf_id, UN_NodeID node_id, const T &value)
Sets the data value in a generic buffer for a given node.
Definition: UN_NodeData.h:386
UT_Vector2T< fpreal64 > UT_Vector2D
const UT_StringHolder & categoryName(UN_NodeID node_id) const
Definition: UN_NodeData.h:236
GLsizei const GLfloat * value
Definition: glcorearb.h:824
bool isValid(UN_DataID data_id) const
Definition: UN_Data.h:140
void setPosition(UN_NodeID node_id, const UT_Vector2D &position)
Sets the node's location in the graph editor.
Definition: UN_NodeData.h:261
UN_MetadataHolder stealMetadata(UN_NodeID node_id)
Returns node's metadata moved from the data buffer entry.
Definition: UN_NodeData.h:367
void setOption(const UT_StringHolder &name, UT_OptionEntryPtr value)
const UN_CustomNodeData * customNodeData() const
Returns node's custom data container, if one was provided.
Definition: UN_NodeData.h:66
static const UN_MetadataHolder theDefMetadata
Definition: UN_NodeData.h:489
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
Definition: UT_Assert.h:242
friend UN_GraphData
Definition: UN_NodeData.h:50
Iterator for traversing valid node IDs in an ascending order.
Definition: UN_NodeData.h:137
Iterator for traversing valid data IDs in the map.
#define UN_API
Definition: UN_API.h:11
UN_Data & operator=(UN_Data &&)
T stealGenericData(UN_GenericBufferID buf_id, UN_NodeID node_id)
Moves the data value out of a generic buffer.
Definition: UN_NodeData.h:410
UN_CustomNodeData * customNodeData()
Returns node's custom data container, if one was provided.
Definition: UN_NodeData.h:61
value_type operator*() const
Definition: UN_NodeData.h:146
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
void setTags(UN_NodeID node_id, UT_StringArray &&tags)
Sets new tags on a node via move-assignment.
Definition: UN_NodeData.h:309
UN_DataIndex dataIndex(UN_DataID id) const
Definition: UN_Data.h:147
void setCategoryName(UN_NodeID node_id, const UT_StringRef &category_name)
Definition: UN_NodeData.h:200
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
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.
Definition: UN_Data.h:213
void update(const OP &op)
Definition: UT_Options.h:1225
T genericDataVal(UN_GenericBufferID buf_id, UN_NodeID node_id) const
Returns a copy of a data value from a generic buffer.
Definition: UN_NodeData.h:404
UN_NodeIDList nodeIDs() const
Definition: UN_NodeData.h:163
UN_CustomData * customData()
Returns the custom data container, if one was provided.
Definition: UN_Data.h:47
static const UT_StringHolder theDefComment
Definition: UN_NodeData.h:487
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.
Definition: UN_Data.h:275
static const UT_StringHolder theEmptyString
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.
Definition: CLI11.h:1729
void setCheckValidNodeNames(bool flag)
Asserts that the node names are alphanumeric.
Definition: UN_NodeData.h:421
void updateMetadata(UN_NodeID node_id, const UT_StringHolder &key, UT_OptionEntryPtr &&value)
Simpler method to update a single metadata value in-place.
Definition: UN_NodeData.h:335
void setTypeName(UN_NodeID node_id, const UT_StringRef &type_name)
Sets the node's type that determines its functional behavour.
Definition: UN_NodeData.h:223
UN_DataIDList dataIDs() const
Returns a list of all the valid IDs in this container.
Definition: UN_Data.h:64
OrderedIDIterator(const UN_DataIndexMap::OrderedIDIterator &id_iterator)
Definition: UN_NodeData.h:142
bool isValid(UN_NodeID node_id) const
Definition: UN_NodeData.h:118
IDIterator(const UN_DataIndexMap::IDIterator &id_iterator)
Definition: UN_NodeData.h:128
value_type operator*() const
Definition: UN_NodeData.h:132
GLuint const GLchar * name
Definition: glcorearb.h:786
void updateGenericData(UN_GenericBufferID buf_id, UN_NodeID node_id, const OP &op)
Updates the data value in a generic buffer in-place via a callable.
Definition: UN_NodeData.h:415
UN_API UN_OptionsPtr asOptions(const UN_GraphData *graph_data)
void updateData(B &buffer, UN_DataID id, const OP &op)
Definition: UN_Data.h:229
void updateTags(UN_NodeID node_id, const OP &op)
Definition: UN_NodeData.h:297
UT_StringArray stealTags(UN_NodeID node_id)
Returns node tags moved from the data buffer entry.
Definition: UN_NodeData.h:321
Maintains a mapping from data ID to data index in the data buffer.
Iterator for traversing valid node IDs.
Definition: UN_NodeData.h:123
GLsizeiptr size
Definition: glcorearb.h:664
A map of string to various well defined value types.
Definition: UT_Options.h:87
const UT_StringHolder & name(UN_NodeID node_id) const
Returns the name that identifies the node among its siblings.
Definition: UN_NodeData.h:216
Iterator for traversing valid data IDs in the map in an ordered fashion.
void setNodeNameSafeChars(const UT_StringRef &safe_chars)
A set of additional characters that are legal in node names.
Definition: UN_NodeData.h:425
GLuint color
Definition: glcorearb.h:1261
SIM_API const UT_StringHolder position
const UN_MetadataHolder & metadata(UN_NodeID node_id) const
Returns nodes's metadata.
Definition: UN_NodeData.h:361
void setData(B &buffer, UN_DataID id, const V &value)
Helper method to copy-assign the value to an entry in the data buffer.
Definition: UN_Data.h:173
void setGenericData(UN_GenericBufferID buf_id, UN_NodeID node_id, T &&value)
Sets the data value in a generic buffer via move.
Definition: UN_NodeData.h:392
void setColor(UN_NodeID node_id, const UT_Color &color)
Sets the node's color in the graph editor.
Definition: UN_NodeData.h:273
void setMetadata(UN_NodeID node_id, UN_MetadataHolder &&metadata)
Sets node's new metadata via move-assignment.
Definition: UN_NodeData.h:355
const UT_StringHolder & typeName(UN_NodeID node_id) const
Returns the name of node's type that determines its functional behavour.
Definition: UN_NodeData.h:229
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:165
void setComment(UN_NodeID node_id, const UT_StringRef &comment)
Sets the node's comment.
Definition: UN_NodeData.h:249
OutGridT XformOp bool bool MergePolicy merge
UN_DataSize size() const
Returns the number of valid data items in the buffer.
Definition: UN_Data.h:72
UN_DataIDList sortedDataIDs() const
Returns a sorted list of all the valid IDs in this container.
Definition: UN_Data.h:68
static const UT_StringArray theDefTags
Definition: UN_NodeData.h:488
const UT_Color & color(UN_NodeID node_id) const
Returns the node's color in the graph editor.
Definition: UN_NodeData.h:279
const UT_StringArray & tags(UN_NodeID node_id) const
Returns node tags.
Definition: UN_NodeData.h:315
UN_GenericBufferID addGenericBuffer(const UT_StringRef &name, UN_GenericBufferType type, const D &default_value)
Definition: UN_Data.h:241
const UT_StringHolder & comment(UN_NodeID node_id) const
Returns the node's comment.
Definition: UN_NodeData.h:255
Definition: UNI_ID.h:25
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.
Definition: UN_Data.h:190
UT_UniquePtr< UT_OptionEntry > UT_OptionEntryPtr
UN_NodeIDList sortedNodeIDs() const
Definition: UN_NodeData.h:174
void setTags(UN_NodeID node_id, const UT_StringArray &tags)
Sets new tags on a node via copy-assignment.
Definition: UN_NodeData.h:303
OrderedIDRange orderedIDRange() const
Definition: UN_Data.h:60
UT_UniquePtr< UN_Options > UN_OptionsPtr
Definition: UN_Include.h:640
void setName(UN_NodeID node_id, const UT_StringRef &name)
Definition: UN_NodeData.h:187
GLenum src
Definition: glcorearb.h:1793
static const UT_StringHolder theDefSignatureName
Definition: UN_NodeData.h:486