HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_IteratorState.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_IteratorState.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_IteratorState__
12 #define __GA_IteratorState__
13 
14 #include "GA_API.h"
15 #include "GA_Types.h"
16 
17 #include <UT/UT_NonCopyable.h>
18 
19 #include <stddef.h>
20 
21 
22 /// State information for a GA_Iterator. This stores unique information for
23 /// each iterator which the GA_Range bound to the iterator can reference.
25 {
26 public:
28  : myPointer(NULL)
29  , myOffset(GA_INVALID_OFFSET)
30  , myIndex(GA_INVALID_INDEX)
31  , mySize(0)
32  , myNestedState(NULL)
33  {}
34 
36 
37  /// Copy the POD state (not including nested state)
39  {
40  myPointer = src.myPointer;
41  myOffset = src.myOffset;
42  myIndex = src.myIndex;
43  mySize = src.mySize;
44  }
45 
46  /// These variables provide easy storage to GA_RangeTypeInterface
47  /// without the style necessarily having to allocate state
48  /// information (i.e. the named storage)
49  void *myPointer;
53 
54  /// Some ranges contain nested ranges. These RTIs can create nested
55  /// states. These nested states should be used to store the iteration
56  /// state for the nested range.
57  /// Call @c createNestedState() in GA_RangeTypeInterface::iterateCreate().
58  /// And it should only be called once.
59  /// For example, a nested range might have code like: @code
60  /// GA_RTINested::iterateCreate(GA_IteratorState &state)
61  /// {
62  /// myBase->iterateCreate(state.createNestedState());
63  /// // Use any data in state to store the parent's state information
64  /// }
65  ///
66  /// GA_RTINested::iterateDestroy(GA_IteratorState &state)
67  /// {
68  /// myBase->iterateDestroy(&state.getNestedState());
69  /// state.clearNestedState();
70  /// // Do any cleanup on state that you need
71  /// }
72  ///
73  /// GA_RTINested::iterateRewind(GA_IteratorState &state,
74  /// GA_Offset &start, GA_Offset &end) const
75  /// {
76  /// GA_Offset n_start, n_end;
77  /// myBase->iterateRewind(state.getNestedState(), n_start, n_end);
78  /// // Use base_start base_end and the state to rewind the parent
79  /// }
80  /// GA_RTINested::iterateCopy(GA_IteratorState &d,
81  /// const GA_IteratorState &s)
82  /// {
83  /// GA_IteratorState &nest = dest.createNestedState();
84  /// myBase->iterateCopy(nest, src.getNestedState());
85  /// state.copyState(src);
86  /// }
87  /// @endcode
88  GA_IteratorState &createNestedState();
89 
90  /// Clear the nested pointer.
91  void clearNestedState();
92 
93  /// Access to the nested state.
94  GA_IteratorState &getNestedState() const;
95 
96 private:
97  GA_IteratorState *myNestedState;
98 };
99 
100 #endif
#define GA_API
Definition: GA_API.h:14
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:236
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
GA_Size GA_Offset
Definition: GA_Types.h:646
void copyState(const GA_IteratorState &src)
Copy the POD state (not including nested state)
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:640
#define GA_INVALID_INDEX
Definition: GA_Types.h:686
GLenum src
Definition: glcorearb.h:1793