Source code of Windows XP (NT5)
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.

225 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. dataobj.h
  5. Abstract:
  6. Snapin data object definitions
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef _DATAOBJ_H
  14. #define _DATAOBJ_H
  15. class CDataObject:
  16. public IDataObject,
  17. public CComObjectRoot
  18. {
  19. friend class CSnapin;
  20. //
  21. // ATL Maps
  22. //
  23. DECLARE_NOT_AGGREGATABLE(CDataObject)
  24. BEGIN_COM_MAP(CDataObject)
  25. COM_INTERFACE_ENTRY(IDataObject)
  26. END_COM_MAP()
  27. //
  28. // Construction/Destruction
  29. //
  30. public:
  31. CDataObject()
  32. {
  33. #ifdef _DEBUG
  34. m_ComponentData = NULL;
  35. #endif // _DEBUG
  36. };
  37. ~CDataObject()
  38. {
  39. #ifdef _DEBUG
  40. m_ComponentData = NULL;
  41. #endif // _DEBUG
  42. };
  43. //
  44. // Clipboard formats that are required by the console
  45. //
  46. public:
  47. static unsigned int m_cfNodeType; // Required by the console
  48. static unsigned int m_cfNodeTypeString; // Required by the console
  49. static unsigned int m_cfDisplayName; // Required by the console
  50. static unsigned int m_cfCoClass; // Required by the console
  51. static unsigned int m_cfInternal; // internal
  52. /*
  53. //
  54. // Multi-selection
  55. //
  56. static unsigned int m_cfpMultiSelDataObj;
  57. static unsigned int m_cfMultiObjTypes;
  58. static unsigned int m_cfMultiSelDataObjs;
  59. */
  60. //
  61. // Published information
  62. //
  63. static unsigned int m_cfMyComputMachineName;
  64. static unsigned int m_cfISMMachineName; // Machine name (e.g. "ronaldm2")
  65. static unsigned int m_cfISMService; // Service string (e.g. "w3svc")
  66. static unsigned int m_cfISMInstance; // Instance number
  67. static unsigned int m_cfISMParentPath;
  68. static unsigned int m_cfISMNode;
  69. static unsigned int m_cfISMMetaPath; // Complete metabase path
  70. //
  71. // Standard IDataObject methods
  72. //
  73. public:
  74. STDMETHOD(GetData)(LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium);
  75. STDMETHOD(GetDataHere)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium);
  76. STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC * ppEnumFormatEtc);
  77. ULONG InternalAddRef()
  78. {
  79. #ifdef _DEBUG
  80. ASSERT(m_ComponentData != NULL);
  81. ++(m_ComponentData->m_cDataObjects);
  82. #endif
  83. return CComObjectRoot::InternalAddRef();
  84. }
  85. ULONG InternalRelease()
  86. {
  87. #ifdef _DEBUG
  88. ASSERT(m_ComponentData != NULL);
  89. --(m_ComponentData->m_cDataObjects);
  90. #endif
  91. return CComObjectRoot::InternalRelease();
  92. }
  93. //
  94. // Not Implemented
  95. //
  96. private:
  97. STDMETHOD(QueryGetData)(LPFORMATETC lpFormatetc)
  98. {
  99. return E_NOTIMPL;
  100. };
  101. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
  102. {
  103. return E_NOTIMPL;
  104. };
  105. STDMETHOD(SetData)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
  106. {
  107. return E_NOTIMPL;
  108. };
  109. STDMETHOD(DAdvise)(
  110. IN LPFORMATETC lpFormatetc,
  111. IN DWORD advf,
  112. IN LPADVISESINK pAdvSink,
  113. IN LPDWORD pdwConnection
  114. )
  115. {
  116. return E_NOTIMPL;
  117. };
  118. STDMETHOD(DUnadvise)(DWORD dwConnection)
  119. {
  120. return E_NOTIMPL;
  121. };
  122. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA * ppEnumAdvise)
  123. {
  124. return E_NOTIMPL;
  125. };
  126. //
  127. // Implementation
  128. //
  129. public:
  130. void SetType(
  131. IN DATA_OBJECT_TYPES type
  132. )
  133. {
  134. ASSERT(m_internal.m_type == CCT_UNINITIALIZED);
  135. m_internal.m_type = type;
  136. }
  137. void SetCookie(
  138. IN MMC_COOKIE cookie
  139. )
  140. {
  141. m_internal.m_cookie = cookie;
  142. }
  143. void SetClsid(
  144. IN const CLSID & clsid
  145. )
  146. {
  147. m_internal.m_clsid = clsid;
  148. }
  149. #ifdef _DEBUG
  150. //
  151. // This is used only as a diagnostic in debug builds to track if
  152. // anyone is hanging on to any data objects that's have been handed out
  153. // Snapins should view context data objects as ephemeral.
  154. //
  155. public:
  156. void SetComponentData(
  157. IN CComponentDataImpl * pCCD
  158. )
  159. {
  160. ASSERT(m_ComponentData == NULL && pCCD != NULL);
  161. m_ComponentData = pCCD;
  162. };
  163. private:
  164. CComponentDataImpl * m_ComponentData;
  165. #endif // _DEBUG
  166. private:
  167. //
  168. // Field types as used by CreateMetaField
  169. //
  170. enum META_FIELD
  171. {
  172. META_SERVICE,
  173. META_INSTANCE,
  174. META_PARENT,
  175. META_NODE,
  176. /**/
  177. META_WHOLE
  178. };
  179. HRESULT CreateNodeTypeData(LPSTGMEDIUM lpMedium);
  180. HRESULT CreateNodeTypeStringData(LPSTGMEDIUM lpMedium);
  181. HRESULT CreateDisplayName(LPSTGMEDIUM lpMedium);
  182. HRESULT CreateMachineName(LPSTGMEDIUM lpMedium);
  183. HRESULT CreateMetaField(LPSTGMEDIUM lpMedium, META_FIELD fld);
  184. HRESULT CreateInternal(LPSTGMEDIUM lpMedium);
  185. HRESULT CreateCoClassID(LPSTGMEDIUM lpMedium);
  186. HRESULT Create(const void * pBuffer, int len, LPSTGMEDIUM lpMedium);
  187. INTERNAL m_internal;
  188. };
  189. #endif // _DATAOBJ_H