InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
InterfaceInfo.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Robin_Briggs
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 // Wraps interface information for a class.
24 //
25 //========================================================================================
26 
27 #ifndef __InterfaceInfo__
28 #define __InterfaceInfo__
29 
30 #include "OMTypes.h"
31 #include "IPMStream.h"
32 #include "PersistBaseTypes.h"
33 #include "IPlugIn.h"
34 
35 extern IPlugIn::ThreadingPolicy GetPluginThreadingPolicy(PluginID pluginID);
36 
40 public:
41  typedef base_type data_type;
42 
43  InterfaceInfo() :
44 #ifdef USE_ALLOCATE_WITH_BOSS
45  fFaceID(IID_IUNKNOWN), fImplID(kInvalidImpl), fOwner(kInvalidPlugin), fIsAddin(kFalse), fOffset(0), fThreadingPolicy(IPlugIn::kUnknownThreadingPolicy)
46 #else
47  fFaceID(IID_IUNKNOWN), fImplID(kInvalidImpl), fOwner(kInvalidPlugin), fIsAddin(kFalse), fThreadingPolicy(IPlugIn::kUnknownThreadingPolicy)
48 #endif
49  {
50  }
51 
52 #ifdef USE_ALLOCATE_WITH_BOSS
53  InterfaceInfo(PMIID faceID, ImplementationID implID, PluginID owner, bool isAddin, int32 offset) :
54  fFaceID(faceID), fImplID(implID), fOwner(owner), fIsAddin(isAddin), fOffset(offset)
55 #else
56  InterfaceInfo(PMIID faceID, ImplementationID implID, PluginID owner, bool isAddin) :
57  fFaceID(faceID), fImplID(implID), fOwner(owner), fIsAddin(isAddin)
58 #endif
59  {
60  ASSERT_MSG(implID != kInvalidImpl,"Creating interfaceInfo with kInvalidImpl");
61  fThreadingPolicy = ::GetPluginThreadingPolicy(fOwner);
62  }
63 
64  PMIID GetInterface() const { return fFaceID; }
65  ImplementationID GetImplementation() const { return fImplID; }
66  PluginID GetOwnerComponent() const { return fOwner; }
67 #ifdef USE_ALLOCATE_WITH_BOSS
68  int32 GetOffset() const { return fOffset; }
69  void SetOffset(int32 newOffset) { fOffset = newOffset; }
70 #endif
71  bool IsAddin() const { return fIsAddin; }
72  IPlugIn::ThreadingPolicy GetThreadingPolicy() const { return fThreadingPolicy; }
73  void ReadWrite(IPMStream *s)
74  {
75  s->XferID(fFaceID);
76  s->XferID(fImplID);
77  s->XferID(fOwner);
78 #ifdef USE_ALLOCATE_WITH_BOSS
79  s->XferInt32(fOffset);
80 #endif
81  s->XferEnum(fThreadingPolicy);
82  }
83 
84 private:
85  PMIID fFaceID;
86  ImplementationID fImplID;
87  PluginID fOwner; // ID of the plugin who added this interface to the boss.
88 #ifdef USE_ALLOCATE_WITH_BOSS
89  int32 fOffset;
90 #endif
91  IPlugIn::ThreadingPolicy fThreadingPolicy; // specifies if threading policy for this interface
92  bool fIsAddin;
93 };
94 
95 // Persistence
96 namespace Persist
97 {
98  template<>
99  inline void Read<InterfaceInfo>(IPMStream* stream, InterfaceInfo& entry)
100  {
101  ASSERT (stream && stream->IsReading());
102  entry.ReadWrite(stream);
103  }
104 
105  template<>
106  inline void Write<InterfaceInfo>(IPMStream* stream, const InterfaceInfo& entry)
107  {
108  ASSERT (stream && stream->IsWriting());
109  const_cast<InterfaceInfo&>(entry).ReadWrite(stream);
110  }
111 }
112 
113 
114 #endif // __InterfaceInfo__
115 
116 
117