HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_ParmUtils.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_ParmUtils.h ( UN Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UN_ParmUtils_h__
13 #define __UN_ParmUtils_h__
14 
15 
16 #include "UN_API.h"
17 #include "UN_GraphData.h"
18 #include <UT/UT_OptionEntry.h>
19 
20 
21 namespace UN_ParmUtils
22 {
23  /// Returns true if the parameter by the given ID is valid in the graph.
24  static inline bool
25  isValid( const UN_GraphData *graph_data, UN_ParmID parm_id )
26  {
27  return graph_data && graph_data->isValid( parm_id );
28  }
29 
30  /// Deletes the given parameter from the graph data structures.
31  static inline void
32  deleteParm( UN_GraphData *graph_data, UN_ParmID parm_id )
33  {
34  if( isValid( graph_data, parm_id ))
35  graph_data->deleteParm( parm_id );
36  }
37 
38  /// Returns the parameter name that identifies it on the node.
39  static inline const UT_StringHolder &
40  name( const UN_GraphData *graph_data, UN_ParmID parm_id )
41  {
42  return graph_data
43  ? graph_data->parmData().name( parm_id )
45  }
46 
47  /// Returns the parameter type that determines the type of a value.
48  static inline const UT_StringHolder &
49  typeName( const UN_GraphData *graph_data, UN_ParmID parm_id )
50  {
51  return graph_data
52  ? graph_data->parmData().typeName( parm_id )
54  }
55 
56  /// Sets the parameter value using copy-assignment.
57  static inline void
58  setValue( UN_GraphData *graph_data, UN_ParmID parm_id,
59  const UT_OptionEntry &value )
60  {
61  if( graph_data )
62  graph_data->parmData().setValue( parm_id, value );
63  }
64 
65  /// Sets the parameter value using move-assignment.
66  static inline void
67  setValue( UN_GraphData *graph_data, UN_ParmID parm_id,
68  UT_OptionEntryPtr &&value )
69  {
70  if( graph_data )
71  graph_data->parmData().setValue( parm_id, std::move( value ));
72  }
73 
74  /// Returns the value of the parameter.
75  static inline UT_OptionEntryPtr
76  value( const UN_GraphData *graph_data, UN_ParmID parm_id )
77  {
78  if( !graph_data )
79  return UT_OptionEntryPtr();
80 
81  auto &value = graph_data->parmData().value( parm_id );
82  return value ? value->clone() : UT_OptionEntryPtr();
83  }
84 }
85 
86 #endif
GLsizei const GLfloat * value
Definition: glcorearb.h:824
virtual UT_OptionEntryPtr clone() const
bool isValid(UN_NodeID node) const
Definition: UN_GraphData.h:472
static const UT_StringHolder theEmptyString
const UT_StringHolder & name(UN_ParmID parm_id) const
The name of the parameter.
GLuint const GLchar * name
Definition: glcorearb.h:786
const UT_StringHolder & typeName(UN_ParmID parm_id) const
The name of the parameter.
UN_ParmData & parmData()
Returns the container of data for the parameters in the graph.
Definition: UN_GraphData.h:495
void deleteParm(UN_ParmID parm)
Deletes the parameter.
const UT_OptionEntryPtr & value(UN_ParmID parm_id) const
The parameter value.
void setValue(UN_ParmID parm_id, const UT_OptionEntry &opt)
The parameter value.
UT_UniquePtr< UT_OptionEntry > UT_OptionEntryPtr