Mobile API Reference  MicroStrategy 2019
Msi_atlcom.h
Go to the documentation of this file.
1 // File: atlcom.h
2 // Date: 10th July 2001
3 // Author: Will Hurwood
4 // Modified by: Liqun Jin
5 //
6 // Copyright (C) 2001 MicroStrategy Incorporated
7 // All rights reserved
8 
9 // This header file replaces the atlcom.h file from ATL on UNIX
10 // File declares similar symbols and classes to the corresponding VC++ file
11 
12 #ifndef __ATLCOM_H__
13 #define __ATLCOM_H__
14 
15 #include "PDCHeader/PDCwindows.h"
16 #include "PDCHeader/PDCwchar.h"
17 
18 #include "Msi_ole2.h"
19 #include "Msi_atldef.h"
20 #include "Msi_ccombstr.h"
21 #include "Msi_atlbase.h"
22 
23 #ifdef WIN64
24 #pragma warning(disable:4312) // 'type cast' : conversion from 'DWORD' to 'LPWSTR' of greater size
25 #endif
26 
27 #define _ATL_DECLARE_GET_UNKNOWN(x) IUnknown* GetUnknown() {return _GetRawUnknown();}
28 
29 //If you get a message that FinalConstruct is ambiguous then you need to
30 // override it in your class and call each base class' version of this
31 #define BEGIN_COM_MAP(x) public: \
32  typedef x _ComMapClass; \
33  static HRESULT WINAPI _Cache(void* pv, REFIID iid, void** ppvObject, DWORD_PTR dw)\
34  {\
35  _ComMapClass* p = (_ComMapClass*)pv;\
36  p->Lock();\
37  HRESULT hRes = CComObjectRootBase::_Cache(pv, iid, ppvObject, dw);\
38  p->Unlock();\
39  return hRes;\
40  }\
41  IUnknown* _GetRawUnknown() \
42  { ATLASSERT(_GetEntries()[0].pFunc == _ATL_SIMPLEMAPENTRY); return (IUnknown*)((DWORD_PTR)this+_GetEntries()->dw); } \
43  _ATL_DECLARE_GET_UNKNOWN(x)\
44  HRESULT _InternalQueryInterface(REFIID iid, void** ppvObject) \
45  { return InternalQueryInterface(this, _GetEntries(), iid, ppvObject); } \
46  const static _ATL_INTMAP_ENTRY* WINAPI _GetEntries() { \
47  static const _ATL_INTMAP_ENTRY _entries[] = {
48 
49 #define DECLARE_GET_CONTROLLING_UNKNOWN() public:\
50  virtual IUnknown* GetControllingUnknown() {return GetUnknown();}
51 
52 #define _ATL_IIDOF(x) IID_##x
53 
54 #define COM_INTERFACE_ENTRY(x)\
55  {&_ATL_IIDOF(x), \
56  offsetofclass(x, _ComMapClass), \
57  _ATL_SIMPLEMAPENTRY},
58 
59 #define COM_INTERFACE_ENTRY_IID(iid, x)\
60  {&iid,\
61  offsetofclass(x, _ComMapClass),\
62  _ATL_SIMPLEMAPENTRY},
63 
64 #define COM_INTERFACE_ENTRY2(x, x2)\
65  {&_ATL_IIDOF(x),\
66  (DWORD_PTR)((x*)(x2*)((_ComMapClass*)8))-8,\
67  _ATL_SIMPLEMAPENTRY},
68 
69 #define COM_INTERFACE_ENTRY_IMPL(x)\
70  COM_INTERFACE_ENTRY_IID(_ATL_IIDOF(x), x##Impl<_ComMapClass>)
71 
72 #define COM_INTERFACE_ENTRY_AGGREGATE(iid, punk)\
73  {&iid,\
74  (DWORD)offsetof(_ComMapClass, punk),\
75  _Delegate},
76 
77 #define COM_INTERFACE_ENTRY_CHAIN(classname)\
78  {NULL,\
79  (DWORD_PTR)&_CComChainData<classname, _ComMapClass>::data,\
80  _Chain},
81 
82 #define END_COM_MAP() {NULL, 0, 0}}; return _entries;}
83 
84 #define _ATL_DEBUG_ADDREF_RELEASE_IMPL(className)\
85  virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0;\
86  virtual ULONG STDMETHODCALLTYPE Release(void) = 0;
87 
88 #define DECLARE_PROTECT_FINAL_CONSTRUCT()\
89  void InternalFinalConstructAddRef() {InternalAddRef();}\
90  void InternalFinalConstructRelease() {InternalRelease();}
91 
92 #define DECLARE_NOT_AGGREGATABLE(x) public:\
93  typedef CComCreator2< CComCreator< CComObject< x > >, CComFailCreator<CLASS_E_NOAGGREGATION> > _CreatorClass;
94 #define DECLARE_AGGREGATABLE(x) public:\
95  typedef CComCreator2< CComCreator< CComObject< x > >, CComCreator< CComAggObject< x > > > _CreatorClass;
96 #define DECLARE_ONLY_AGGREGATABLE(x) public:\
97  typedef CComCreator2< CComFailCreator<E_FAIL>, CComCreator< CComAggObject< x > > > _CreatorClass;
98 
99 #define DECLARE_CLASSFACTORY_EX(cf) typedef CComCreator< CComObjectCachedClassFactory< cf > > _ClassFactoryCreatorClass;
100 #define DECLARE_CLASSFACTORY() DECLARE_CLASSFACTORY_EX(CComClassFactory)
101 
103 // Support for the OBJECT_MAP
104 #define BEGIN_OBJECT_MAP(x) static _ATL_OBJMAP_ENTRY x[] = {
105 #define END_OBJECT_MAP() {NULL, NULL, NULL}};
106 #define OBJECT_ENTRY(clsid, class) {\
107  &clsid,\
108  class::_ClassFactoryCreatorClass::CreateInstance,\
109  class::_CreatorClass::CreateInstance },\
110 
111 // We do not use the registry
112 #define DECLARE_REGISTRY_RESOURCEID(x)
113 
114 // We do not implement Classes for connection point
115 #define CComConnectionPointContainerImpl IConnectionPointContainerImpl
116 #define BEGIN_CONNECTION_POINT_MAP(x)
117 #define CONNECTION_POINT_ENTRY(iid)
118 #define END_CONNECTION_POINT_MAP()
119 
120 #ifndef MSI_min
121 #define MSI_min(a,b) (((a) < (b)) ? (a) : (b))
122 #endif
123 
124 #ifndef LOWORD
125 #define LOWORD(l) ((WORD)(l))
126 #endif // LOWORD
127 
128 #ifndef HIWORD
129 #define HIWORD(l) ((WORD)(((DWORD_PTR)(l) >> 16) & 0xFFFF))
130 #endif // HIWORD
131 
132 #ifndef MAKEINTRESOURCE
133 #define MAKEINTRESOURCE(i) (LPWSTR)((DWORD)((WORD)(i)))
134 #endif //MAKEINTRESOURCE
135 
136 #ifndef _DEFAULT_VECTORLENGTH
137 #define _DEFAULT_VECTORLENGTH 4
138 #endif
139 
140 namespace ATL
141 {
143  // Macros used to support QueryInterface
144 
146  {
148  _ATL_CREATORFUNC* pFunc;
149  };
150 
152  {
154  const _ATL_INTMAP_ENTRY* (WINAPI *pFunc)();
155  };
156 
157  template <class base, class derived>
159  {
160  public:
162  };
163 
164  template <class base, class derived>
166  {
167  offsetofclass(base, derived),
168  base::_GetEntries
169  };
170 
172  // Classes used to define COM objects
173 
174  // Base class used for all COM objects implemented by ATL
175  // Its methods are not virtual since they are called in top level template
177  {
178  public:
180 
181  HRESULT FinalConstruct();
182 
183  void FinalRelease();
184 
185  static HRESULT WINAPI InternalQueryInterface(void* pThis,
186  const _ATL_INTMAP_ENTRY* pEntries,
187  REFIID iid,
188  void** ppvObject);
189 
190  //Outer funcs
191  ULONG OuterAddRef();
192 
193  ULONG OuterRelease();
194 
195  HRESULT OuterQueryInterface(REFIID iid, void ** ppvObject);
196 
197  void SetVoid(void*);
198 
199  void InternalFinalConstructAddRef();
200 
201  void InternalFinalConstructRelease();
202 
203  static HRESULT WINAPI _Cache(void* pv, REFIID iid, void** ppvObject, DWORD_PTR dw);
204 
205  static HRESULT WINAPI _Delegate(void* pv, REFIID iid, void** ppvObject, DWORD_PTR dw)
206  {
207  HRESULT hRes = E_NOINTERFACE;
208  IUnknown* p = *(IUnknown**)((DWORD_PTR)pv + dw);
209  if (p != NULL)
210  hRes = p->QueryInterface(iid, ppvObject);
211  return hRes;
212  }
213 
214  static HRESULT WINAPI _Chain(void* pv, REFIID iid, void** ppvObject, DWORD_PTR dw)
215  {
217  void* p = (void*)((DWORD_PTR)pv + pcd->dwOffset);
218  return InternalQueryInterface(p, pcd->pFunc(), iid, ppvObject);
219  }
220 
221  // BEWARE: since ATOMICLONG is not allowed in the union, we just remove union.
222  //union {
225  //};
226  };
227 
228  // CComObjectRootEx is the main base class for a COM object
229  // BEWARE - Since we expect to have to use some kind of MsiCriticalSection
230  // BEWARE - we have removed the critical sections from this code
231  // 10/17/01 yma, solve above BEWARE
232  //foward declaration
233  template <class ThreadModel>
235 
236  template <class ThreadModel>
238  {
239  public:
241  {
242  if (p)
243  p->Lock();
244  m_p = p;
245  }
246 
248  {
249  if (m_p)
250  m_p->Unlock();
251  }
253  };
254 
255  //template <> class CComObjectLockT<CComSingleThreadModel>;
256 
257  // CComObjectRootEx contains a critical section. We have modified the
258  // definition of AutoCriticalSection so that it is an MSICriticalSection.
259  // We add a constructor so that the caller can pass in a parameter to
260  // specify the lock category of the critical section
261 
262  template <class ThreadModel>
263  class CComObjectRootEx : public CComObjectRootBase
264  {
265  public:
266  typedef ThreadModel _ThreadModel;
267  typedef typename _ThreadModel::AutoCriticalSection _CritSec;
269 
271  {
272  if (iLockCategory == MSynch::DssLkStkCatNoLock)
273  {
274  // this object does not need a lock; no need to create critical section for it
275  m_pcritsec = NULL;
276  }
277  else
278  {
279  m_pcritsec = new _CritSec(iLockCategory);
280  }
281  }
282 
284  {
285  if (m_pcritsec)
286  {
287  delete m_pcritsec;
288  m_pcritsec = NULL;
289  }
290  }
291 
292  // (MSI) Added this method to allow objects to reset their lock category defn.
294  {
295  if (m_pcritsec)
296  m_pcritsec->SetLockCategory(iLockCat);
297  //(m_pcritsec->pCriticalSection.Get())->SetLockCategory(iLockCat);
298  }
299 
301  {
302  ATLASSERT(m_dwRef != -1L);
303  return _ThreadModel::Increment(&m_dwRef);
304  }
306  {
307  ATLASSERT(m_dwRef > 0);
308  return _ThreadModel::Decrement(&m_dwRef);
309  }
310 
311  void Lock()
312  {
313  if (m_pcritsec)
314  m_pcritsec->Exception_unsafe_Lock__which_should_NOT_be_used_because_of_imminent_deadlocks__Use_SmartLock_instead();
315 #ifdef _DEBUG
316  // in debug build, assertion failure because caller has promised not to use lock
317  // when passing in DssLkStkCatNoLock to constructor
318  else
319  _ASSERTE("CComObjectRootEx::Lock: no lock" == 0);
320 #endif
321  }
322 
323  void Unlock()
324  {
325  if (m_pcritsec)
326  m_pcritsec->Exception_unsafe_Unlock__which_should_NOT_be_used_because_of_imminent_deadlocks__Use_SmartLock_instead();
327 #ifdef _DEBUG
328  // in debug build, assertion failure because caller has promised not to use lock
329  // when passing in DssLkStkCatNoLock to constructor
330  else
331  _ASSERTE("CComObjectRootEx::Unlock: no lock" == 0);
332 #endif
333  }
334 
335  protected:
336  // (MSI) Added this method
337  // (MSI) A class that can be used as a subject object, supports this method
339  {
340  }
341 
342  private:
343  _CritSec *m_pcritsec;
344  };
345 
346  // npratt:102099:We cannot allow a default lock category in the server
347  // So we remove the default param. However, many clases across COM, Engine and
348  // Kernel, inherit from CComObjectRooEx but dont actually use locks (specifically
349  // CComSmartLock) - so we provide an alternative class to derive from that
350  // doesnt contain a critical section so that we dont have to allocate
351  // needless lock categories to objects which are single threaded hence dont have
352  // a lock inside them.
353 
354  // Template class that doesnt contain a critical section
355  // hence does NOT support CComSmartLock. If you need/want CComSmartLock
356  // then you have to use CComObjectRootEx, and specify the lock category
357  template <class ThreadModel>
359  {
360  public:
361  typedef ThreadModel _ThreadModel;
362  typedef typename _ThreadModel::AutoCriticalSection _CritSec;
364 
365  // (MSI) Added this constructor
367  {
368  }
369 
371  {
372  ATLASSERT(m_dwRef != -1L);
373  return _ThreadModel::Increment(&m_dwRef);
374  }
376  {
377  ATLASSERT(m_dwRef > 0);
378  return _ThreadModel::Decrement(&m_dwRef);
379  }
380 
381  void Lock()
382  {
383  }
384 
385  void Unlock()
386  {
387  }
388  };
389 
390  // **** MicroStrategy modifications end here
391 
392 
394  // Top level templates used to implement IUnknown methods
395 
396  //Base is the user's class that derives from CComObjectRoot and whatever
397  //interfaces the user wants to support on the object
398  template <class Base>
399  class CComObject : public Base
400  {
401  public:
402  typedef Base _BaseClass;
403  CComObject(void* = NULL)
404  {
405  }
406 
407  // Set refcount to 1 to protect destruction
409  {
410  this->m_dwRef = 1L;
411  this->FinalRelease();
412  }
413 
414  //If InternalAddRef or InternalRelease is undefined then your class
415  //doesn't derive from CComObjectRoot
416  STDMETHOD_(ULONG, AddRef)()
417  {
418  return this->InternalAddRef();
419  }
420 
421  STDMETHOD_(ULONG, Release)()
422  {
423  ULONG l = this->InternalRelease();
424  if (l == 0)
425  delete this;
426  return l;
427  }
428 
429  //if _InternalQueryInterface is undefined then you forgot BEGIN_COM_MAP
430  STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
431  {
432  return this->_InternalQueryInterface(iid, ppvObject);
433  }
434 
436  };
437 
438  template <class Base>
440  {
441  ATLASSERT(pp != NULL);
442  HRESULT hRes = E_OUTOFMEMORY;
443  CComObject<Base>* p = NULL;
444  ATLTRY(p = new CComObject<Base>())
445  if (p != NULL)
446  {
447  p->SetVoid(NULL);
448  p->InternalFinalConstructAddRef();
449  hRes = p->FinalConstruct();
450  p->InternalFinalConstructRelease();
451  if (hRes != S_OK)
452  {
453  delete p;
454  p = NULL;
455  }
456  }
457  *pp = p;
458  return hRes;
459  }
460 
461  template <class Base> //Base must be derived from CComObjectRoot
462  class CComContainedObject : public Base
463  {
464  public:
465  typedef Base _BaseClass;
467  {
468  this->m_pOuterUnknown = (IUnknown*)pv;
469  }
470 
471  STDMETHOD_(ULONG, AddRef)()
472  {
473  return this->OuterAddRef();
474  }
475 
476  STDMETHOD_(ULONG, Release)()
477  {
478  return this->OuterRelease();
479  }
480 
481  STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
482  {
483  HRESULT hr = this->OuterQueryInterface(iid, ppvObject);
484  if (FAILED(hr) && this->_GetRawUnknown() != this->m_pOuterUnknown)
485  hr = this->_InternalQueryInterface(iid, ppvObject);
486  return hr;
487  }
488 
489  //GetControllingUnknown may be virtual if the Base class has declared
490  //DECLARE_GET_CONTROLLING_UNKNOWN()
492  {
493  return this->m_pOuterUnknown;
494  }
495  };
496 
497  // contained is the user's class that derives from CComObjectRoot and whatever
498  // interfaces the user wants to support on the object
499  template <class contained>
501  public IUnknown,
502  public CComObjectRootEx< typename contained::_ThreadModel::ThreadModelNoCS >
503  {
504  public:
505  typedef contained _BaseClass;
506 
507  // **** MicroStrategy modications begin here
508  // (MSI) We have added a lock category to this aggregation object, but we do not use it in Unix environment
509  CComAggObject(void* pv):
510  m_contained(pv),
511 #if defined(WIN32) && !defined(WIN64)
512  CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>(MSynch::DssLkStkCatAggObject)
513 #else
514  CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>(MSynch::DssLkStkCatAggObject)
515 #endif
516  {
517  }
518  // **** MicroStrategy modifications end here
519 
520  //If you get a message that this call is ambiguous then you need to
521  // override it in your class and call each base class' version of this
523  {
524 #if defined(WIN32) && !defined(WIN64)
526 #else
528 #endif
529  return m_contained.FinalConstruct();
530  }
531 
533  {
534 #if defined(WIN32) && !defined(WIN64)
536 #else
538 #endif
539  m_contained.FinalRelease();
540  }
541 
542  // Set refcount to 1 to protect destruction
544  {
545  this->m_dwRef = 1L;
546  this->FinalRelease();
547  }
548 
550  {
551  return this->InternalAddRef();
552  }
553 
555  {
556  ULONG l = this->InternalRelease();
557  if (l == 0)
558  delete this;
559  return l;
560  }
561 
562  STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
563  {
564  HRESULT hRes = S_OK;
565  if (InlineIsEqualUnknown(iid))
566  {
567  if (ppvObject == NULL)
568  return E_POINTER;
569  *ppvObject = (void*)(IUnknown*)this;
570  AddRef();
571  }
572  else
573  {
574  hRes = m_contained._InternalQueryInterface(iid, ppvObject);
575  }
576 
577  return hRes;
578  }
579 
581  {
582  ATLASSERT(pp != NULL);
583  HRESULT hRes = E_OUTOFMEMORY;
585  ATLTRY(p = new CComAggObject<contained>(pUnkOuter))
586  if (p != NULL)
587  {
588  p->SetVoid(NULL);
590  hRes = p->FinalConstruct();
592  if (hRes != S_OK)
593  {
594  delete p;
595  p = NULL;
596  }
597  }
598  *pp = p;
599  return hRes;
600  }
601 
603  };
604 
605  // This is the top-level template used for class factory objects
606  // In the original they have different synchronization requirements
607  // BEWARE - Since we have no synchronization in this prototype the
608  // BEWARE - difference is not apparent. I've left in a different template
609  // BEWARE - so we can separate it out again.
610  template <class Base>
612  {
613  public:
614  typedef Base _BaseClass;
615 
617  {
618  }
619 
620  // Set refcount to 1 to protect destruction
622  {
623  this->m_dwRef = 1L;
624  this->FinalRelease();
625  }
626 
627  //If InternalAddRef or InternalRelease is undefined then your class
628  //doesn't derive from CComObjectRoot
629  STDMETHOD_(ULONG, AddRef)()
630  {
631  ULONG l = this->InternalAddRef();
632  return l;
633  }
634 
635  STDMETHOD_(ULONG, Release)()
636  {
637  ULONG l = this->InternalRelease();
638  if (l == 0)
639  delete this;
640  return l;
641  }
642 
643  //if _InternalQueryInterface is undefined then you forgot BEGIN_COM_MAP
644  STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
645  {
646  return this->_InternalQueryInterface(iid, ppvObject);
647  }
648  };
649 
650 
652  // Classes used to create an object
653 
654  template <class T1>
656  {
657  public:
659  {
660  ATLASSERT(*ppv == NULL);
661  HRESULT hRes = E_OUTOFMEMORY;
662  T1* p = NULL;
663  ATLTRY(p = new T1(pv))
664  if (p != NULL)
665  {
666  p->SetVoid(pv);
667  p->InternalFinalConstructAddRef();
668  hRes = p->FinalConstruct();
669  p->InternalFinalConstructRelease();
670  if (hRes == S_OK)
671  hRes = p->QueryInterface(riid, ppv);
672  if (hRes != S_OK)
673  delete p;
674  }
675  return hRes;
676  }
677  };
678 
679  template <HRESULT hr>
681  {
682  public:
684  {
685  return hr;
686  }
687  };
688 
689  template <class T1, class T2>
691  {
692  public:
694  {
695  ATLASSERT(*ppv == NULL);
696  return (pv == NULL) ?
697  T1::CreateInstance(NULL, riid, ppv) :
698  T2::CreateInstance(pv, riid, ppv);
699  }
700  };
701 
703  // Classes used for COM CoClass
704 
705  // This is the class used to implement IClassFactory on the coclass object
707  public CComObjectRootEx<CComGlobalsThreadModel>
708  {
709  public:
710  // **** MicroStrategy modications begin here
711  // We'd need to modify CComClassFactory since it uses a lock as well
712  // and we are trying to always provide a lock category
713 
714  // (MSI) we added the constructor here, so pass in a lock category
717  {
718  }
719 
720  // **** MicroStrategy modifications end here
721 
724  END_COM_MAP()
725 
726  // IClassFactory
727  STDMETHOD(CreateInstance)(LPUNKNOWN pUnkOuter, REFIID riid, void** ppvObj);
728 
729  STDMETHOD(LockServer)(BOOL fLock);
730 
731  // helper
732  void SetVoid(void* pv);
733  _ATL_CREATORFUNC* m_pfnCreateInstance;
734  };
735 
736  template <class T, const CLSID* pclsid = &CLSID_NULL>
738  {
739  public:
742  typedef T _CoClass;
743 
744  static const CLSID& WINAPI GetObjectCLSID()
745  {
746  return *pclsid;
747  }
748  };
749 
750  // We do not implement IDispatch
751  // We do not plan to support IDispatch on the Intelligence Server
752  // We still need to stub out the template to allow for compilation
753  // We must inherit from the base interface, since this is how the interface is included
754  template <class T, const IID* piid, const GUID* plibid>
755  class IDispatchImpl : public T
756  {
757  STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid,
758  LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
759  EXCEPINFO* pexcepinfo, UINT* puArgErr)
760  {
762  return E_NOTIMPL;
763  }
764  };
765 
766  template <const IID* piid>
768  {
769  public:
770  //this method needs a different name than QueryInterface
771  STDMETHOD(_LocCPQueryInterface)(REFIID riid, void ** ppvObject) = 0;
772  virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0;\
773  virtual ULONG STDMETHODCALLTYPE Release(void) = 0;
774  };
775 
776  // IConnectionPointImpl
777  template <class T, const IID* piid, class CDV/* = CComDynamicUnkArray*/ >
779  {
780  public:
782  {
783  }
784 
785  STDMETHOD(_LocCPQueryInterface)(REFIID riid, void ** ppvObject)
786  {
788  return E_NOTIMPL;
789  }
790 
791  STDMETHOD(GetConnectionInterface)(IID* piid2)
792  {
794  return E_NOTIMPL;
795  }
796 
797  STDMETHOD(GetConnectionPointContainer)(IConnectionPointContainer** ppCPC)
798  {
800  return E_NOTIMPL;
801  }
802 
803  STDMETHOD(Advise)(IUnknown* pUnkSink, DWORD* pdwCookie)
804  {
806  return E_NOTIMPL;
807  }
808 
809  STDMETHOD(Unadvise)(DWORD dwCookie)
810  {
812  return E_NOTIMPL;
813  }
814 
815  STDMETHOD(EnumConnections)(IEnumConnections** ppEnum)
816  {
818  return E_NOTIMPL;
819  }
820  };
821 
822  // IConnectionPointContainerImpl
823  template <class T>
825  {
826  public:
827  STDMETHOD(EnumConnectionPoints)(IEnumConnectionPoints** ppEnum)
828  {
830  return E_NOTIMPL;
831  }
832 
833  STDMETHOD(FindConnectionPoint)(REFIID riid, IConnectionPoint** ppCP)
834  {
836  return E_NOTIMPL;
837  }
838  };
839 
841  // CComEnumImpl
842 
843  // These _CopyXXX classes are used with enumerators in order to control
844  // how enumerated items are initialized, copied, and deleted
845 
846  // Default is shallow copy with no special init or cleanup
847  template <class T>
848  class _Copy
849  {
850  public:
851  static HRESULT copy(T* p1, T* p2)
852  {
853  memmove(p1, p2, sizeof(T));
854  return S_OK;
855  }
856 
857  static void init(T*)
858  {
859  }
860 
861  static void destroy(T*)
862  {
863  }
864  };
865 
866  template<>
867  class _Copy<VARIANT>
868  {
869  public:
870  static HRESULT copy(VARIANT* p1, VARIANT* p2)
871  {
872  return VariantCopy(p1, p2);
873  }
874 
875  static void init(VARIANT* p)
876  {
877  p->vt = VT_EMPTY;
878  }
879 
880  static void destroy(VARIANT* p)
881  {
882  VariantClear(p);
883  }
884  };
885 
886  template<>
888  {
889  public:
890  static HRESULT copy(LPOLESTR* p1, LPOLESTR* p2)
891  {
892  HRESULT hr = S_OK;
893 #ifdef NO_WCHAR_SUPPORT
894  (*p1) = (LPOLESTR)CoTaskMemAlloc(sizeof(OLECHAR)*(ULONG)(::strlen(*p2)+1));
895 #else
896  (*p1) = (LPOLESTR)CoTaskMemAlloc(sizeof(OLECHAR)*(ULONG)(::wcslen(*p2)+1));
897 #endif
898  if (*p1 == NULL)
899  hr = E_OUTOFMEMORY;
900  else
901 #ifdef WIN32
902  #ifdef NO_WCHAR_SUPPORT
903  ::strcpy_s(*p1,(ULONG)(::strlen(*p2)+1),*p2);
904  #else
905  ::wcscpy_s(*p1,(ULONG)(::wcslen(*p2)+1),*p2);
906  #endif
907 #else // for Unix
908  #ifdef NO_WCHAR_SUPPORT
909  ::strlcpy(*p1, *p2, strlen(*p2)+1);
910  #else
911  ::wcslcpy(*p1, *p2, wcslen(*p2)+1);
912  #endif
913 #endif
914  return hr;
915  }
916 
917  static void init(LPOLESTR* p)
918  {
919  *p = NULL;
920  }
921 
922  static void destroy(LPOLESTR* p)
923  {
924  CoTaskMemFree(*p);
925  }
926  };
927 
928  template<>
930  {
931  public:
933  {
934  *p1 = *p2;
935  if (p1->pUnk)
936  p1->pUnk->AddRef();
937  return S_OK;
938  }
939 
940  static void init(CONNECTDATA* )
941  {
942  }
943 
944  static void destroy(CONNECTDATA* p)
945  {
946  if (p->pUnk) p->pUnk->Release();
947  }
948  };
949 
950  template <class T>
952  {
953  public:
954  static HRESULT copy(T** p1, T** p2)
955  {
956  *p1 = *p2;
957  if (*p1)
958  (*p1)->AddRef();
959  return S_OK;
960  }
961 
962  static void init(T** )
963  {
964  }
965 
966  static void destroy(T** p)
967  {
968  if (*p) (*p)->Release();
969  }
970  };
971 
972  template<class T>
974  {
975  public:
976  STDMETHOD(Next)(ULONG celt, T* rgelt, ULONG* pceltFetched) = 0;
977  STDMETHOD(Skip)(ULONG celt) = 0;
978  STDMETHOD(Reset)(void) = 0;
979  STDMETHOD(Clone)(CComIEnum<T>** ppEnum) = 0;
980  };
981 
982  template <class Base, const IID* piid, class T, class Copy, class ThreadModel = CComObjectThreadModel>
984 
986  {
987  //see FlagBits in CComEnumImpl
990  AtlFlagCopy = 3 // copy implies ownership
991  };
992 
993  template <class Base, const IID* piid, class T, class Copy>
995  {
996  public:
998  {
999  m_begin = m_end = m_iter = NULL;
1000  m_dwFlags = 0;
1001  }
1002  ~CComEnumImpl();
1003  STDMETHOD(Next)(ULONG celt, T* rgelt, ULONG* pceltFetched);
1004  STDMETHOD(Skip)(ULONG celt);
1005  STDMETHOD(Reset)(void)
1006  {
1007  m_iter = m_begin;
1008  return S_OK;
1009  }
1010 
1011  STDMETHOD(Clone)(Base** ppEnum);
1012  HRESULT Init(T* begin, T* end, IUnknown* pUnk,
1013  CComEnumFlags flags = AtlFlagNoCopy);
1016  T* m_end;
1019  protected:
1021  {
1022  BitCopy=1,
1023  BitOwn=2
1024  };
1025  };
1026 
1027  template <class Base, const IID* piid, class T, class Copy>
1029  {
1030  if (m_dwFlags & BitOwn)
1031  {
1032  for (T* p = m_begin; p != m_end; p++)
1033  Copy::destroy(p);
1034  delete [] m_begin;
1035  }
1036  }
1037 
1038  template <class Base, const IID* piid, class T, class Copy>
1040  ULONG* pceltFetched)
1041  {
1042  if (rgelt == NULL || (celt != 1 && pceltFetched == NULL))
1043  return E_POINTER;
1044  if (m_begin == NULL || m_end == NULL || m_iter == NULL)
1045  return E_FAIL;
1046  ULONG nRem = (ULONG)(m_end - m_iter);
1047  HRESULT hRes = S_OK;
1048  if (nRem < celt)
1049  hRes = S_FALSE;
1050  ULONG nMin = MSI_min(celt, nRem);
1051  if (pceltFetched != NULL)
1052  *pceltFetched = nMin;
1053  T* pelt = rgelt;
1054  while(nMin--)
1055  {
1056  HRESULT hr = Copy::copy(pelt, m_iter);
1057  if (FAILED(hr))
1058  {
1059  while (rgelt < pelt)
1060  Copy::destroy(rgelt++);
1061  if (pceltFetched != NULL)
1062  *pceltFetched = 0;
1063  return hr;
1064  }
1065  pelt++;
1066  m_iter++;
1067  }
1068  return hRes;
1069  }
1070 
1071  template <class Base, const IID* piid, class T, class Copy>
1073  {
1074  m_iter += celt;
1075  if (m_iter >= m_end)
1076  {
1077  m_iter = m_end;
1078  return S_FALSE;
1079  }
1080  if (m_iter < m_begin)
1081  {
1082  m_iter = m_begin;
1083  return S_FALSE;
1084  }
1085  return S_OK;
1086  }
1087 
1088  template <class Base, const IID* piid, class T, class Copy>
1090  {
1092  HRESULT hRes = E_POINTER;
1093  if (ppEnum != NULL)
1094  {
1095  *ppEnum = NULL;
1096  _class* p;
1097  hRes = _class::CreateInstance(&p);
1098  if (SUCCEEDED(hRes))
1099  {
1100  // If the data is a copy then we need to keep "this" object around
1101  if(m_dwFlags & BitCopy)
1102  hRes = p->Init(m_begin, m_end, this);
1103  else
1104  hRes = p->Init(m_begin, m_end, m_spUnk);
1105 
1106  if (SUCCEEDED(hRes))
1107  {
1108  p->m_iter = m_iter;
1109  hRes = p->_InternalQueryInterface(*piid, (void**)ppEnum);
1110  }
1111  if (FAILED(hRes))
1112  delete p;
1113  }
1114  }
1115  return hRes;
1116  }
1117 
1118  template <class Base, const IID* piid, class T, class Copy>
1120  CComEnumFlags flags)
1121  {
1122  if (flags == AtlFlagCopy)
1123  {
1124  ATLASSERT(m_begin == NULL); //Init called twice?
1125  ATLTRY(m_begin = new T[end-begin])
1126  m_iter = m_begin;
1127  if (m_begin == NULL)
1128  return E_OUTOFMEMORY;
1129  for (T* i=begin; i != end; i++)
1130  {
1131  Copy::init(m_iter);
1132  HRESULT hr = Copy::copy(m_iter, i);
1133  if (FAILED(hr))
1134  {
1135  T* p = m_begin;
1136  while (p < m_iter)
1137  Copy::destroy(p++);
1138  delete [] m_begin;
1139  m_begin = m_end = m_iter = NULL;
1140  return hr;
1141  }
1142  m_iter++;
1143  }
1144  m_end = m_begin + (end-begin);
1145  }
1146  else
1147  {
1148  m_begin = begin;
1149  m_end = end;
1150  }
1151  m_spUnk = pUnk;
1152  m_iter = m_begin;
1153  m_dwFlags = flags;
1154  return S_OK;
1155  }
1156 
1157  // CComEnum
1158  template <class Base, const IID* piid, class T, class Copy, class ThreadModel /*= CComObjectThreadModel*/>
1160  public CComEnumImpl<Base, piid, T, Copy>,
1161  public CComObjectRootEx< ThreadModel >
1162  {
1163  public:
1166 
1168  CComEnumImpl<Base, piid, T, Copy>(),
1170  {
1171  }
1172 
1173  BEGIN_COM_MAP(_CComEnum)
1174  COM_INTERFACE_ENTRY_IID(*piid, _CComEnumBase)
1175  END_COM_MAP()
1176  };
1177 
1178  // CComEnumOnSTL
1179  template <class Base, const IID* piid, class T, class Copy, class CollType, class ThreadModel = CComObjectThreadModel>
1181 
1182  template <class Base, const IID* piid, class T, class Copy, class CollType>
1184  {
1185  public:
1186  HRESULT Init(IUnknown *pUnkForRelease, CollType& collection)
1187  {
1188  m_spUnk = pUnkForRelease;
1189  m_pcollection = &collection;
1190  m_iter = m_pcollection->begin();
1191  return S_OK;
1192  }
1193  STDMETHOD(Next)(ULONG celt, T* rgelt, ULONG* pceltFetched);
1194  STDMETHOD(Skip)(ULONG celt);
1195  STDMETHOD(Reset)(void)
1196  {
1197  if (m_pcollection == NULL)
1198  return E_FAIL;
1199  m_iter = m_pcollection->begin();
1200  return S_OK;
1201  }
1202  STDMETHOD(Clone)(Base** ppEnum);
1203  //Data
1205  CollType* m_pcollection;
1206  typename CollType::iterator m_iter;
1207  };
1208 
1209  template <class Base, const IID* piid, class T, class Copy, class CollType>
1211  ULONG* pceltFetched)
1212  {
1213  if (rgelt == NULL || (celt != 1 && pceltFetched == NULL))
1214  return E_POINTER;
1215  if (m_pcollection == NULL)
1216  return E_FAIL;
1217 
1218  ULONG nActual = 0;
1219  HRESULT hr = S_OK;
1220  T* pelt = rgelt;
1221  while (SUCCEEDED(hr) && m_iter != m_pcollection->end() && nActual < celt)
1222  {
1223  hr = Copy::copy(pelt, &*m_iter);
1224  if (FAILED(hr))
1225  {
1226  while (rgelt < pelt)
1227  Copy::destroy(rgelt++);
1228  nActual = 0;
1229  }
1230  else
1231  {
1232  pelt++;
1233  m_iter++;
1234  nActual++;
1235  }
1236  }
1237  if (pceltFetched)
1238  *pceltFetched = nActual;
1239  if (SUCCEEDED(hr) && (nActual < celt))
1240  hr = S_FALSE;
1241  return hr;
1242  }
1243 
1244  template <class Base, const IID* piid, class T, class Copy, class CollType>
1246  {
1247  HRESULT hr = S_OK;
1248  while (celt--)
1249  {
1250  if (m_iter != m_pcollection->end())
1251  m_iter++;
1252  else
1253  {
1254  hr = S_FALSE;
1255  break;
1256  }
1257  }
1258  return hr;
1259  }
1260 
1261  template <class Base, const IID* piid, class T, class Copy, class CollType>
1263  {
1265  HRESULT hRes = E_POINTER;
1266  if (ppEnum != NULL)
1267  {
1268  *ppEnum = NULL;
1269  _class* p;
1270  hRes = _class::CreateInstance(&p);
1271  if (SUCCEEDED(hRes))
1272  {
1273  hRes = p->Init(m_spUnk, *m_pcollection);
1274  if (SUCCEEDED(hRes))
1275  {
1276  p->m_iter = m_iter;
1277  hRes = p->_InternalQueryInterface(*piid, (void**)ppEnum);
1278  }
1279  if (FAILED(hRes))
1280  delete p;
1281  }
1282  }
1283  return hRes;
1284  }
1285 
1286  template <class Base, const IID* piid, class T, class Copy, class CollType, class ThreadModel>
1288  public IEnumOnSTLImpl<Base, piid, T, Copy, CollType>,
1289  public CComObjectRootEx<ThreadModel>
1290  {
1291  public:
1294 
1296  IEnumOnSTLImpl<Base, piid, T, Copy, CollType>(),
1298  {
1299  }
1300 
1301  BEGIN_COM_MAP(_CComEnum)
1302  COM_INTERFACE_ENTRY_IID(*piid, _CComEnumBase)
1303  END_COM_MAP()
1304  };
1305 
1306 
1308  // ISupportErrorInfoImpl
1309 
1310  template <const IID* piid>
1312  {
1313  public:
1314  STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
1315  {
1316  return (InlineIsEqualGUID(riid,*piid)) ? S_OK : S_FALSE;
1317  }
1318  };
1319 
1320 
1322  // IDispatch Error handling
1323 
1324  inline HRESULT WINAPI AtlSetErrorInfo(const CLSID& clsid, LPCOLESTR lpszDesc, DWORD dwHelpID,
1325  LPCOLESTR lpszHelpFile, const IID& iid, HRESULT hRes, HINSTANCE hInst)
1326  {
1327 
1329  TCHAR szDesc[1024] = _T("Unknown Error");
1330 
1331  // For a valid HRESULT the id should be in the range [0x0200, 0xffff]
1332  if (HIWORD(lpszDesc) == 0) //id
1333  {
1334  UINT nID = LOWORD((DWORD_PTR)lpszDesc);
1335  ATLASSERT((nID >= 0x0200 && nID <= 0xffff) || hRes != 0);
1336 
1337 #if defined(WIN32) && !defined(_USE_MSI_COM)
1338  if (LoadString(hInst, nID, szDesc, 1024) == 0)
1339  {
1340  ATLASSERT(FALSE);
1341  }
1342 #endif // WIN32 && !_USE_MSI_COM
1343 
1344  lpszDesc = szDesc;
1345  if (hRes == 0)
1346  hRes = MAKE_HRESULT(3, FACILITY_ITF, nID);
1347  }
1348 
1350  if (SUCCEEDED(CreateErrorInfo(&pICEI)))
1351  {
1352  CComPtr<IErrorInfo> pErrorInfo;
1353  pICEI->SetGUID(iid);
1354  LPOLESTR lpsz = NULL;
1355  ProgIDFromCLSID(clsid, &lpsz);
1356  if (lpsz != NULL)
1357  pICEI->SetSource(lpsz);
1358  if (dwHelpID != 0 && lpszHelpFile != NULL)
1359  {
1360  pICEI->SetHelpContext(dwHelpID);
1361  pICEI->SetHelpFile(const_cast<LPOLESTR>(lpszHelpFile));
1362  }
1363  CoTaskMemFree(lpsz);
1364  pICEI->SetDescription((LPOLESTR)lpszDesc);
1365  if (SUCCEEDED(pICEI->QueryInterface(IID_IErrorInfo, (void**)&pErrorInfo)))
1366  SetErrorInfo(0, pErrorInfo);
1367  }
1368  return (hRes == 0) ? DISP_E_EXCEPTION : hRes;
1369  }
1370 
1372  // AtlReportError
1373 
1374  inline HRESULT WINAPI AtlReportError(const CLSID& clsid, UINT nID, const IID& iid,
1375  HRESULT hRes, HINSTANCE hInst)
1376  {
1377  return AtlSetErrorInfo(clsid, (LPCOLESTR)MAKEINTRESOURCE(nID), 0, NULL, iid, hRes, hInst);
1378  }
1379 
1380  inline HRESULT WINAPI AtlReportError(const CLSID& clsid, UINT nID, DWORD dwHelpID,
1381  LPCOLESTR lpszHelpFile, const IID& iid, HRESULT hRes, HINSTANCE hInst)
1382  {
1383  return AtlSetErrorInfo(clsid, (LPCOLESTR)MAKEINTRESOURCE(nID), dwHelpID,
1384  lpszHelpFile, iid, hRes, hInst);
1385  }
1386 
1387  inline HRESULT WINAPI AtlReportError(const CLSID& clsid, LPCOLESTR lpszDesc,
1388  const IID& iid, HRESULT hRes)
1389  {
1390  return AtlSetErrorInfo(clsid, lpszDesc, 0, NULL, iid, hRes, NULL);
1391  }
1392 
1393  inline HRESULT WINAPI AtlReportError(const CLSID& clsid, LPCOLESTR lpszDesc, DWORD dwHelpID,
1394  LPCOLESTR lpszHelpFile, const IID& iid, HRESULT hRes)
1395  {
1396  return AtlSetErrorInfo(clsid, lpszDesc, dwHelpID, lpszHelpFile, iid, hRes, NULL);
1397  }
1398 
1399 
1401  // Connection Points
1403  {
1404  public:
1406  {
1407  m_nSize = 0;
1408  m_ppUnk = NULL;
1409  }
1410 
1412  {
1413  if (m_nSize > 1)
1414  free(m_ppUnk);
1415  }
1416 
1417  DWORD Add(IUnknown* pUnk);
1418  BOOL Remove(DWORD dwCookie);
1419 
1421  {
1422  DWORD iIndex;
1423  iIndex = DWORD(pp-begin());
1424  return iIndex+1;
1425  }
1426 
1427  static IUnknown* WINAPI GetUnknown(DWORD dwCookie)
1428  {
1429  return (IUnknown*)dwCookie;
1430  }
1431 
1433  {
1434  return (m_nSize < 2) ? &m_pUnk : m_ppUnk;
1435  }
1436 
1438  {
1439  return (m_nSize < 2) ? (&m_pUnk)+m_nSize : &m_ppUnk[m_nSize];
1440  }
1441 
1442  IUnknown* GetAt(int nIndex)
1443  {
1444  if (nIndex < 0 || nIndex >= m_nSize)
1445  return NULL;
1446 
1447  return (m_nSize < 2) ? m_pUnk : m_ppUnk[nIndex];
1448  }
1449 
1450  int GetSize() const
1451  {
1452  return m_nSize;
1453  }
1454 
1455  void clear()
1456  {
1457  if (m_nSize > 1)
1458  free(m_ppUnk);
1459  m_nSize = 0;
1460  }
1461  protected:
1462  union
1463  {
1466  };
1467  int m_nSize;
1468  };
1469 
1471  {
1472  DWORD iIndex;
1473 
1474  IUnknown** pp = NULL;
1475  if (m_nSize == 0) // no connections
1476  {
1477  m_pUnk = pUnk;
1478  m_nSize = 1;
1479  return 1;//(DWORD)m_pUnk;
1480  }
1481  else if (m_nSize == 1)
1482  {
1483  //create array
1484  pp = (IUnknown**)malloc(sizeof(IUnknown*)*_DEFAULT_VECTORLENGTH);
1485  if (pp == NULL)
1486  return 0;
1487  memset(pp, 0, sizeof(IUnknown*)*_DEFAULT_VECTORLENGTH);
1488  *pp = m_pUnk;
1489  m_ppUnk = pp;
1490  m_nSize = _DEFAULT_VECTORLENGTH;
1491  }
1492 
1493  for (pp = begin();pp<end();pp++)
1494  {
1495  if (*pp == NULL)
1496  {
1497  *pp = pUnk;
1498  iIndex = (DWORD)(pp-begin());
1499  return iIndex+1; //(DWORD)pUnk;
1500  }
1501  }
1502  int nAlloc = m_nSize*2;
1503  pp = (IUnknown**)realloc(m_ppUnk, sizeof(IUnknown*)*nAlloc);
1504  if (pp == NULL)
1505  return 0;
1506  m_ppUnk = pp;
1507  memset(&m_ppUnk[m_nSize], 0, sizeof(IUnknown*)*m_nSize);
1508  m_ppUnk[m_nSize] = pUnk;
1509  iIndex = m_nSize;
1510  m_nSize = nAlloc;
1511  return iIndex+1;
1512  }
1513 
1515  {
1516  if (dwCookie == 0)
1517  return FALSE;
1518  if (m_nSize == 0)
1519  return FALSE;
1520  DWORD iIndex = dwCookie-1;
1521  if (iIndex >= (DWORD)m_nSize)
1522  return FALSE;
1523  if (m_nSize == 1)
1524  {
1525  m_nSize = 0;
1526  return TRUE;
1527  }
1528  begin()[iIndex] = NULL;
1529 
1530  return TRUE;
1531  }
1532 }
1533 
1534 #endif /* __ATLCOM_H__ */
CComClassFactory()
Definition: Msi_atlcom.h:715
const _ATL_INTMAP_ENTRY *WINAPI * pFunc()
Definition: Msi_variant.h:90
Definition: Msi_atlcom.h:145
static void init(T *)
Definition: Msi_atlcom.h:857
Definition: Msi_atlcom.h:680
Definition: Msi_atlcom.h:690
signed char BOOL
Definition: PDCwtypes.h:101
STDMETHOD_(ULONG, Release)()
Definition: Msi_atlcom.h:635
static void destroy(T **p)
Definition: Msi_atlcom.h:966
Definition: Msi_ocidl.h:106
DWORD_PTR dwOffset
Definition: Msi_atlcom.h:153
CComObjectRootEx< ThreadModel > * m_p
Definition: Msi_atlcom.h:252
Definition: Msi_atlcom.h:994
#define offsetofclass(base, derived)
Definition: Msi_atldef.h:32
LPOLESTR lpsz
Definition: Msi_objbase.h:85
ULONG InternalAddRef()
Definition: Msi_atlcom.h:300
IUnknown __RPC_FAR * LPUNKNOWN
Definition: Msi_oaidl.h:53
IUnknown ** m_ppUnk
Definition: Msi_atlcom.h:1464
DWORD dwOffsetVar
Definition: Msi_atlcom.h:147
Definition: Msi_atlcom.h:755
MSynch::AtomicLong m_dwRef
Definition: Msi_atlcom.h:223
BOOL Remove(DWORD dwCookie)
Definition: Msi_atlcom.h:1514
#define E_POINTER
Definition: PDCwinerror.h:141
WINOLEAUTAPI DLL_MSICOM_EXIM VariantClear(VARIANTARG *pvarg)
#define STDMETHODIMP
Definition: PDCwtypes.h:84
T * m_end
Definition: Msi_atlcom.h:1016
#define _DEFAULT_VECTORLENGTH
Definition: Msi_atlcom.h:137
#define MAKE_HRESULT(sev, fac, code)
Definition: PDCwinerror.h:55
#define USES_CONVERSION
Definition: Msi_ccombstr.h:30
CComEnumOnSTL()
Definition: Msi_atlcom.h:1295
#define STDMETHODCALLTYPE
Definition: PDCwtypes.h:76
Definition: Msi_atlcom.h:824
Definition: Msi_atlbase.h:93
#define MAKEINTRESOURCE(i)
Definition: Msi_atlcom.h:133
LONG DISPID
Definition: Msi_oaidl.h:237
#define STDMETHOD(method)
Definition: PDCwtypes.h:80
Definition: Msi_atlcom.h:1311
void clear()
Definition: Msi_atlcom.h:1455
Definition: Msi_atlcom.h:989
ThreadModel _ThreadModel
Definition: Msi_atlcom.h:266
Definition: Msi_ocidl.h:125
Definition: Msi_atlcom.h:737
#define BEGIN_COM_MAP(x)
Definition: Msi_atlcom.h:31
STDMETHOD_(ULONG, AddRef)()
Definition: Msi_atlcom.h:471
CComObjectRootEx(MSynch::EnumDSSLockStackCategory iLockCategory)
Definition: Msi_atlcom.h:270
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject)=0
long HRESULT
Definition: FragmentedString.h:20
static HRESULT copy(T **p1, T **p2)
Definition: Msi_atlcom.h:954
CComEnum< Base, piid, T, Copy > _CComEnum
Definition: Msi_atlcom.h:1164
static void init(CONNECTDATA *)
Definition: Msi_atlcom.h:940
T * m_iter
Definition: Msi_atlcom.h:1017
WINOLEAUTAPI DLL_MSICOM_EXIM VariantCopy(VARIANTARG *pvargDest, VARIANTARG *pvargSrc)
HRESULT WINAPI AtlReportError(const CLSID &clsid, UINT nID, const IID &iid, HRESULT hRes, HINSTANCE hInst)
Definition: Msi_atlcom.h:1374
#define _ASSERTE(x)
Definition: Asserte.h:40
void FinalRelease()
Definition: Msi_atlcom.h:532
static void destroy(LPOLESTR *p)
Definition: Msi_atlcom.h:922
CComObjectCachedClassFactory(void *=NULL)
Definition: Msi_atlcom.h:616
_ThreadModel::AutoCriticalSection _CritSec
Definition: Msi_atlcom.h:362
#define ATLASSERT(expr)
Definition: Msi_atldef.h:18
Definition: Msi_atlcom.h:767
Base _BaseClass
Definition: Msi_atlcom.h:614
IUnknown * m_pOuterUnknown
Definition: Msi_atlcom.h:224
~CComObjectCachedClassFactory()
Definition: Msi_atlcom.h:621
Definition: ReferenceCountedImpl.h:18
Definition: Msi_atlcom.h:158
STDMETHOD() Skip(ULONG celt)
Definition: Msi_atlcom.h:1245
Definition: Msi_atlcom.h:1287
Definition: LockCategories.h:82
#define WINAPI
Definition: PDCwindows.h:52
#define S_FALSE
Definition: PDCwinerror.h:32
Definition: Msi_atlcom.h:1402
CComAggObject(void *pv)
Definition: Msi_atlcom.h:509
unsigned long DWORD_PTR
Definition: Msi_atlbase.h:34
Definition: Msi_atlcom.h:1159
STDMETHOD() Next(ULONG celt, T *rgelt, ULONG *pceltFetched)
Definition: Msi_atlcom.h:1210
_ATL_CREATORFUNC * pFunc
Definition: Msi_atlcom.h:148
EXTERN_C const IID IID_IErrorInfo
Definition: Msi_oaidl.h:161
void * LPVOID
Definition: PDCwtypes.h:136
Definition: Msi_atlcom.h:1183
unsigned int UINT
Definition: PDCwtypes.h:110
#define S_OK
Definition: PDCwinerror.h:31
#define NOT_IMP_ASSERTE
_ATL_NO_PRAGMA_WARNINGS
Definition: Msi_atlbase.h:19
Base _BaseClass
Definition: Msi_atlcom.h:465
#define FAILED(Status)
Definition: PDCwinerror.h:47
WINOLEAUTAPI DLL_MSICOM_EXIM SetErrorInfo(ULONG dwReserved, IErrorInfo *perrinfo)
static void init(VARIANT *p)
Definition: Msi_atlcom.h:875
void Lock()
Definition: Msi_atlcom.h:311
DWORD WINAPI GetCookie(IUnknown **pp)
Definition: Msi_atlcom.h:1420
STDMETHOD() Skip(ULONG celt)
Definition: Msi_atlcom.h:1072
#define CLSID_NULL
Definition: PDCwtypes.h:326
CComEnumImpl< Base, piid, T, Copy > _CComEnumBase
Definition: Msi_atlcom.h:1165
STDMETHOD() Clone(Base **ppEnum)
Definition: Msi_atlcom.h:1089
_ThreadModel::AutoCriticalSection _CritSec
Definition: Msi_atlcom.h:267
IUnknown ** end()
Definition: Msi_atlcom.h:1437
CComEnumFlags
Definition: Msi_atlcom.h:985
static HRESULT copy(CONNECTDATA *p1, CONNECTDATA *p2)
Definition: Msi_atlcom.h:932
VARTYPE vt
Definition: Msi_variant.h:148
DWORD LCID
Definition: PDCwtypes.h:294
static HRESULT WINAPI CreateInstance(CComObject< Base > **pp)
Definition: Msi_atlcom.h:439
Definition: Msi_atlcom.h:462
~CComObject()
Definition: Msi_atlcom.h:408
Definition: LockCategories.h:36
#define _T(x)
Definition: PDCtchar.h:94
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: Msi_atlcom.h:59
WCHAR OLECHAR
Definition: PDCwtypes.h:390
static HRESULT WINAPI CreateInstance(void *, REFIID, LPVOID *)
Definition: Msi_atlcom.h:683
~IConnectionPointImpl()
Definition: Msi_atlcom.h:781
REFIID LPVOID * ppv
Definition: Msi_atlbase.h:90
#define SUCCEEDED(Status)
Definition: PDCwinerror.h:42
Definition: Msi_atlcom.h:706
#define LOWORD(l)
Definition: Msi_atlcom.h:125
BOOL InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: Msi_atlbase.h:53
static _ATL_CHAINDATA data
Definition: Msi_atlcom.h:161
~CComEnumImpl()
Definition: Msi_atlcom.h:1028
#define DECLARE_AGGREGATABLE(x)
Definition: Msi_atlcom.h:94
ULONG InternalRelease()
Definition: Msi_atlcom.h:375
Definition: Msi_ocidl.h:48
static void destroy(VARIANT *p)
Definition: Msi_atlcom.h:880
STDMETHOD_(ULONG, AddRef)()
Definition: Msi_atlcom.h:549
CComEnum()
Definition: Msi_atlcom.h:1167
T _CoClass
Definition: Msi_atlcom.h:742
WINOLEAUTAPI DLL_MSICOM_EXIM CreateErrorInfo(ICreateErrorInfo **pperrinfo)
STDMETHOD_(ULONG, AddRef)()
Definition: Msi_atlcom.h:629
static HRESULT WINAPI CreateInstance(void *pv, REFIID riid, LPVOID *ppv)
Definition: Msi_atlcom.h:693
CComObjectLockT(CComObjectRootEx< ThreadModel > *p)
Definition: Msi_atlcom.h:240
Definition: Msi_atlcom.h:951
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
Definition: Msi_atlcom.h:430
IUnknown * m_pUnk
Definition: Msi_atlcom.h:1465
Definition: Msi_atlcom.h:399
Definition: Msi_atlcom.h:358
#define E_FAIL
Definition: PDCwinerror.h:168
static HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, CComAggObject< contained > **pp)
Definition: Msi_atlcom.h:580
CComObjectLockT< _ThreadModel > ObjectLock
Definition: Msi_atlcom.h:363
CComDynamicUnkArray()
Definition: Msi_atlcom.h:1405
Definition: Msi_oaidl.h:215
Definition: Msi_atlcom.h:500
DWORD m_dwFlags
Definition: Msi_atlcom.h:1018
static HRESULT WINAPI CreateInstance(void *pv, REFIID riid, LPVOID *ppv)
Definition: Msi_atlcom.h:658
IUnknown ** begin()
Definition: Msi_atlcom.h:1432
REFIID LPVOID DWORD_PTR dw
Definition: Msi_atlbase.h:90
#define END_COM_MAP()
Definition: Msi_atlcom.h:82
HRESULT FinalConstruct()
Definition: Msi_atlcom.h:522
CollType::iterator m_iter
Definition: Msi_atlcom.h:1206
static void destroy(T *)
Definition: Msi_atlcom.h:861
#define DECLARE_CLASSFACTORY()
Definition: Msi_atlcom.h:100
#define DISP_E_EXCEPTION
Definition: PDCwinerror.h:285
static HRESULT copy(VARIANT *p1, VARIANT *p2)
Definition: Msi_atlcom.h:870
CComObjectLockT< _ThreadModel > ObjectLock
Definition: Msi_atlcom.h:268
Definition: Msi_atlcom.h:990
Base _BaseClass
Definition: Msi_atlcom.h:402
ThreadModel _ThreadModel
Definition: Msi_atlcom.h:361
#define HIWORD(l)
Definition: Msi_atlcom.h:129
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
Definition: Msi_atlcom.h:562
BOOL InlineIsEqualUnknown(REFGUID rguid1)
Definition: Msi_atlbase.h:68
#define MSI_min(a, b)
Definition: Msi_atlcom.h:121
~CComObjectLockT()
Definition: Msi_atlcom.h:247
#define E_OUTOFMEMORY
Definition: PDCwinerror.h:114
REFIID riid
Definition: Msi_atlbase.h:90
Definition: Msi_ocidl.h:95
unsigned short WORD
Definition: PDCwtypes.h:109
int GetSize() const
Definition: Msi_atlcom.h:1450
Definition: Msi_oaidl.h:41
HRESULT QueryInterface(Q **pp) const
Definition: Msi_atlbase.h:529
#define TRUE
Definition: PDCwtypes.h:58
HRESULT WINAPI AtlSetErrorInfo(const CLSID &clsid, LPCOLESTR lpszDesc, DWORD dwHelpID, LPCOLESTR lpszHelpFile, const IID &iid, HRESULT hRes, HINSTANCE hInst)
Definition: Msi_atlcom.h:1324
Definition: Msi_atlcom.h:988
#define DLL_MSICOM_EXIM
Definition: MsiCOM.h:19
static HRESULT WINAPI _Delegate(void *pv, REFIID iid, void **ppvObject, DWORD_PTR dw)
Definition: Msi_atlcom.h:205
static void init(LPOLESTR *p)
Definition: Msi_atlcom.h:917
IUnknown * GetControllingUnknown()
Definition: Msi_atlcom.h:491
STDMETHOD_(ULONG, Release)()
Definition: Msi_atlcom.h:554
static HRESULT copy(LPOLESTR *p1, LPOLESTR *p2)
Definition: Msi_atlcom.h:890
Definition: Msi_atlcom.h:176
CComPtr< IUnknown > m_spUnk
Definition: Msi_atlcom.h:1204
#define ATL_NO_VTABLE
Definition: Msi_atldef.h:21
int m_nSize
Definition: Msi_atlcom.h:1467
STDMETHOD_(ULONG, AddRef)()
Definition: Msi_atlcom.h:416
IEnumOnSTLImpl< Base, piid, T, Copy, CollType > _CComEnumBase
Definition: Msi_atlcom.h:1293
Definition: AtomicLong.h:71
~CComDynamicUnkArray()
Definition: Msi_atlcom.h:1411
Definition: Msi_variant.h:147
ULONG InternalRelease()
Definition: Msi_atlcom.h:305
#define FALSE
Definition: PDCwtypes.h:54
void Unlock()
Definition: Msi_atlcom.h:323
CComEnumImpl()
Definition: Msi_atlcom.h:997
virtual ~CComObjectRootEx()
Definition: Msi_atlcom.h:283
Definition: Msi_oaidl.h:390
Definition: Msi_oaidl.h:59
CComObject(void *=NULL)
Definition: Msi_atlcom.h:403
static void destroy(CONNECTDATA *p)
Definition: Msi_atlcom.h:944
WCHAR TCHAR
Definition: PDCwtypes.h:352
void _SetSubjectObject()
Definition: Msi_atlcom.h:338
static void init(T **)
Definition: Msi_atlcom.h:962
virtual ULONG STDMETHODCALLTYPE Release(void)=0
HRESULT Init(IUnknown *pUnkForRelease, CollType &collection)
Definition: Msi_atlcom.h:1186
#define E_NOINTERFACE
Definition: PDCwinerror.h:132
CComObjectRootEx_NoLock()
Definition: Msi_atlcom.h:366
Definition: Msi_atlcom.h:655
virtual ULONG STDMETHODCALLTYPE AddRef(void)=0
CComEnumOnSTL< Base, piid, T, Copy, CollType, ThreadModel > _CComEnum
Definition: Msi_atlcom.h:1292
Definition: Msi_atlbase.h:247
T * m_begin
Definition: Msi_atlcom.h:1015
FlagBits
Definition: Msi_atlcom.h:1020
OLECHAR __RPC_FAR * LPOLESTR
Definition: PDCwtypes.h:392
static HRESULT copy(T *p1, T *p2)
Definition: Msi_atlcom.h:851
ULONG InternalAddRef()
Definition: Msi_atlcom.h:370
Definition: Msi_atlcom.h:973
Definition: StaticCheck.h:26
STDMETHOD_(ULONG, Release)()
Definition: Msi_atlcom.h:421
Definition: Msi_atlcom.h:848
STDMETHOD_(ULONG, Release)()
Definition: Msi_atlcom.h:476
CComContainedObject(void *pv)
Definition: Msi_atlcom.h:466
const OLECHAR __RPC_FAR * LPCOLESTR
Definition: PDCwtypes.h:394
DWORD Add(IUnknown *pUnk)
Definition: Msi_atlcom.h:1470
Definition: Msi_oaidl.h:472
STDMETHOD() Next(ULONG celt, T *rgelt, ULONG *pceltFetched)
Definition: Msi_atlcom.h:1039
void Lock()
Definition: Msi_atlcom.h:381
contained _BaseClass
Definition: Msi_atlcom.h:505
DWORD ULONG
Definition: PDCwtypes.h:127
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
Definition: Msi_atlcom.h:644
#define FACILITY_ITF
Definition: PDCwinerror.h:74
#define ATLTRY(x)
Definition: Msi_atldef.h:19
#define COM_INTERFACE_ENTRY(x)
Definition: Msi_atlcom.h:54
unsigned long DWORD
Definition: PDCwtypes.h:121
~CComAggObject()
Definition: Msi_atlcom.h:543
#define NULL
Definition: Null.h:10
CComContainedObject< contained > m_contained
Definition: Msi_atlcom.h:602
static HRESULT WINAPI _Chain(void *pv, REFIID iid, void **ppvObject, DWORD_PTR dw)
Definition: Msi_atlcom.h:214
Definition: Msi_atlcom.h:151
Definition: Msi_atlcom.h:234
Definition: Msi_atlbase.h:42
void SetLockCategory(MSynch::EnumDSSLockStackCategory iLockCat)
Definition: Msi_atlcom.h:293
IUnknown __RPC_FAR * pUnk
Definition: Msi_ocidl.h:97
Definition: Msi_ocidl.h:77
#define E_NOTIMPL
Definition: PDCwinerror.h:105
Definition: LockCategories.h:81
Definition: Msi_atlcom.h:237
EnumDSSLockStackCategory
Definition: LockCategories.h:32
static IUnknown *WINAPI GetUnknown(DWORD dwCookie)
Definition: Msi_atlcom.h:1427
void Unlock()
Definition: Msi_atlcom.h:385
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
Definition: Msi_atlcom.h:481
void InternalFinalConstructRelease()
#define REFIID
Definition: PDCwtypes.h:321
STDMETHOD() Clone(Base **ppEnum)
Definition: Msi_atlcom.h:1262
Definition: Base/Base/GUID.h:32
CollType * m_pcollection
Definition: Msi_atlcom.h:1205
HRESULT Init(T *begin, T *end, IUnknown *pUnk, CComEnumFlags flags=AtlFlagNoCopy)
Definition: Msi_atlcom.h:1119
Definition: Msi_atlcom.h:778
IUnknown * GetAt(int nIndex)
Definition: Msi_atlcom.h:1442
WINOLEAPI DLL_MSICOM_EXIM ProgIDFromCLSID(REFCLSID clsid, LPOLESTR FAR *lplpszProgID)
Definition: Msi_atlcom.h:611
CComPtr< IUnknown > m_spUnk
Definition: Msi_atlcom.h:1014