HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_RTISingle.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_RTISingle.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_RTISingle__
12 #define __GA_RTISingle__
13 
14 #include "GA_API.h"
15 #include "GA_RangeTypeInterface.h"
16 #include "GA_Types.h"
17 
18 
19 class GA_IndexMap;
20 class GA_IteratorState;
21 
22 
23 /// @brief Base class for ranges providing consolidation to contiguous blocks.
24 ///
25 /// GA_Iterator uses contiguous blocks for iteration, but it is often easier
26 /// to implement iteration over single elements. Such range implementations
27 /// can derive from this class to automatically perform the required
28 /// consolidation.
29 ///
30 /// @see GA_Range
32 {
33 public:
34  GA_RTISingle(const GA_IndexMap &list);
35  GA_RTISingle(const GA_RTISingle &other);
36  ~GA_RTISingle() override;
37 
38  /// Rewind the iterator (i.e. reset the iterator state). The start/offset
39  /// should be initialized so that they define the first contiguous "block"
40  /// for iteration. If the range is empty, @c start should be greater than
41  /// @c end
42  void iterateRewind(GA_IteratorState &state,
43  GA_Offset &start, GA_Offset &end) const override;
44 
45  /// Choose the next contiguous range. If the iteration is complete,
46  /// @c start should be set to a value greater than @c end.
47  void iterateNext(GA_IteratorState &state,
48  GA_Offset &start, GA_Offset &end) const override;
49 
50 protected:
51  /// @{
52  /// Some iterators are not set up to perform block iteration. These
53  /// methods can be used to define single iteration. The default
54  /// iterateRewind() and iterateNext() methods will call these methods to
55  /// collate single iterations into a block.
56  ///
57  /// - @c singleRewind() @n
58  /// Start iteration process
59  /// - @c singleGet() @n
60  /// Get the current value of the iteration. Return false if the
61  /// iteration is complete.
62  /// - @c singleNext() @n
63  /// Iterate to the next value
64  ///
65  /// Iteration using the single interface goes something like: @code
66  /// for (singleRewind(state); singleGet(state, offset); singleNext(state))
67  /// @endcode
68  /// @warning Even if you've optimized the iterateRewind()/iterateNext()
69  /// code, you still need to implement these methods.
70  virtual void singleRewind(GA_IteratorState &state) const=0;
71  virtual bool singleGet(const GA_IteratorState &state,
72  GA_Offset &value) const = 0;
73  virtual void singleNext(GA_IteratorState &state) const = 0;
74  /// @}
75 
76 private:
77  void singleIterate(GA_IteratorState &state,
78  GA_Offset &start, GA_Offset &end) const;
79 };
80 #endif
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
GLuint start
Definition: glcorearb.h:475
#define GA_API
Definition: GA_API.h:14
GA_Size GA_Offset
Definition: GA_Types.h:641
GLuint GLuint end
Definition: glcorearb.h:475
virtual void iterateRewind(GA_IteratorState &state, GA_Offset &start, GA_Offset &end) const =0
Abstract implementation of a range.
Definition: core.h:1131
Base class for ranges providing consolidation to contiguous blocks.
Definition: GA_RTISingle.h:31
virtual void iterateNext(GA_IteratorState &state, GA_Offset &start, GA_Offset &end) const =0