HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_AIFBlindData.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_AIFBlindData.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_AIFBlindData__
12 #define __GA_AIFBlindData__
13 
14 #include "GA_API.h"
15 #include "GA_Types.h"
16 
17 #include <stddef.h>
18 
19 
20 class GA_Attribute;
21 
22 
23 /// @brief Attribute Interface for blind data per element
24 ///
25 /// This attribute interface allows control over a "blind" attribute.
26 /// Each element is viewed as having a block of N bytes associated with it.
27 /// You can get a blind pointer to this data to read/write data.
28 /// @warning No constructor/destructors are called on the blind data, the blind
29 /// data should be used for POD types like floats or ints, and only if there's
30 /// no way to use friendlier attribute types.
32 {
33 public:
35  virtual ~GA_AIFBlindData();
36 
38  {
39  GA_BLINDDATA_LITTLE_ENDIAN, // Data is little endian
40  GA_BLINDDATA_BIG_ENDIAN // Data is big endian
41  };
42 
43  /// Set the data size. Each element will have this many bytes of data
44  /// allocated for it.
45  virtual bool setDataSize(GA_Attribute *attrib,
46  GA_Size size_in_bytes,
47  const void *default_value=NULL) const = 0;
48 
49  /// Set data alignment. This method will force data to be aligned on this
50  /// many bytes. An alignment of 0 specifies the data will be aligned with
51  /// @c sizeof(void*) on the particular architecture.
52  virtual bool setDataAlignment(GA_Attribute *attrib,
53  GA_Size alignment_bytes) const = 0;
54 
55  /// @{
56  /// Query state of attribute
57  virtual GA_Size getDataSize(const GA_Attribute *attrib) const = 0;
58  virtual GA_Size getDataAlignment(const GA_Attribute *attrib) const = 0;
59  /// @}
60 
61  /// @{
62  /// Get/Set the save flag. If the save flag is set, the blind data will be
63  /// saved with geometry (if the attribute supports it)
64  virtual bool getSaveFlag(const GA_Attribute *a) const = 0;
65  virtual void setSaveFlag(GA_Attribute *a, bool save) const = 0;
66  /// @}
67 
68  /// @{
69  /// Query or set the endian flag.
70  /// @note Calling @c swapEndian() will change the state of the endian flag,
71  /// but will @b not swap the data (this is the caller's responsibility).
72  virtual GA_BlindDataEndian getEndianFlag(const GA_Attribute *a) const = 0;
73  virtual void swapEndianFlag(GA_Attribute *a) const = 0;
74  /// @}
75 
76  /// Get a read pointer to the data for a given element
77  virtual const void *getReadData(const GA_Attribute *attrib,
78  GA_Offset offset) const = 0;
79 
80  /// Get a write pointer to the data for a given element
81  virtual void *getWriteData(GA_Attribute *attrib,
82  GA_Offset offset) const = 0;
83 
84  /// Convenience function to access value as a read-only object
85  template <typename T>
86  const T &getValue(const GA_Attribute *atr, GA_Offset off) const
87  { return *static_cast<const T *>(getReadData(atr, off)); }
88  /// Convenience function to access value as a writable object
89  template <typename T>
91  { return *static_cast<T *>(getWriteData(atr, off)); }
92  /// Convenience function to set value to an object
93  template <typename T>
95  const T &value) const
96  { *static_cast<T *>(getWriteData(atr, off)) = value; }
97 };
98 
99 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:190
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
T & getWriteValue(GA_Attribute *atr, GA_Offset off) const
Convenience function to access value as a writable object.
#define GA_API
Definition: GA_API.h:12
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
GA_Size GA_Offset
Definition: GA_Types.h:617
GLintptr offset
Definition: glcorearb.h:664
GLsizei const GLfloat * value
Definition: glcorearb.h:823
Attribute Interface for blind data per element.
void setValue(GA_Attribute *atr, GA_Offset off, const T &value) const
Convenience function to set value to an object.
const T & getValue(const GA_Attribute *atr, GA_Offset off) const
Convenience function to access value as a read-only object.