HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GA_PrimitiveTypeMask.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_PrimitiveTypeMask.h (GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_PrimitiveTypeMask_h__
12 #define __GA_PrimitiveTypeMask_h__
13 
14 #include "GA_API.h"
15 
16 #include "GA_PrimitiveTypeId.h"
17 
18 #include <SYS/SYS_Types.h>
19 #include <iterator>
20 
21 class UT_BitArray;
23 
25 {
26 public:
28  {
29  explicit FamilyBitMask(unsigned m) : myMask(m) {}
30  unsigned getMask() const { return myMask; }
31  private:
32  unsigned myMask;
33  };
34 
36  {
37  explicit FactoryTypeBitMask(unsigned m) : myMask(m) {}
38  unsigned getMask() const { return myMask; }
39  private:
40  unsigned myMask;
41  };
42 
44  : myBaseMask(0), myExtendedMask(NULL)
45  {
46  }
48  const FamilyBitMask &mask)
49  : myBaseMask(0), myExtendedMask(NULL)
50  {
51  init(factory, mask);
52  }
54  : myBaseMask(mask.getMask()), myExtendedMask(NULL)
55  {
56  }
57 
59 
60  bool includes(GA_PrimitiveTypeId type_id) const;
61  bool excludes(GA_PrimitiveTypeId type_id) const
62  { return !includes(type_id); }
63 
64  void add(GA_PrimitiveTypeId type_id);
65  void remove(GA_PrimitiveTypeId type_id);
66 
67  void operator|=(const GA_PrimitiveTypeMask &m);
68  void operator&=(const GA_PrimitiveTypeMask &m);
69  void operator-=(const GA_PrimitiveTypeMask &m);
70  bool operator==(const GA_PrimitiveTypeMask &m);
71  bool operator!=(const GA_PrimitiveTypeMask &m);
72 
73  class const_iterator :
74  public std::iterator<std::forward_iterator_tag, const GA_PrimitiveTypeId>
75  {
76  public:
77  const GA_PrimitiveTypeId &operator*() const { return myId; }
78 
79  bool operator==(const const_iterator &other) const
80  { return myId == other.myId; }
81  bool operator!=(const const_iterator &other) const
82  { return myId != other.myId; }
83 
85  {
86  myId = myMask.getNextType(myId);
87  return *this;
88  }
89 
90  protected:
91  friend class GA_PrimitiveTypeMask;
93  const GA_PrimitiveTypeId &id) : myMask(mask), myId(id) {}
94  private:
95  // Delete the post-increment operator.
96  const_iterator &operator++(int);
97 
98  const GA_PrimitiveTypeMask &myMask;
99  GA_PrimitiveTypeId myId;
100  };
101 
102  /// Returns an iterator representing the beginning of the range for the
103  /// type ids contained with this mask.
105  { return const_iterator(*this, getFirstType()); }
106 
107  /// Returns an iterator representing the end of the range for the
108  /// type ids contained with this mask.
110  { return const_iterator(*this, GA_PrimitiveTypeId()); }
111 
112  SYS_SAFE_BOOL operator bool() const;
113 
114 private:
116 
117  /// Initialize primitive mask using a family mask.
118  void init(const GA_PrimitiveFactory &factory,
119  const FamilyBitMask &mask);
120 
121  GA_PrimitiveTypeId getFirstType() const;
122  GA_PrimitiveTypeId getNextType(GA_PrimitiveTypeId c) const;
123 
124  friend const GA_PrimitiveTypeMask operator|
125  (const GA_PrimitiveTypeMask &m1, const GA_PrimitiveTypeMask &m2);
126  friend const GA_PrimitiveTypeMask operator&
127  (const GA_PrimitiveTypeMask &m1, const GA_PrimitiveTypeMask &m2);
128 #if 0
129  friend const GA_PrimitiveTypeMask operator~
130  (const GA_PrimitiveTypeMask &m1);
131 #endif
132 
133  uint64 myBaseMask;
134  UT_BitArray *myExtendedMask;
135 };
136 
137 // Binary Operations on GA_TypeMask
138 inline const GA_PrimitiveTypeMask
140 {
141  GA_PrimitiveTypeMask m(m1);
142  m |= m2;
143  return m;
144 }
145 inline const GA_PrimitiveTypeMask
147 {
148  GA_PrimitiveTypeMask m(m1);
149  m &= m2;
150  return m;
151 }
152 
153 // TODO: Cannot invert without a GA_PrimitiveFactory reference...
154 #if 0
155 inline const GA_PrimitiveTypeMask
157 {
158  GA_PrimitiveTypeMask m(m1);
159  m.invert();
160  return m;
161 }
162 #endif
163 
164 #endif
const GA_PrimitiveTypeId & operator*() const
const_iterator begin() const
GA_PrimitiveTypeMask(const GA_PrimitiveFactory &factory, const FamilyBitMask &mask)
const TypeMask operator~(const TypeMask &m1)
Definition: GA_PrimCompat.h:95
const_iterator(const GA_PrimitiveTypeMask &mask, const GA_PrimitiveTypeId &id)
const GA_PrimitiveTypeMask operator&(const GA_PrimitiveTypeMask &m1, const GA_PrimitiveTypeMask &m2)
bool operator==(const const_iterator &other) const
GLint GLuint mask
Definition: glcorearb.h:123
#define GA_API
Definition: GA_API.h:12
bool operator!=(const const_iterator &other) const
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
unsigned long long uint64
Definition: SYS_Types.h:101
#define SYS_SAFE_BOOL
Definition: SYS_Compiler.h:56
bool excludes(GA_PrimitiveTypeId type_id) const
const_iterator end() const
GA_PrimitiveTypeMask(const FactoryTypeBitMask &mask)
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:165
const GA_PrimitiveTypeMask operator|(const GA_PrimitiveTypeMask &m1, const GA_PrimitiveTypeMask &m2)