HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_PrimCompat.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_PrimCompat.h (GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_PrimCompat_h__
12 #define __GA_PrimCompat_h__
13 
14 #include "GA_API.h"
15 #include "GA_PrimitiveTypeMask.h"
16 
17 #include <SYS/SYS_Compiler.h>
18 #include <SYS/SYS_Types.h>
19 
20 class UT_TokenString;
21 
22 /// Namespace for storing transitional types to provide source compatibility
23 /// with the old bitmask primitive type detection.
24 
25 namespace GA_PrimCompat
26 {
27 
28 // Ensure enum is in the GA_PrimCompat namespace
30 enum
31 {
32  TypeMaskBits = std::numeric_limits<value_type>::digits
33 };
34 
36 {
37 public:
38  TypeMask() {}
40  : myMask(mask) {}
41 
42  static TypeMask fullMask() { return TypeMask(~(value_type)0); }
43 
44  void operator|=(const TypeMask &m)
45  { myMask |= m.myMask; }
46  void operator&=(const TypeMask &m)
47  { myMask &= m.myMask; }
48  void operator^=(const TypeMask &m)
49  { myMask ^= m.myMask; }
50  bool operator==(const TypeMask &m) const
51  { return myMask == m.myMask; }
52  bool operator!=(const TypeMask &m) const
53  { return !operator==(m); }
54 
55  void save(UT_TokenString &token_string) const;
56 
57  /// Convert from new-style primitive type mask to this old-style one.
58  /// Avoid using if possible and modify the function that requires the
59  /// mask as an argument, instead.
60  /// Returns \c false if it was unable to convert all the bits from the
61  /// type mask into the old-school mask.
62  bool setFromPrimitiveTypeMask(const GA_PrimitiveTypeMask &mask);
63 
64  operator GA_PrimitiveTypeMask() const;
65 
66  SYS_SAFE_BOOL inline operator bool() const { return myMask != 0; }
67 
68 private:
69  friend const TypeMask operator|(const TypeMask &m1, const TypeMask &m2);
70  friend const TypeMask operator&(const TypeMask &m1, const TypeMask &m2);
71  friend const TypeMask operator^(const TypeMask &m1, const TypeMask &m2);
72  friend const TypeMask operator~(const TypeMask &m1);
73 
74  value_type myMask;
75 };
76 
77 // Binary Operations on GA_TypeMask
78 inline const TypeMask
79 operator|(const TypeMask &m1, const TypeMask &m2)
80 {
81  return TypeMask(m1.myMask | m2.myMask);
82 }
83 inline const TypeMask
84 operator&(const TypeMask &m1, const TypeMask &m2)
85 {
86  return TypeMask(m1.myMask & m2.myMask);
87 }
88 
89 inline const TypeMask
90 operator^(const TypeMask &m1, const TypeMask &m2)
91 {
92  return TypeMask(m1.myMask ^ m2.myMask);
93 }
94 inline const TypeMask
95 operator~(const TypeMask &m1)
96 {
97  return TypeMask(~m1.myMask);
98 }
99 
100 }
101 
102 #endif
const TypeMask operator~(const TypeMask &m1)
Definition: GA_PrimCompat.h:95
bool operator==(const TypeMask &m) const
Definition: GA_PrimCompat.h:50
void operator^=(const TypeMask &m)
Definition: GA_PrimCompat.h:48
void operator&=(const TypeMask &m)
Definition: GA_PrimCompat.h:46
#define GA_API
Definition: GA_API.h:14
unsigned long long uint64
Definition: SYS_Types.h:117
uint64 value_type
Definition: GA_PrimCompat.h:29
TypeMask(value_type mask)
Definition: GA_PrimCompat.h:39
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
#define SYS_SAFE_BOOL
Definition: SYS_Compiler.h:55
GLint GLuint mask
Definition: glcorearb.h:124
const TypeMask operator|(const TypeMask &m1, const TypeMask &m2)
Definition: GA_PrimCompat.h:79
static TypeMask fullMask()
Definition: GA_PrimCompat.h:42
bool operator!=(const TypeMask &m) const
Definition: GA_PrimCompat.h:52
const TypeMask operator&(const TypeMask &m1, const TypeMask &m2)
Definition: GA_PrimCompat.h:84
void operator|=(const TypeMask &m)
Definition: GA_PrimCompat.h:44
const TypeMask operator^(const TypeMask &m1, const TypeMask &m2)
Definition: GA_PrimCompat.h:90