HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_AttributeFilter.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_AttributeFilter.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_AttributeFilter__
12 #define __GA_AttributeFilter__
13 
14 #include "GA_API.h"
15 #include "GA_Types.h"
16 
17 #include <UT/UT_IntrusivePtr.h>
18 
19 #include <stddef.h>
20 
21 
22 class GA_Attribute;
23 
24 
25 // This enum is used to identify boolean operations on filters
27 {
31 };
32 
33 // GA_AttributeFilterImpl is the base class for the implementation of an
34 // attribute filter. These objects are reference counted and managed by
35 // the GA_AttributeFilter (handle) object.
37  : public UT_IntrusiveRefCounter<GA_AttributeFilterImpl>
38 {
39 public:
41  virtual ~GA_AttributeFilterImpl();
42 
43  virtual bool match(const GA_Attribute *atr) const = 0;
44  virtual bool terminateAfterFirstMatch() const { return false; }
45 
46 protected:
47 
48  template <typename T> static bool isType(const GA_Attribute *atr)
49  { return T::isType(atr); }
50 };
51 
52 // GA_AttributeFilter is a handle object to a GA_AttributeFilterImpl. This
53 // class properly supports return-by-value and pass-by-value semantics.
55 {
56 public:
58  {
59  }
61  const GA_AttributeFilter &f0,
62  const GA_AttributeFilter &f1)
63  {
64  switch (op)
65  {
67  *this = selectAnd(f0, f1);
68  break;
70  *this = GA_AttributeFilter::selectXor(f0, f1);
71  break;
72  default:
73  *this = GA_AttributeFilter::selectOr(f0, f1);
74  break;
75  }
76  }
77 
78  // This constructor takes over the current reference to the
79  // supplied implementation to properly support calls of the
80  // form GA_AttributeFilter(new GA_AttributeFilterImpl).
82  : myImpl(impl) {}
83 
84  bool match(const GA_Attribute *atr) const
85  { return myImpl ? myImpl->match(atr) : false; }
87  { return myImpl ? myImpl->terminateAfterFirstMatch() : false; }
88 
89  bool isValid() const
90  { return myImpl != NULL; }
91  //----------------------------------------------
92  /// Class factories
93 
94  /// selectAll was removed in H16 because it is almost certainly
95  /// not what you want or what you think it does. It also selects
96  /// internal and private attributes that can result in looping
97  /// over selections crashing.
98  /// You should replace your calls with selectPublic().
99  // static GA_AttributeFilter selectAll();
100 
101  // Select "standard" will select standard factory attribute types,
102  // excluding groups and topology. Optionally, a single attribute can be
103  // excluded from the filter.
104  static GA_AttributeFilter selectStandard(const GA_Attribute *exclude=0);
105 
106  /// Select "factory" will select all factory (non-HDK-registered) types.
107  static GA_AttributeFilter selectFactory(const GA_Attribute *exclude=0);
108 
109  // These filters will also detect any sub-classes of the given types
110  static GA_AttributeFilter selectNumeric(); // Subclass of numeric
111  static GA_AttributeFilter selectTransforming(bool include_P);
112  static GA_AttributeFilter selectString(); // String attributes
113  static GA_AttributeFilter selectAlphaNum(); // String || Numeric
114  static GA_AttributeFilter selectIndexPair(); // Index pair attributes
115  static GA_AttributeFilter selectBlindData(); // Subclass of blinddata
116  static GA_AttributeFilter selectGroup(); // Only groups
117  static GA_AttributeFilter selectTopology(); // Only topological atrs
118 
119  /// Select public scope attributes and non-internal groups.
120  static GA_AttributeFilter selectPublic(
121  bool include_noninternal_groups = true);
122 
123  // Select based on typename (more generic than above specialized filters)
124  // This filter will only matches the exact type (not any sub-classes).
125  static GA_AttributeFilter selectType(const char *type);
126 
127  /// Select based on the type info
128  static GA_AttributeFilter selectTypeInfo(GA_TypeInfo info);
129 
130  // Select based on storage type
131  static GA_AttributeFilter selectTupleByStorage(GA_Storage store);
132  static GA_AttributeFilter selectFloatTuple(bool include_P=true);
133  static GA_AttributeFilter selectFloatNumeric(bool include_P=true);
134 
135  // Select by name (or pattern)
136  static GA_AttributeFilter selectByName(const char *name);
137  static GA_AttributeFilter selectByPattern(const char *pattern);
138 
139  // Select based on tuple size, either an exact match or in a range. The
140  // range is inclusive (i.e. selectByTupleRange(3,3) will match only
141  // 3-tuples)
143  { return selectByTupleRange(size,size);}
144  static GA_AttributeFilter selectByTupleRange(int min_range,
145  int max_range=1024*1024*1024);
146 
147  // Select all except for the specified attribute. This is equivalent to
148  // selectAll() if passed 0.
149  static GA_AttributeFilter selectAllExcept(const GA_Attribute *except);
150 
151  // Group specific filters
152  static GA_AttributeFilter selectEmptyGroup();
153  static GA_AttributeFilter selectOrderedGroup();
154 
155  // Boolean operations on selections
156  static GA_AttributeFilter selectNot(const GA_AttributeFilter &f0,
157  bool single_match=false);
158  static GA_AttributeFilter selectAnd(const GA_AttributeFilter &f0,
159  const GA_AttributeFilter &f1,
160  bool single_match=false);
161  static GA_AttributeFilter selectOr(const GA_AttributeFilter &f0,
162  const GA_AttributeFilter &f1,
163  bool single_match=false);
164  static GA_AttributeFilter selectXor(const GA_AttributeFilter &f0,
165  const GA_AttributeFilter &f1,
166  bool single_match=false);
167 
168 private:
170 };
171 
172 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
static bool isType(const GA_Attribute *atr)
#define GA_API
Definition: GA_API.h:14
bool terminateAfterFirstMatch() const
A reference counter base class for use with UT_IntrusivePtr.
static GA_AttributeFilter selectXor(const GA_AttributeFilter &f0, const GA_AttributeFilter &f1, bool single_match=false)
GA_AttributeFilterBooleanOp
static GA_AttributeFilter selectByTupleSize(int size)
bool match(const GA_Attribute *atr) const
GLuint const GLchar * name
Definition: glcorearb.h:786
GA_AttributeFilter(GA_AttributeFilterImpl *impl)
GLushort pattern
Definition: glad.h:2583
GA_TypeInfo
Definition: GA_Types.h:101
GA_AttributeFilter(GA_AttributeFilterBooleanOp op, const GA_AttributeFilter &f0, const GA_AttributeFilter &f1)
GLsizeiptr size
Definition: glcorearb.h:664
virtual bool terminateAfterFirstMatch() const
static GA_AttributeFilter selectOr(const GA_AttributeFilter &f0, const GA_AttributeFilter &f1, bool single_match=false)
type
Definition: core.h:1059
GA_Storage
Definition: GA_Types.h:51