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.

291 lines
7.6 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////
  2. // ComponentTypeimpl.h : implementation helper template for component type interface
  3. // Copyright (c) Microsoft Corporation 1999.
  4. #ifndef COMPONENTTYPEIMPL_H
  5. #define COMPONENTTYPEIMPL_H
  6. #pragma once
  7. #include <tuner.h>
  8. #include "errsupp.h"
  9. namespace BDATuningModel {
  10. template<class T,
  11. class MostDerived = IComponentType,
  12. LPCGUID iid = &__uuidof(MostDerived),
  13. LPCGUID LibID = &LIBID_TunerLib,
  14. WORD wMajor = 1,
  15. WORD wMinor = 0,
  16. class tihclass = CComTypeInfoHolder
  17. > class ATL_NO_VTABLE IComponentTypeImpl :
  18. public IPersistPropertyBagImpl<T>,
  19. public IDispatchImpl<MostDerived, iid, LibID, wMajor, wMinor, tihclass>
  20. {
  21. // IComponentType
  22. public:
  23. BEGIN_PROP_MAP(IComponentTypeImpl)
  24. PROP_DATA_ENTRY("Category", m_ComponentCategory, VT_I4)
  25. PROP_DATA_ENTRY("Media Major Type", m_MediaMajorType, VT_BSTR)
  26. PROP_DATA_ENTRY("Media Sub Type", m_MediaSubType, VT_BSTR)
  27. PROP_DATA_ENTRY("Media Format Type", m_MediaFormatType, VT_BSTR)
  28. END_PROP_MAP()
  29. ComponentCategory m_ComponentCategory;
  30. CComBSTR m_MediaMajorType;
  31. CComBSTR m_MediaSubType;
  32. CComBSTR m_MediaFormatType;
  33. IComponentTypeImpl() : m_ComponentCategory(CategoryNotSet) {
  34. GUID2 g(GUID_NULL);
  35. m_MediaMajorType = g.GetBSTR();
  36. m_MediaSubType = g.GetBSTR();
  37. m_MediaFormatType = g.GetBSTR();
  38. }
  39. virtual ~IComponentTypeImpl() {}
  40. STDMETHOD(get_Category)(/*[out, retval]*/ ComponentCategory *pVal) {
  41. try {
  42. if (!pVal) {
  43. return E_POINTER;
  44. }
  45. ATL_LOCKT();
  46. *pVal = m_ComponentCategory;
  47. } catch (...) {
  48. return E_POINTER;
  49. }
  50. return NOERROR;
  51. }
  52. STDMETHOD(put_Category)(/*[in]*/ ComponentCategory newVal) {
  53. ATL_LOCKT();
  54. m_ComponentCategory = newVal;
  55. MARK_DIRTY(T);
  56. return NOERROR;
  57. }
  58. STDMETHOD(get_MediaMajorType)(/*[out, retval]*/ BSTR *pVal) {
  59. try {
  60. if (!pVal) {
  61. return E_POINTER;
  62. }
  63. ATL_LOCKT();
  64. return m_MediaMajorType.CopyTo(pVal);
  65. } catch (...) {
  66. return E_POINTER;
  67. }
  68. return NOERROR;
  69. }
  70. STDMETHOD(get__MediaMajorType)(/*[out, retval]*/ GUID* pMediaMajorTypeGuid) {
  71. try {
  72. if (!pMediaMajorTypeGuid) {
  73. return E_POINTER;
  74. }
  75. ATL_LOCKT();
  76. GUID2 g(m_MediaMajorType);
  77. memcpy(pMediaMajorTypeGuid, &g, sizeof(GUID));
  78. return NOERROR;
  79. } catch (...) {
  80. return E_POINTER;
  81. }
  82. return NOERROR;
  83. }
  84. STDMETHOD(put_MediaMajorType)(/*[in]*/ BSTR newVal) {
  85. try {
  86. GUID2 g(newVal);
  87. return put__MediaMajorType(g);
  88. } catch (ComException &e) {
  89. return e;
  90. } catch (...) {
  91. return ImplReportError(__uuidof(T), IDS_OBJ_NO_INIT, __uuidof(IComponentType), E_UNEXPECTED);
  92. }
  93. }
  94. STDMETHOD(put__MediaMajorType)(/*[in]*/REFCLSID newVal) {
  95. try {
  96. GUID2 g(newVal);
  97. ATL_LOCKT();
  98. m_MediaMajorType = g.GetBSTR();
  99. MARK_DIRTY(T);
  100. return NOERROR;
  101. } catch(...) {
  102. return ImplReportError(__uuidof(T), IDS_OBJ_NO_INIT, __uuidof(IComponentType), E_UNEXPECTED);
  103. }
  104. }
  105. STDMETHOD(get_MediaSubType)(/*[out, retval]*/ BSTR *pVal) {
  106. try {
  107. if (!pVal) {
  108. return E_POINTER;
  109. }
  110. ATL_LOCKT();
  111. return m_MediaSubType.CopyTo(pVal);
  112. } catch (...) {
  113. return E_POINTER;
  114. }
  115. return NOERROR;
  116. }
  117. STDMETHOD(get__MediaSubType)(/*[out, retval]*/ GUID* pMediaSubTypeGuid) {
  118. try {
  119. if (!pMediaSubTypeGuid) {
  120. return E_POINTER;
  121. }
  122. ATL_LOCKT();
  123. GUID2 g(m_MediaSubType);
  124. memcpy(pMediaSubTypeGuid, &g, sizeof(GUID));
  125. return NOERROR;
  126. } catch (...) {
  127. return E_POINTER;
  128. }
  129. return NOERROR;
  130. }
  131. STDMETHOD(put_MediaSubType)(/*[in]*/ BSTR newVal) {
  132. try {
  133. return put__MediaSubType(GUID2(newVal));
  134. } catch (ComException &e) {
  135. return e;
  136. } catch (...) {
  137. return ImplReportError(__uuidof(T), IDS_OBJ_NO_INIT, __uuidof(IComponentType), E_UNEXPECTED);
  138. }
  139. }
  140. STDMETHOD(put__MediaSubType)(/*[in]*/ REFCLSID newVal) {
  141. try {
  142. GUID2 g(newVal);
  143. ATL_LOCKT();
  144. m_MediaSubType = g.GetBSTR();
  145. MARK_DIRTY(T);
  146. return NOERROR;
  147. } catch(...) {
  148. return ImplReportError(__uuidof(T), IDS_OBJ_NO_INIT, __uuidof(IComponentType), E_UNEXPECTED);
  149. }
  150. }
  151. STDMETHOD(get_MediaFormatType)(/*[out, retval]*/ BSTR *pVal) {
  152. try {
  153. if (!pVal) {
  154. return E_POINTER;
  155. }
  156. ATL_LOCKT();
  157. return m_MediaFormatType.CopyTo(pVal);
  158. } catch (...) {
  159. return E_POINTER;
  160. }
  161. return NOERROR;
  162. }
  163. STDMETHOD(get__MediaFormatType)(/*[out, retval]*/ GUID* pMediaFormatTypeGuid) {
  164. try {
  165. if (!pMediaFormatTypeGuid) {
  166. return E_POINTER;
  167. }
  168. ATL_LOCKT();
  169. GUID2 g(m_MediaFormatType);
  170. memcpy(pMediaFormatTypeGuid, &g, sizeof(GUID));
  171. return NOERROR;
  172. } catch (...) {
  173. return E_POINTER;
  174. }
  175. return NOERROR;
  176. }
  177. STDMETHOD(put_MediaFormatType)(/*[in]*/ BSTR newVal) {
  178. try {
  179. return put__MediaFormatType(GUID2(newVal));
  180. } catch (ComException &e) {
  181. return e;
  182. } catch (...) {
  183. return ImplReportError(__uuidof(T), IDS_OBJ_NO_INIT, __uuidof(IComponentType), E_UNEXPECTED);
  184. }
  185. }
  186. STDMETHOD(put__MediaFormatType)(/*[in]*/ REFCLSID newVal) {
  187. try {
  188. GUID2 g(newVal);
  189. ATL_LOCKT();
  190. m_MediaFormatType = g.GetBSTR();
  191. MARK_DIRTY(T);
  192. return NOERROR;
  193. } catch(...) {
  194. return ImplReportError(__uuidof(T), IDS_OBJ_NO_INIT, __uuidof(IComponentType), E_UNEXPECTED);
  195. }
  196. }
  197. STDMETHOD(get_MediaType)(/*[out, retval]*/ AM_MEDIA_TYPE *pVal) {
  198. try {
  199. if (!pVal) {
  200. return E_POINTER;
  201. }
  202. ATL_LOCKT();
  203. pVal->majortype = GUID2(m_MediaMajorType);
  204. pVal->subtype = GUID2(m_MediaSubType);
  205. pVal->formattype = GUID2(m_MediaFormatType);
  206. return NOERROR;
  207. } catch (...) {
  208. return E_POINTER;
  209. }
  210. }
  211. STDMETHOD(put_MediaType)(/*[in]*/ AM_MEDIA_TYPE *pnewVal) {
  212. try {
  213. if (!pnewVal) {
  214. return E_POINTER;
  215. }
  216. ATL_LOCKT();
  217. m_MediaMajorType = GUID2(pnewVal->majortype).GetBSTR();
  218. m_MediaSubType = GUID2(pnewVal->subtype).GetBSTR();
  219. m_MediaFormatType = GUID2(pnewVal->formattype).GetBSTR();
  220. MARK_DIRTY(T);
  221. return NOERROR;
  222. } catch (...) {
  223. return E_FAIL;
  224. }
  225. }
  226. STDMETHOD(Clone) (IComponentType **ppCT) {
  227. try {
  228. if (!ppCT) {
  229. return E_POINTER;
  230. }
  231. ATL_LOCKT();
  232. T* pt = static_cast<T*>(new CComObject<T>);
  233. if (!pt) {
  234. return ImplReportError(__uuidof(T), IDS_E_OUTOFMEMORY, __uuidof(IComponentType), E_OUTOFMEMORY);
  235. }
  236. pt->m_ComponentCategory = m_ComponentCategory;
  237. pt->m_MediaMajorType = m_MediaMajorType;
  238. pt->m_MediaSubType = m_MediaSubType;
  239. pt->m_MediaFormatType = m_MediaFormatType;
  240. pt->m_bRequiresSave = true;
  241. pt->AddRef();
  242. *ppCT = pt;
  243. return NOERROR;
  244. } catch (HRESULT h) {
  245. return h;
  246. } catch (...) {
  247. return E_POINTER;
  248. }
  249. }
  250. };
  251. }; // namespace
  252. #endif // COMPONENTTYPEIMPL_H
  253. // end of file -- componenttypeimpl.h