Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
6.0 KiB

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright(C) 1997-1998 Microsoft Corporation all rights reserved.
  4. //
  5. // Module: sdofactory.h
  6. //
  7. // Project: Everest
  8. //
  9. // Description: SDO Factory Class
  10. //
  11. // Log:
  12. //
  13. // When Who What
  14. // ---- --- ----
  15. // 9/08/98 TLP Initial Version
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef __INC_SDO_FACTORY_H_
  19. #define __INC_SDO_FACTORY_H_
  20. #include "resource.h"
  21. #include <ias.h>
  22. #include <sdoiaspriv.h>
  23. #include "sdo.h"
  24. //////////////////////////////////////////////////////////////////////////////
  25. template <class T>
  26. class CSdoFactoryImpl
  27. {
  28. public:
  29. CSdoFactoryImpl() { }
  30. ~CSdoFactoryImpl() { }
  31. //////////////////////////////////////////////////////////////////////////
  32. static ISdo* WINAPI MakeSdo(
  33. LPCWSTR lpszSdoName,
  34. LPCWSTR lpszSdoProgId,
  35. ISdoMachine* pAttachedMachine,
  36. IDataStoreObject* pDSObject,
  37. ISdoCollection* pParent,
  38. bool fInitNew
  39. )
  40. {
  41. ISdo* pSdo = NULL;
  42. auto_ptr< CComObjectNoLock<T> > pSdoNew (new CComObjectNoLock<T>);
  43. if ( SUCCEEDED(pSdoNew->InternalInitialize(
  44. lpszSdoName,
  45. lpszSdoProgId,
  46. pAttachedMachine,
  47. pDSObject,
  48. pParent,
  49. fInitNew
  50. )) )
  51. {
  52. pSdo = dynamic_cast<ISdo*>(pSdoNew.release());
  53. }
  54. return pSdo;
  55. }
  56. //////////////////////////////////////////////////////////////////////////
  57. static ISdo* WINAPI MakeSdo(
  58. LPCWSTR lpszSdoName,
  59. LPCWSTR lpszSdoProgId,
  60. ISdoSchema* pSdoSchema,
  61. IDataStoreObject* pDSObject,
  62. ISdoCollection* pParent,
  63. bool fInitNew
  64. )
  65. {
  66. ISdo* pSdo = NULL;
  67. auto_ptr< CComObjectNoLock<T> > pSdoNew (new CComObjectNoLock<T>);
  68. if ( SUCCEEDED(pSdoNew->InternalInitialize(
  69. lpszSdoName,
  70. lpszSdoProgId,
  71. pSdoSchema,
  72. pDSObject,
  73. pParent,
  74. fInitNew
  75. )) )
  76. {
  77. pSdo = dynamic_cast<ISdo*>(pSdoNew.release());
  78. }
  79. return pSdo;
  80. }
  81. private:
  82. CSdoFactoryImpl(const CSdoFactoryImpl& rhs);
  83. CSdoFactoryImpl& operator = (CSdoFactoryImpl& rhs);
  84. };
  85. //////////////////////////////////////////////////////////////////////////////
  86. #define DECLARE_SDO_FACTORY(x) static CSdoFactoryImpl<x> m_Factory;
  87. //////////////////////////////////////////////////////////////////////////////
  88. typedef ISdo* (WINAPI *PFNFACTORY1)(
  89. LPCWSTR lpszSdoName,
  90. LPCWSTR lpszSdoProgId,
  91. ISdoMachine* pSdoMachine,
  92. IDataStoreObject* pDSObject,
  93. ISdoCollection* pParent,
  94. bool fInitNew
  95. );
  96. //////////////////////////////////////////////////////////////////////////////
  97. typedef ISdo* (WINAPI *PFNFACTORY2)(
  98. LPCWSTR lpszSdoName,
  99. LPCWSTR lpszSdoProgId,
  100. ISdoSchema* pSdoSchema,
  101. IDataStoreObject* pDSObject,
  102. ISdoCollection* pParent,
  103. bool fInitNew
  104. );
  105. //////////////////////////////////////////////////////////////////////////////
  106. typedef struct _SDO_CLASS_FACTORY_INFO
  107. {
  108. LPCWSTR pProgId;
  109. PFNFACTORY1 pfnFactory1;
  110. PFNFACTORY2 pfnFactory2;
  111. } SDO_CLASS_FACTORY_INFO, *PSDO_CLASS_FACTORY_INFO;
  112. //////////////////////////////////////////////////////////////////////////////
  113. #define BEGIN_SDOFACTORY_MAP(x) SDO_CLASS_FACTORY_INFO x[] = {
  114. #define DEFINE_SDOFACTORY_ENTRY_1(x,y) { x, y::m_Factory.MakeSdo, NULL },
  115. #define DEFINE_SDOFACTORY_ENTRY_2(x,y) { x, NULL, y::m_Factory.MakeSdo },
  116. #define END_SDOFACTORY_MAP() { NULL, CSdoComponent::m_Factory.MakeSdo, NULL } };
  117. //////////////////////////////////////////////////////////////////////////////
  118. ISdo* MakeSDO(
  119. /*[in]*/ LPCWSTR lpszSdoName,
  120. /*[in]*/ LPCWSTR lpszSdoProgId,
  121. /*[in]*/ ISdoMachine* pAttachedMachine,
  122. /*[in]*/ IDataStoreObject* pDSObject,
  123. /*[in]*/ ISdoCollection* pParent,
  124. /*[in]*/ bool fInitNew
  125. );
  126. ///////////////////////////////////////////////////////////////////
  127. ISdo* MakeSDO(
  128. /*[in]*/ LPCWSTR lpszSdoName,
  129. /*[in]*/ LPCWSTR lpszSdoProgId,
  130. /*[in]*/ ISdoSchema* pSdoSchema,
  131. /*[in]*/ IDataStoreObject* pDSObject,
  132. /*[in]*/ ISdoCollection* pParent,
  133. /*[in]*/ bool fInitNew
  134. );
  135. ///////////////////////////////////////////////////////////////////
  136. ISdoCollection* MakeSDOCollection(
  137. LPCWSTR lpszCreateClassId,
  138. ISdoMachine* pAttachedMachine,
  139. IDataStoreContainer* pDSContainer,
  140. size_t maxSize
  141. );
  142. #endif // __INC_SDO_FACTORY_H_