InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IRIDX.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Paul Messmer
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 __IRIDX__
25 #define __IRIDX__
26 
27 #include "ShuksanID.h"
28 #include "IDataBase.h"
29 
30 #include <utility>
31 #include <vector>
32 
33 //========================================================================================
34 
46 {
47 private:
48 
49  UID fUID;
50  ImplementationID fImplID;
51 
52 public:
53 
57  {}
58 
63  RIDXSource (UID sourceUID, ImplementationID sourceImplID) :
64  fUID (sourceUID),
65  fImplID (sourceImplID)
66  {}
67 
72  RIDXSource (uint32 sourceUID, uint32 sourceImplID) :
73  fUID (UID (sourceUID)),
74  fImplID (ImplementationID (sourceImplID))
75  {}
76 
80  UID GetUID () const { return fUID; }
81 
85  ImplementationID GetImplID () const { return fImplID; }
86 };
87 
88 //========================================================================================
89 
90 inline bool operator == (const RIDXSource &lhs, const RIDXSource &rhs)
91 {
92  return lhs.GetUID () == rhs.GetUID () &&
93  lhs.GetImplID () == rhs.GetImplID ();
94 }
95 
96 inline bool operator != (const RIDXSource &lhs, const RIDXSource &rhs)
97 {
98  return lhs.GetUID () != rhs.GetUID () ||
99  lhs.GetImplID () != rhs.GetImplID ();
100 }
101 
102 inline bool operator < (const RIDXSource &lhs, const RIDXSource &rhs)
103 {
104  if (lhs.GetUID () > rhs.GetUID ()) return false;
105  if (lhs.GetUID () < rhs.GetUID ()) return true;
106  return lhs.GetImplID () < rhs.GetImplID ();
107 }
108 
109 //========================================================================================
110 
122 {
123 public:
124 
128  enum Type
129  {
134 
139  };
140 
141 private:
142 
143  uint32 fType;
144  uint32 fValue;
145 
146 public:
147 
151  fType(0),
152  fValue(0)
153  {}
154 
159  RIDXTarget (Type targetType, uint32 targetValue) :
160  fType ((uint32) targetType),
161  fValue (targetValue)
162  {}
163 
168  RIDXTarget (uint32 targetType, uint32 targetValue) :
169  fType (targetType),
170  fValue (targetValue)
171  {}
172 
176  RIDXTarget::Type GetType () const { return RIDXTarget::Type (fType); }
177 
181  uint32 GetValue () const { return fValue; }
182 };
183 
184 //========================================================================================
185 
186 inline bool operator == (const RIDXTarget &lhs, const RIDXTarget &rhs)
187 {
188  return lhs.GetType () == rhs.GetType () &&
189  lhs.GetValue () == rhs.GetValue ();
190 }
191 
192 inline bool operator != (const RIDXTarget &lhs, const RIDXTarget &rhs)
193 {
194  return lhs.GetType () != rhs.GetType () ||
195  lhs.GetValue () != rhs.GetValue ();
196 }
197 
198 inline bool operator < (const RIDXTarget &lhs, const RIDXTarget &rhs)
199 {
200  if ((uint32) lhs.GetType () > (uint32) rhs.GetType ()) return false;
201  if ((uint32) lhs.GetType () < (uint32) rhs.GetType ()) return true;
202  return lhs.GetValue () < rhs.GetValue ();
203 }
204 
205 //========================================================================================
206 
218 {
219  RIDXSource fSource;
220  RIDXTarget fTarget;
221 
222 public:
223 
227  {}
228 
234  fSource (source),
235  fTarget (target)
236  {}
237 
244  RIDXReference (UID sourceUID, ImplementationID sourceImplID, RIDXTarget::Type targetType, uint32 targetValue) :
245  fSource (RIDXSource (sourceUID, sourceImplID)),
246  fTarget (RIDXTarget (targetType, targetValue))
247  {}
248 
255  RIDXReference (uint32 sourceUID, uint32 sourceImplID, uint32 targetType, uint32 targetValue) :
256  fSource (RIDXSource (sourceUID, sourceImplID)),
257  fTarget (RIDXTarget (targetType, targetValue))
258  {}
259 
263  RIDXSource GetSource () const { return fSource; }
264 
268  RIDXTarget GetTarget () const { return fTarget; }
269 };
270 
271 //========================================================================================
272 
273 inline bool operator == (const RIDXReference &lhs, const RIDXReference &rhs)
274 {
275  return lhs.GetSource ().GetUID () == rhs.GetSource ().GetUID () &&
276  lhs.GetSource ().GetImplID () == rhs.GetSource ().GetImplID () &&
277  lhs.GetTarget ().GetType () == rhs.GetTarget ().GetType () &&
278  lhs.GetTarget ().GetValue () == rhs.GetTarget ().GetValue ();
279 }
280 
281 inline bool operator != (const RIDXReference &lhs, const RIDXReference &rhs)
282 {
283  return lhs.GetSource ().GetUID () != rhs.GetSource ().GetUID () ||
284  lhs.GetSource ().GetImplID () != rhs.GetSource ().GetImplID () ||
285  lhs.GetTarget ().GetType () != rhs.GetTarget ().GetType () ||
286  lhs.GetTarget ().GetValue () != rhs.GetTarget ().GetValue ();
287 }
288 
289 inline bool operator < (const RIDXReference &lhs, const RIDXReference &rhs)
290 {
291  if (lhs.GetSource ().GetUID () > rhs.GetSource ().GetUID ()) return false;
292  if (lhs.GetSource ().GetUID () < rhs.GetSource ().GetUID ()) return true;
293  if (lhs.GetSource ().GetImplID () > rhs.GetSource ().GetImplID ()) return false;
294  if (lhs.GetSource ().GetImplID () < rhs.GetSource ().GetImplID ()) return true;
295  if ((uint32) lhs.GetTarget ().GetType () > (uint32) rhs.GetTarget ().GetType ()) return false;
296  if ((uint32) lhs.GetTarget ().GetType () < (uint32) rhs.GetTarget ().GetType ()) return true;
297  return lhs.GetTarget ().GetValue () < rhs.GetTarget ().GetValue ();
298 }
299 
300 //========================================================================================
301 
302 class IRIDXQuery;
303 
304 class IRIDX;
305 
306 //========================================================================================
307 
311 class IRIDXAccess : public IPMUnknown
312 {
313 public:
314  enum { kDefaultIID = IID_IRIDXACCESS };
315 
319  virtual IRIDX *QueryRIDX() = 0;
320 
324  virtual UIDRef GetRIDX() = 0;
325 };
326 
327 //========================================================================================
328 
329 namespace RIDXAccess
330 {
331  inline IRIDX *QueryRIDX (IDataBase *db)
332  {
333  InterfacePtr<IRIDXAccess> ridxAccess (db, db->GetRootUID(), UseDefaultIID());
334  return ridxAccess ? ridxAccess->QueryRIDX () : 0;
335  }
336 }
337 
338 //========================================================================================
339 
384 class IRIDX : public IPMUnknown
385 {
386 public:
387 
388  enum { kDefaultIID = IID_IRIDX };
389 
390  typedef std::vector<RIDXTarget> Targets; // These typedefs are not Doc++ commented
391  typedef std::vector<RIDXSource> Sources; // because they are not used in the current
392  typedef std::vector<RIDXReference> References; // set of public APIs.
393 
398  virtual void Initialize () = 0;
399 
404  virtual void ProcessScheduledIndexing () = 0;
405 
410  {
413 
416  };
417 
422  {
425 
428  };
429 
490  virtual IRIDXQuery *CreateQuery (QueryType queryType, CoherencyType coherencyType) const = 0;
491 
495  virtual bool HasOutstandingQuery () const = 0;
496 
500  virtual bool HasOutstandingLockedQuery () const = 0;
501 
507  virtual void WontProcessScheduledIndexing () = 0;
508 
513  virtual bool UpdateInProgress () const = 0;
514 };
515 
516 //========================================================================================
517 
524 class IRIDXQuery : public IPMUnknown
525 {
526 public:
527  enum { kDefaultIID = IID_IRIDXQUERY };
528 
532  virtual IDataBase *GetDataBase () = 0;
533 
540  virtual void StartTarget (RIDXTarget target) = 0;
541 
548  virtual bool GetNextSource (RIDXSource &source) = 0;
549 };
550 
551 //========================================================================================
552 
553 #endif // __IRIDX__
554 
555