InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CreateObject.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: rbriggs
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 __CreateObject__
25 #define __CreateObject__
26 
27 #include "IObjectModel.h"
28 #include "ISession.h"
29 #include "IPMUnknown.h" // for the definition of
30 
31 
37 {
38 public:
39  virtual IPMUnknown *CreateObject(ClassID clsID, PMIID interfaceID) = 0;
40 };
41 
42 
43 #ifdef PUBLIC_BUILD
44 #endif
45 
46 class RsrcSpec;
47 class IResourceAccess;
48 
49 
51 
52 
61  IPMUnknown* CreateObject(ClassID clsID, PMIID iid = IID_IUNKNOWN, const IObjectModel*om = GetObjectModelInstance());
62 
73  IPMUnknown* CreateObject(IDataBase* db, ClassID id, PMIID iid = IID_IUNKNOWN);
74 
84  IPMUnknown* CreateObject(IDataBase* db, const RsrcSpec& spec, PMIID iid = IID_IUNKNOWN, const IObjectModel*om = GetObjectModelInstance());
85 
95  IPMUnknown* CreateObjectNoInit (IDataBase* db, const RsrcSpec& spec, PMIID returnIID, const IObjectModel*om = GetObjectModelInstance());
96 
98 
99 // ***************************************************************************************************
100 // Drover based widgets created/read from resources need a context to indicate to the panel control
101 // data that there is an underlying UI_Node off this boss. This is so things get addref'd properly.
102 // During stream resource read, an extra addref on the IControlView interface keeps the drover based
103 // widget boss from being immediately destroyed since at present, unlike our old platform based
104 // widgets, we don't allow drover based widgets in the instance cache. This AddRef is compensated
105 // for in DVControlPanelData::ReadWrite.
106 
107 namespace ResourceStreamReadContext
108 {
109  bool16 IsResourceStreamReadContextActive();
110 }
111 
112 // ***************************************************************************************************
113 
114 
115 
117 
118 
119 
120 // These work like CreateObject(ClassID, PMIID), but you can omit the interface ID if the
121 // face defines kDefaultIID and the correct face pointer is returned. Usage is like this:
122 // ::CreateObject2<ITableTarget>(kTableSelectionBoss).
123 
133 template <class FACE>
134 inline FACE* CreateObject2(ClassID clsID) // do not forward declare these: CW Pro 5 won't inline them if they're forward declared...
135 {
136  IPMUnknown* face = CreateObject(clsID, FACE::kDefaultIID);
137 
138  return static_cast<FACE*>(face);
139 }
140 
150 template <class FACE>
151 inline FACE* CreateObject2(ClassID clsID, PMIID iid)
152 {
153  IPMUnknown* face = CreateObject(clsID, iid);
154 
155  return static_cast<FACE*>(face);
156 }
157 
165 template <class FACE>
166 inline FACE* CreateObject2(IDataBase* db, ClassID clsID)
167 {
168  IPMUnknown* face = CreateObject(db, clsID, FACE::kDefaultIID);
169 
170  return static_cast<FACE*>(face);
171 }
172 
180 template <class FACE>
181 inline FACE* CreateObject2(IDataBase* db, ClassID clsID, PMIID iid)
182 {
183  IPMUnknown* face = CreateObject(db, clsID, iid);
184 
185  return static_cast<FACE*>(face);
186 }
187 
195 template <class FACE>
196 inline FACE* CreateObject2(IDataBase* db, const RsrcSpec& spec)
197 {
198  IPMUnknown* face = CreateObject(db, spec, FACE::kDefaultIID);
199 
200  return static_cast<FACE*>(face);
201 }
202 
204 
205 
206 #endif // __CreateObject__