HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_RTICachedRange.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_RTICachedRange.h ( GA Library, C++)
7  *
8  * COMMENTS: This is an RTI class that caches the data offsets visited by
9  * another RTI to allow traversal when it would not otherwise
10  * be safe with the original RTI.
11  */
12 
13 #ifndef __GA_RTICachedRange__
14 #define __GA_RTICachedRange__
15 
16 #include "GA_API.h"
17 #include "GA_OffsetList.h"
18 #include "GA_RTISingle.h"
19 #include "GA_Types.h"
20 
21 
22 class GA_IteratorState;
23 class GA_Range;
25 
26 
27 /// @brief Cache a given range for later traversal
29 {
30 public:
31  /// Iterate over the source range but in order.
32  GA_RTICachedRange(const GA_RangeTypeInterface &range_to_cache);
33 
34  // Copy c-tor
36 
37  ~GA_RTICachedRange() override;
38 
39  /// @{
40  /// RangeTypeInterface implementation
41  GA_RangeTypeInterface *copy() const override;
42  bool isSplittable() const override { return false; }
43  bool isEmpty() const override;
44  GA_Size getMaxEntries() const override;
45  GA_Size getEntries() const override;
46  bool split(GA_RangeTypeInterface *list[2]) const override;
48  &src) const override;
49  void iterateCopy(GA_IteratorState &dest,
50  const GA_IteratorState &src) const override;
51  bool isOrdered() const override { return myIsOrdered; }
52  bool areTraversalDeletionsSafe() const override
53  { return true; }
54 
55  GA_Size getPageCount() const override
56  { return 0; }
58  GA_Size, GA_Size) const override
62  /// @}
63 
64  /// Accessors for offset list.
65  /// @{
66  const GA_OffsetList &getOffsetList() const { return myOffsetList; }
67  bool isFullList() const
68  { return myStart == 0 && myEnd == myOffsetList.size(); }
69  GA_Size getStart() const
70  { return myStart; }
71  GA_Size getEnd() const
72  { return myEnd; }
73  /// @}
74 
75  /// Get a GA_RangeTypeInterface representing the remainder of the range
76  /// after iterating over part of it, as specified by state and current.
77  /// NOTE: The caller is responsible for deleting the returned
78  /// GA_RangeTypeInterface!
79  virtual GA_RangeTypeInterface *getRemainder(
80  const GA_IteratorState &state,
81  const GA_Offset current) const;
82 
83 private:
84  /// @{
85  /// RangeTypeInterface implementation
86  void singleRewind(GA_IteratorState &state) const override;
87  bool singleGet(const GA_IteratorState &state,
88  GA_Offset &value) const override;
89  void singleNext(GA_IteratorState &state) const override;
90  /// @}
91  //
92  /// Initialize the cache.
93  void init(const GA_RangeTypeInterface &range_to_cache);
94 
95  GA_OffsetList myOffsetList;
96 
97  /// We support using a subset of our offset list to allow sharing of the
98  /// underlying data when splitting the range. Note that the valid range
99  /// is [myStart..myEnd-1], i.e., myEnd is non-inclusive.
100  GA_Size myStart, myEnd;
101 
102  bool myIsOrdered;
103 };
104 
105 #endif
virtual bool isEmpty() const =0
Check whether the range is empty.
virtual GA_RangeTypeInterface * copy() const =0
Method to create a copy of this selection.
const GA_OffsetList & getOffsetList() const
virtual bool singleGet(const GA_IteratorState &state, GA_Offset &value) const =0
Cache a given range for later traversal.
virtual void iterateCopy(GA_IteratorState &dest, const GA_IteratorState &src) const =0
Copy iterator state. The dest state will not have been constructed.
virtual bool split(GA_RangeTypeInterface *list[2]) const =0
GA_Offset getFirstOffsetInPage(GA_Size) const override
#define GA_API
Definition: GA_API.h:14
GLenum src
Definition: glcorearb.h:1792
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:234
A range of elements in an index-map.
Definition: GA_Range.h:42
bool getPageElementRangeNonSplittable() const
Method which can be called for getPageElementRange()
GA_Size GA_Offset
Definition: GA_Types.h:640
bool getPageElementRange(GA_Range &, GA_Size, GA_Size) const override
GA_Offset getFirstOffsetInPageNonSplittable() const
Method which can be called for getFirstOffsetInPage()
Abstract implementation of a range.
virtual void singleNext(GA_IteratorState &state) const =0
virtual GA_Size getMaxEntries() const =0
Get an upper bound on the size of the range.
virtual void singleRewind(GA_IteratorState &state) const =0
bool isSplittable() const override
GLsizei const GLfloat * value
Definition: glcorearb.h:823
GA_Size getPageCount() const override
bool isOrdered() const override
bool areTraversalDeletionsSafe() const override
GA_Size getStart() const
virtual GA_Size getEntries() const =0
Base class for ranges providing consolidation to contiguous blocks.
Definition: GA_RTISingle.h:31
bool isFullList() const
GA_Size getEnd() const
virtual bool isEqual(const GA_RangeTypeInterface &src) const =0