InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
OMTypes.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner:
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __OMTypes__
25 #define __OMTypes__
26 
27 #ifndef __AnsiBasedTypes__
28 #include "AnsiBasedTypes.h"
29 #endif
30 
31 #include "K2TypeTraits.h"
32 // ** These classes are used in the debug build to catch **
33 // ** unintended typecast. For example, using a ClassID **
34 // ** when we really want to use an ImplementationID. **
35 
36 struct UID_tag {};
37 struct ClassID_tag {};
38 struct PMIID_tag {};
40 struct PluginID_tag {};
41 struct ServiceID_tag {};
42 struct WidgetID_tag {};
43 struct KitViewID_tag {};
44 struct ActionID_tag {};
47 struct ProductID_tag {} ;
48 struct AsyncUIID_tag {} ;
49 struct ScriptID_tag {} ;
53 struct LinkClientID_tag {};
54 struct SnapshotID_tag {};
57 
71 template<class T>
72 class IDType
73 {
74  public:
75  typedef base_type data_type;
76  typedef int32 difference_type;
77  typedef uint32 value_type;
78 
79  constexpr IDType() noexcept : fIDInt(0) {}
80  //~IDType() {}
81 
82  constexpr IDType(const IDType &) noexcept = default;
83  IDType& operator=(const IDType &) noexcept = default;
84  constexpr IDType(IDType &&) noexcept = default;
85  IDType& operator=(IDType && ) noexcept = default;
86 
87  constexpr IDType(value_type sourceInt) noexcept : fIDInt(sourceInt) {}
88  IDType& operator=(const value_type& sourceInt) noexcept {fIDInt = sourceInt; return *this;}
89 
90  bool operator>(const IDType& rhs) const noexcept { return fIDInt > rhs.fIDInt; }
91  bool operator>(const value_type& rhs) const noexcept { return fIDInt > rhs; }
92  friend bool operator>(const value_type& lhs, const IDType<T>& rhs) noexcept { return lhs > rhs.fIDInt; }
93 
94  bool operator<(const IDType& rhs) const noexcept { return fIDInt < rhs.fIDInt; }
95  bool operator<(const value_type& rhs) const noexcept { return fIDInt < rhs; }
96  friend bool operator<(const value_type& lhs, const IDType<T>& rhs) noexcept { return lhs < rhs.fIDInt; }
97 
98  bool operator<=(const IDType& rhs) const noexcept { return !(fIDInt > rhs.fIDInt); }
99  bool operator<=(const value_type& rhs) const noexcept { return !(fIDInt > rhs); }
100  friend bool operator<=(const value_type& lhs, const IDType<T>& rhs) noexcept { return !(lhs > rhs.fIDInt); }
101 
102  bool operator>=(const IDType& rhs) const noexcept { return !(fIDInt < rhs.fIDInt); }
103  bool operator>=(const value_type& rhs) const noexcept { return !(fIDInt < rhs); }
104  friend bool operator>=(const value_type& lhs, const IDType<T>& rhs) noexcept { return !(lhs < rhs.fIDInt); }
105 
106  bool operator==(const IDType& rhs) const noexcept { return fIDInt == rhs.fIDInt; }
107  friend bool operator==(const value_type& lhs, const IDType<T>& rhs) noexcept { return lhs == rhs.fIDInt; }
108 
109  bool operator!=(const IDType& rhs) const noexcept { return !(fIDInt == rhs.fIDInt); }
110  bool operator!=(const value_type& rhs) const noexcept { return !(fIDInt == rhs); }
111  friend bool operator!=(const value_type& lhs, const IDType<T>& rhs) noexcept { return !(lhs == rhs.fIDInt); }
112 
113  IDType& operator+=(const difference_type& rhs) { fIDInt += rhs; return *this; }
114  friend IDType<T> operator+(const IDType<T>& lhs, const difference_type& rhs) { return IDType<T>(lhs) += rhs; }
115  friend IDType<T> operator+(const IDType<T>& lhs, const IDType<T>& rhs) { return IDType<T>(lhs) += rhs.fIDInt; }
116  friend IDType<T> operator+(const difference_type& lhs, const IDType<T> rhs) { return IDType<T>(rhs) += lhs; }
117 
118  // prefix
119  IDType& operator++() { *this += 1; return *this; }
120  // postfix
121  const IDType operator++(int) { IDType oldValue = *this; ++(*this); return oldValue; }
122 
123  IDType& operator-=(const IDType& rhs) { fIDInt -= rhs.fIDInt; return *this; }
124  IDType& operator-=(const difference_type& rhs) { fIDInt -= rhs; return *this; }
125  friend IDType<T> operator-(const difference_type& lhs, IDType<T> rhs) { return IDType<T>(rhs) -= lhs; }
126  friend difference_type operator-(const IDType<T>& lhs, const difference_type& rhs) { return lhs.fIDInt - rhs; }
127  friend difference_type operator-(const IDType<T>& lhs, const IDType<T>& rhs) { return lhs.fIDInt - rhs.fIDInt; }
128 
129  // prefix
130  IDType& operator--() { *this -= 1; return *this; }
131  // postfix
132  const IDType operator--(int) { IDType oldValue = *this; --(*this); return oldValue; }
133 
134  value_type operator>>(const int& rhs) const { return fIDInt >> rhs; }
135  value_type operator<<(const int& rhs) const { return fIDInt << rhs; }
136 
137  value_type operator&(const value_type& rhs) const { return fIDInt & rhs; }
138  friend value_type operator&(const value_type& lhs, const IDType<T>& rhs) { return IDType<T>(rhs) & lhs; }
139 
140  value_type operator|(const value_type& rhs) { return fIDInt | rhs; }
141  friend value_type operator|(const value_type& lhs, const IDType<T>& rhs) { return IDType<T>(rhs) | lhs; }
142 
143  IDType& operator|=(const value_type& rhs) { fIDInt |= rhs; return *this; }
144 // friend value_type operator|=(const value_type& lhs, const IDType<T>& rhs) { lhs |= rhs.fIDInt; return lhs; }
145 
146  value_type& Get() noexcept { return fIDInt; }
147  inline const value_type& Get() const noexcept { return fIDInt; }
148 
149  bool IsValid() const noexcept { return (fIDInt != 0); }
150 
151  static bool less_IDType(IDType<T>& lhs, IDType<T>& rhs)
152  {
153  return lhs.Get() < rhs.Get();
154  }
155 
156 // operator uint32&() { return fIDInt; }
157 // operator uint32() { return fIDInt; }
158 
159  private:
160  value_type fIDInt;
161 };
162 
163 // Global operators
164 template<class T>
165 inline bool operator<(const IDType<T>& lhs, const IDType<T>& rhs) noexcept
166 {
167  return lhs.Get() < rhs.Get();
168 }
169 
170 template<class T>
171 inline bool operator==(const IDType<T>& lhs, const IDType<T>& rhs) noexcept
172 {
173  return lhs.Get() == rhs.Get();
174 }
175 
176 template <class T>
178  static typename IDType<T>::value_type CONVERT(IDType<T> arg) {return arg.Get();}
179 };
180 
181 
182 // typedef the ID types we need.
183 
190 typedef uint32 SBOSID;
192 constexpr SBOSID kInvalidSBOSID = 0;
193 
196 typedef IDType<UID_tag> UID;
197 
201 
204 typedef IDType<PMIID_tag> PMIID;
205 
209 
213 
217 
219 
230 
234 
238 
242 
246 
247 
248 // OM constants
249 
251 constexpr UID kInvalidUID;
253 constexpr WidgetID kInvalidWidgetID;
255 constexpr ClassID kInvalidClass;
257 constexpr PluginID kInvalidPlugin;
259 constexpr ImplementationID kInvalidImpl;
261 constexpr ServiceID kInvalidService;
263 constexpr PMIID kInvalidInterfaceID;
265 constexpr KitViewID kInvalidKitViewID;
267 constexpr ActionID kInvalidActionID;
269 constexpr FileTypeInfoID kInvalidFileTypeInfoID;
271 constexpr ScriptElementID kInvalidScriptElementID;
273 constexpr ProductID kInvalidProdcutID;
275 constexpr AsyncUIID kInvalidAsyncUIID;
277 constexpr ScriptID kInvalidScriptID;
279 constexpr UserActionCategoryID kInvalidUserActionCategoryID;
281 constexpr InvalHandlerID kInvalidInvHandID;
283 constexpr LinkClientID kInvalidLinkClientID;
285 constexpr SnapshotID kInvalidSnapshotID;
287 constexpr LastRevInfoID kInvalidLastRevInfoID;
289 constexpr DontShowAgainID kInvalidDontShowAgainID;
290 
291 
292 // common defs used by interfaces
294 constexpr bool16 kFalse = 0;
296 constexpr bool16 kTrue = 1;
297 
298 #ifndef nil
299 #define nil nullptr
300 #endif
301 
302 #endif // __OMTypes__