HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_AIFStringTuple.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: GA_AIFStringTuple.h ( GA Library, C++)
7  *
8  * COMMENTS: Attribute Interface class for string index table methods
9  */
10 
11 #ifndef __GA_AIFStringTuple__
12 #define __GA_AIFStringTuple__
13 
14 #include "GA_API.h"
15 #include "GA_Types.h"
16 
17 class GA_Attribute;
18 class GA_Range;
19 class UT_StringArray;
20 
21 /// @brief Generic Attribute Interface class to work with string indices
22 /// directly, rather than string values.
23 ///
24 /// This class provides the interface to access string table data. Each
25 /// attribute type may provide this interface if it makes sense.
27 {
28 public:
30  virtual ~GA_AIFStringTuple();
31 
32 public:
33  // --------------------------------------------------------------
34  // Tuple Interface
35  // --------------------------------------------------------------
36 
37  /// Query the tuple size
38  virtual int getTupleSize(const GA_Attribute *attrib) const = 0;
39 
40  /// Set the tuple size
41  virtual bool setTupleSize(GA_Attribute *attrib, int size) const = 0;
42 
43  /// Get a single string from the array for a single tuple of an element.
44  virtual const char *getString(const GA_Attribute *attrib, GA_Offset ai,
45  int tuple_index=0) const = 0;
46 
47  /// Get the full tuple of string values for a single element
48  virtual bool getStrings(const GA_Attribute *attrib, GA_Offset ai,
50  int count, int start=0) const;
51 
52  /// Set a single component for a single element.
53  virtual bool setString(GA_Attribute *attrib, GA_Offset ai,
54  const char *string, int tuple_index) const = 0;
55  /// Set a single component for a range of elements.
56  virtual bool setString(GA_Attribute *attrib, const GA_Range &ai,
57  const char *string, int tuple_index) const;
58 
59  /// Set multiple components for a single element.
60  virtual bool setStrings(GA_Attribute *attrib, GA_Offset ai,
61  const char **strings, int count,
62  int start=0) const;
63  /// Set multiple components for a range of elements.
64  virtual bool setStrings(GA_Attribute *attrib, const GA_Range &ai,
65  const char **strings, int count,
66  int start=0) const;
67 
68 public:
69  // --------------------------------------------------------------
70  // Interface to deal with a detail attribute as a list of strings
71  //
72  // By default interface uses the simple tuple interface defined above.
73  // --------------------------------------------------------------
74 
75  /// Reserve space in the array.
76  virtual bool arrayReserve(GA_Attribute *attrib, int length) const
77  {
78  if (length <= getTupleSize(attrib))
79  return true;
80  return setTupleSize(attrib, length);
81  }
82  /// Truncate the array to the given entries
83  virtual bool arrayTruncate(GA_Attribute *attrib, int length) const
84  {
85  if (length >= getTupleSize(attrib))
86  return true;
87  return setTupleSize(attrib, length);
88  }
89 
90  /// Trim the array to the minimum required size. This may be an expensive
91  /// operation as it traverses all elements to compute the minimum size,
92  /// then calls truncate. The method returns the new size.
93  virtual int arrayTrim(GA_Attribute *attrib) const;
94 
95  /// Append an index to the array. The resulting index will be returned.
96  /// The @c element_index specifies the point, primitive, vertex etc.
97  virtual int arrayAppendString(GA_Attribute *attrib,
98  const char *string,
99  GA_Offset element_index=GA_Offset(0)) const;
100 
101  /// Append an string to the array, but only if the string is unique in the
102  /// array.
103  virtual int arrayAppendUniqueString(GA_Attribute *attrib,
104  const char *string,
105  GA_Offset element_index=GA_Offset(0)) const;
106 
107  /// Return the length of the array. That is, the number of strings which
108  /// occupy slots in the tuple.
109  /// The @c element_index specifies the point, primitive, vertex etc.
110  virtual int arrayGetLength(const GA_Attribute *attrib,
111  GA_Offset element_index=GA_Offset(0)) const;
112 
113  /// Find the maximum length of all elements in the range
114  virtual int arrayGetMaxLength(const GA_Attribute *attrib,
115  const GA_Range &range) const;
116 
117  /// Extract a string from the array (by index)
118  /// The @c element_index specifies the point, primitive, vertex etc.
119  virtual const char *arrayGetString(const GA_Attribute *attrib,
120  int string_index,
121  GA_Offset element_index=GA_Offset(0)) const;
122 
123  /// Extract the list of strings from the array. Returns the number of
124  /// strings extracted.
125  /// The @c element_index specifies the point, primitive, vertex etc.
126  virtual int arrayGetStrings(UT_StringArray &strings,
127  const GA_Attribute *attrib,
128  GA_Offset element_index=GA_Offset(0)) const;
129 
130  /// Find the index of a string in the array of strings (-1 if the string
131  /// isn't found).
132  /// The @c element_index specifies the point, primitive, vertex etc.
133  virtual int arrayFindString(const GA_Attribute *attrib,
134  const char *string,
135  GA_Offset element_index=GA_Offset(0)) const;
136 
137  /// Delete a string from the array (by index)
138  /// The @c element_index specifies the point, primitive, vertex etc.
139  virtual bool arrayDestroyString(GA_Attribute *attrib,
140  int string_index,
141  GA_Offset element_index=GA_Offset(0)) const;
142 
143  /// Remove duplicate strings from the array
144  /// The @c element_index specifies the point, primitive, vertex etc.
145  virtual int arrayRemoveDuplicates(GA_Attribute *attrib,
146  GA_Offset element_index=GA_Offset(0)) const;
147 };
148 
149 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
GLenum GLint * range
Definition: glcorearb.h:1925
GLuint start
Definition: glcorearb.h:475
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
#define GA_API
Definition: GA_API.h:14
virtual bool arrayReserve(GA_Attribute *attrib, int length) const
Reserve space in the array.
A range of elements in an index-map.
Definition: GA_Range.h:42
virtual bool arrayTruncate(GA_Attribute *attrib, int length) const
Truncate the array to the given entries.
GA_Size GA_Offset
Definition: GA_Types.h:641
GLsizei const GLchar *const * strings
Definition: glcorearb.h:1933
GLsizeiptr size
Definition: glcorearb.h:664
GLint GLsizei count
Definition: glcorearb.h:405
Generic Attribute Interface class to work with string indices directly, rather than string values...