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  /// @{
38  /// Returns the number of values in the list
39  int entries() const { return myValues.entries(); }
40  int size() const { return myValues.size(); }
41  /// @}
42 
43  /// Get a value by index
44  const CVEX_ValueT<PREC> *getValue(int i) const { return myValues(i); }
45  CVEX_ValueT<PREC> *getValue(int i) { return myValues(i); }
46 
47  /// Get a value by name and type. Returns NULL if there's no value by
48  /// that name and type.
49  const CVEX_ValueT<PREC> *getValue(const UT_StringRef &name, CVEX_Type type) const;
51 
52  /// Get a value by name. Returns NULL if there's no value by that name.
54  { return getValue(name, CVEX_TYPE_INVALID); }
56  { return getValue(name, CVEX_TYPE_INVALID); }
57 
58  /// Add a value by name type and varying flag. This fails if:
59  /// - There's already a symbol with the name
60  /// - The type is invalid
61  /// @note Users should call CVEX_Context::addInput()
62  bool addValue(const UT_StringHolder &name,
63  CVEX_Type type, bool varying);
64 
65  /// Add a value by name, type and provide data.
66  /// @note Users should call CVEX_Context::addInput()
67  bool addValue(const UT_StringHolder &name, CVEX_Type type,
68  void *data, int array_size,
69  bool isconstant);
70 
71  /// Add a string value (with data)
72  /// @note Users should call CVEX_Context::addInput()
73  bool addValue(const UT_StringHolder &name,
75  bool isconstant);
76  bool addValue(const UT_StringHolder &name,
78  bool isconstant);
79 
80  /// Add an array of integer value (with data)
81  /// @note Users should call CVEX_Context::addInput()
82  bool addValue(const UT_StringHolder &name,
84  bool isconstant);
85 
86  /// @{
87  /// Convenience operators
88  const CVEX_ValueT<PREC> *operator[](int i) const { return getValue(i); }
89  CVEX_ValueT<PREC> *operator[](int i) { return getValue(i); }
90 
91  CVEX_ValueT<PREC> *operator()(int i) { return getValue(i); }
93  { return getValue(name, type); }
94  /// @}
95 
96 private:
97  void clear();
98  void addValue(CVEX_ValueT<PREC> *value);
99 
100  // Clear the value but leave the null entry in myValues
101  void clearValue(int index);
102 
103  UT_StringMap<CVEX_ValueT<PREC> *> mySymbols;
104  UT_ValArray<CVEX_ValueT<PREC> *> myValues;
105  UT_String myError;
106 
107  UT_ValArray<CVEX_ValueT<PREC> *> myClearedValues;
108 
109  template <VEX_Precision ALLPREC>
110  friend class CVEX_ContextT;
111 };
112 
114 
117 
118 #endif
CVEX_ValueT< PREC > * operator[](int i)
CVEX_ValueT< PREC > * getValue(int i)
GLuint const GLchar * name
Definition: glcorearb.h:786
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:59
int entries() const
GLsizei const GLchar *const * strings
Definition: glcorearb.h:1933
CVEX_Type
The CVEX_Type enum defines the VEX types available to CVEX.
Definition: CVEX_Value.h:29
CVEX_ValueT< PREC > * getValue(const UT_StringRef &name)
GLuint index
Definition: glcorearb.h:786
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
Definition: core.h:1131
const CVEX_ValueT< PREC > * operator[](int i) const
type
Definition: core.h:1059
Call VEX from C++.
Definition: CVEX_Context.h:203
CVEX_ValueT< PREC > * operator()(int i)
Definition: format.h:895
int size() const
CVEX_EXTERN_TEMPLATE(CVEX_ValueListT< VEX_32 >)