HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_Filter.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  * COMMENTS:
7  */
8 
9 #ifndef PDG_FILTER_H
10 #define PDG_FILTER_H
11 
12 #include "PDG_API.h"
13 #include "PDG_Types.h"
14 
15 /**
16  * An item id filter that describes what static item ids to cook. The filter is
17  * either a single id, a range of ids or a set of ids.
18  */
20 {
21 public:
22  /// Storage method the filter uses to keep track of ids
23  enum Type
24  {
25  eSingle, /// A single item id
26  eRange, /// An inclusive range of item ids
27  eSet, /// A set of aribitrary ids, possibly disjoint
28  eInvalid, /// An invalid filter that cannot be used
29  };
30 
31 
32  /// Constructs a new filter, which is all by default
34  : myType(eSingle)
35  , myIsStrict(false)
36  {
37  }
38 
39  /// Constructs a filter with a specific value for the Strict flag. A Strict
40  /// filter will cook exactly the desired static item set, not the set +
41  /// other dependencies
42  PDG_Filter(bool is_strict)
43  : myType(eSingle)
44  , myIsStrict(is_strict)
45  {
46  }
47 
48  /// Returns true if the filter is set to cook all static items
49  bool isAll() const
50  {
51  return (myType != eInvalid) && mySet.empty();
52  }
53 
54  /// Returns true if the given id matches that ones that this filter
55  /// wishes to cook
56  bool apply(PDG_WorkItemID id) const
57  {
58  if (myType == eInvalid)
59  return false;
60  else if (mySet.size() == 0)
61  return true;
62 
63  return mySet.contains(id);
64  }
65 
66  /// Configures the filter to cook nothing
67  void setNone()
68  {
69  myType = eInvalid;
70  mySet.clear();
71  }
72 
73  /// Configures the filter so that it specifies all static items
74  void setAll()
75  {
76  myType = eSingle;
77  mySet.clear();
78  }
79 
80  /// Configures the filter to cook a single static item
82  {
83  myType = eSingle;
84 
85  mySet.clear();
86  mySet.insert(single);
87  }
88 
89  /// Configures the filter to cook an inclusive range of work items
91  {
92  myType = eRange;
93 
94  mySet.clear();
95  for (int i = start; i <= end; i++)
96  mySet.insert(i);
97  }
98 
99  /// Configures the filter to cook a set of items
100  void setSet(const PDG_WorkItemIDSet& set)
101  {
102  myType = eSet;
103  mySet = set;
104  }
105 
106  /// Appends an id to the set of static items to cook
108  {
109  if (myType != eSingle || !mySet.empty())
110  {
111  myType = eSet;
112  mySet.insert(id);
113  }
114  }
115 
117  {
118  mySet.erase(id);
119  }
120 
121  /// Returns the filter cook type
122  Type type() const { return myType; }
123 
124  /// Returns the filter id set
125  const PDG_WorkItemIDSet& set() const { return mySet; }
126 
127  /// Returns true if the filter is strict
128  bool strict() const { return myIsStrict; }
129 
130 private:
131  Type myType;
132  PDG_WorkItemIDSet mySet;
133  bool myIsStrict;
134 };
135 
136 #endif
void setRange(PDG_WorkItemID start, PDG_WorkItemID end)
Configures the filter to cook an inclusive range of work items.
Definition: PDG_Filter.h:90
void eraseFromSet(PDG_WorkItemID id)
Definition: PDG_Filter.h:116
GLuint start
Definition: glcorearb.h:475
#define PDG_API
Definition: PDG_API.h:23
An inclusive range of item ids.
Definition: PDG_Filter.h:27
Type
Storage method the filter uses to keep track of ids.
Definition: PDG_Filter.h:23
A single item id.
Definition: PDG_Filter.h:26
void setSet(const PDG_WorkItemIDSet &set)
Configures the filter to cook a set of items.
Definition: PDG_Filter.h:100
void setAll()
Configures the filter so that it specifies all static items.
Definition: PDG_Filter.h:74
bool isAll() const
Returns true if the filter is set to cook all static items.
Definition: PDG_Filter.h:49
PDG_Filter(bool is_strict)
Definition: PDG_Filter.h:42
Type type() const
Returns the filter cook type.
Definition: PDG_Filter.h:122
GLuint GLuint end
Definition: glcorearb.h:475
void appendToSet(PDG_WorkItemID id)
Appends an id to the set of static items to cook.
Definition: PDG_Filter.h:107
bool apply(PDG_WorkItemID id) const
Definition: PDG_Filter.h:56
void setSingle(PDG_WorkItemID single)
Configures the filter to cook a single static item.
Definition: PDG_Filter.h:81
void setNone()
Configures the filter to cook nothing.
Definition: PDG_Filter.h:67
PDG_Filter()
Constructs a new filter, which is all by default.
Definition: PDG_Filter.h:33
exint PDG_WorkItemID
Type defs for unique work item IDs.
Definition: PDG_Types.h:48
const PDG_WorkItemIDSet & set() const
Returns the filter id set.
Definition: PDG_Filter.h:125
A set of aribitrary ids, possibly disjoint.
Definition: PDG_Filter.h:28
bool strict() const
Returns true if the filter is strict.
Definition: PDG_Filter.h:128