HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CVEX_ValueList.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: CVEX_ValueList.h ( CVEX Library, C++)
7  *
8  * COMMENTS: C++ interface to VEX. This class is used to specify
9  * a list of input/output values
10  */
11 
12 #ifndef __CVEX_ValueList__
13 #define __CVEX_ValueList__
14 
15 #include "CVEX_API.h"
16 #include "CVEX_Value.h"
17 #include <UT/UT_ValArray.h>
18 #include <UT/UT_SymbolTable.h>
19 
20 template <VEX_Precision PREC> class CVEX_ContextT;
21 
22 /// @brief List of input or output values for a CVEX_Context
23 ///
24 /// This class maintains a list of the input and output parameters for a CVEX
25 /// context.
26 ///
27 /// Both input and output variables are associated with parameters on the VEX
28 /// function being run. Output variables are those flagged with the @c export
29 /// keyword.
30 template <VEX_Precision PREC>
32 {
33 public:
35  ~CVEX_ValueListT();
36 
37  /// Returns the number of values in the list
38  int entries() const { return myValues.entries(); }
39 
40  /// Get a value by index
41  const CVEX_ValueT<PREC> *getValue(int i) const { return myValues(i); }
42  CVEX_ValueT<PREC> *getValue(int i) { return myValues(i); }
43 
44  /// Get a value by name and type. Returns NULL if there's no value by
45  /// that name and type.
46  const CVEX_ValueT<PREC> *getValue(const UT_StringRef &name, CVEX_Type type) const;
48 
49  /// Get a value by name. Returns NULL if there's no value by that name.
51  { return getValue(name, CVEX_TYPE_INVALID); }
53  { return getValue(name, CVEX_TYPE_INVALID); }
54 
55  /// Add a value by name type and varying flag. This fails if:
56  /// - There's already a symbol with the name
57  /// - The type is invalid
58  /// @note Users should call CVEX_Context::addInput()
59  bool addValue(const UT_StringHolder &name,
60  CVEX_Type type, bool varying);
61 
62  /// Add a value by name, type and provide data.
63  /// @note Users should call CVEX_Context::addInput()
64  bool addValue(const UT_StringHolder &name, CVEX_Type type,
65  void *data, int array_size,
66  bool isconstant);
67 
68  /// Add a string value (with data)
69  /// @note Users should call CVEX_Context::addInput()
70  bool addValue(const UT_StringHolder &name,
72  bool isconstant);
73 
74  /// Add an array of integer value (with data)
75  /// @note Users should call CVEX_Context::addInput()
76  bool addValue(const UT_StringHolder &name,
78  bool isconstant);
79 
80  /// @{
81  /// Convenience operators
82  const CVEX_ValueT<PREC> *operator[](int i) const { return getValue(i); }
83  CVEX_ValueT<PREC> *operator[](int i) { return getValue(i); }
84 
85  CVEX_ValueT<PREC> *operator()(int i) { return getValue(i); }
87  { return getValue(name, type); }
88  /// @}
89 
90 private:
91  void clear();
92  void addValue(CVEX_ValueT<PREC> *value);
93 
94  // Clear the value but leave the null entry in myValues
95  void clearValue(int index);
96 
97  UT_StringMap<CVEX_ValueT<PREC> *> mySymbols;
99  UT_String myError;
100 
101  UT_ValArray<CVEX_ValueT<PREC> *> myClearedValues;
102 
103  template <VEX_Precision ALLPREC>
104  friend class CVEX_ContextT;
105 };
106 
108 
111 
112 #endif
GLuint const GLchar * name
Definition: glew.h:1814
GLuint index
Definition: glew.h:1814
CVEX_ValueT< PREC > * operator[](int i)
CVEX_ValueT< PREC > * getValue(int i)
const CVEX_ValueT< PREC > * getValue(const UT_StringRef &name) const
Get a value by name. Returns NULL if there's no value by that name.
List of input or output values for a CVEX_Context.
CVEX_ValueT< PREC > * operator()(const UT_StringRef &name, CVEX_Type type)
A class representing a VEX value.
Definition: CVEX_Value.h:53
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
int entries() const
Returns the number of values in the list.
GLsizei const GLchar *const * strings
Definition: glew.h:5883
CVEX_Type
The CVEX_Type enum defines the VEX types available to CVEX.
Definition: CVEX_Value.h:25
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
CVEX_ValueT< PREC > * getValue(const UT_StringRef &name)
const CVEX_ValueT< PREC > * getValue(int i) const
Get a value by index.
#define CVEX_API
Definition: CVEX_API.h:12
typename VEX_PrecisionResolver< P >::int_type VEXint
Definition: VEX_PodTypes.h:68
const CVEX_ValueT< PREC > * operator[](int i) const
Call VEX from C++.
Definition: CVEX_Context.h:175
GLsizei const GLfloat * value
Definition: glew.h:1849
CVEX_ValueT< PREC > * operator()(int i)
CVEX_EXTERN_TEMPLATE(CVEX_ValueListT< VEX_32 >)