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.

369 lines
11 KiB

  1. /*****************************************************************************
  2. * (C) COPYRIGHT MICROSOFT CORPORATION, 2002
  3. *
  4. * AUTHOR: ByronC
  5. *
  6. * DATE: 3/25/2002
  7. *
  8. * @doc INTERNAL
  9. *
  10. * @module WiaEventInfo.cpp - Declaration for <c WiaEventInfo> |
  11. *
  12. * This file contains the implementation for the <c WiaEventInfo> class.
  13. *
  14. *****************************************************************************/
  15. #include "cplusinc.h"
  16. #include "coredbg.h"
  17. /*****************************************************************************
  18. * @doc INTERNAL
  19. *
  20. * @mfunc | WiaEventInfo | WiaEventInfo |
  21. *
  22. * We initialize all member variables. In general, this sets the values to 0,
  23. * except:
  24. * <nl><md WiaEventInfo::m_cRef> is set to be 1.
  25. *
  26. *****************************************************************************/
  27. WiaEventInfo::WiaEventInfo() :
  28. m_cRef(1)
  29. {
  30. //Trace("WiaEventInfo contructor for %p", this);
  31. m_guidEvent = GUID_NULL;
  32. m_bstrEventDescription = NULL;
  33. m_bstrDeviceID = NULL;
  34. m_bstrDeviceDescription = NULL;
  35. m_bstrFullItemName = NULL;
  36. m_dwDeviceType = 0;
  37. m_ulEventType = 0;
  38. }
  39. /*****************************************************************************
  40. * @doc INTERNAL
  41. *
  42. * @mfunc | WiaEventInfo | WiaEventInfo |
  43. *
  44. * Copy Constructor.
  45. *
  46. *****************************************************************************/
  47. WiaEventInfo::WiaEventInfo(
  48. WiaEventInfo *pWiaEventInfo)
  49. {
  50. //Trace("WiaEventInfo contructor2 for %p", this);
  51. if (pWiaEventInfo)
  52. {
  53. m_guidEvent = pWiaEventInfo->m_guidEvent;
  54. m_bstrEventDescription = SysAllocString(pWiaEventInfo->m_bstrEventDescription);
  55. m_bstrDeviceID = SysAllocString(pWiaEventInfo->m_bstrDeviceID);
  56. m_bstrDeviceDescription = SysAllocString(pWiaEventInfo->m_bstrDeviceDescription);
  57. m_bstrFullItemName = SysAllocString(pWiaEventInfo->m_bstrFullItemName);
  58. m_dwDeviceType = pWiaEventInfo->m_dwDeviceType;
  59. m_ulEventType = pWiaEventInfo->m_ulEventType;
  60. }
  61. }
  62. /*****************************************************************************
  63. * @doc INTERNAL
  64. *
  65. * @mfunc | WiaEventInfo | ~WiaEventInfo |
  66. *
  67. * Free all resources.
  68. *
  69. *****************************************************************************/
  70. WiaEventInfo::~WiaEventInfo()
  71. {
  72. //Trace("==> ~WiaEventInfo destructor for %p", this);
  73. m_cRef = 0;
  74. m_guidEvent = GUID_NULL;
  75. if (m_bstrEventDescription)
  76. {
  77. SysFreeString(m_bstrEventDescription);
  78. m_bstrEventDescription = NULL;
  79. }
  80. if (m_bstrDeviceID)
  81. {
  82. SysFreeString(m_bstrDeviceID);
  83. m_bstrDeviceID = NULL;
  84. }
  85. if (m_bstrDeviceDescription)
  86. {
  87. SysFreeString(m_bstrDeviceDescription);
  88. m_bstrDeviceDescription = NULL;
  89. }
  90. if (m_bstrFullItemName)
  91. {
  92. SysFreeString(m_bstrFullItemName);
  93. m_bstrFullItemName = NULL;
  94. }
  95. m_dwDeviceType = 0;
  96. m_ulEventType = 0;
  97. //Trace("<== ~WiaEventInfo destructor for %p", this);
  98. }
  99. /*****************************************************************************
  100. * @doc INTERNAL
  101. *
  102. * @mfunc ULONG | WiaEventInfo | AddRef |
  103. *
  104. * Increments this object's ref count. We should always AddRef when handing
  105. * out a pointer to this object.
  106. *
  107. * @rvalue Count |
  108. * The reference count after the count has been incremented.
  109. *****************************************************************************/
  110. ULONG __stdcall WiaEventInfo::AddRef()
  111. {
  112. InterlockedIncrement((long*) &m_cRef);
  113. return m_cRef;
  114. }
  115. /*****************************************************************************
  116. * @doc INTERNAL
  117. *
  118. * @mfunc ULONG | WiaEventInfo | Release |
  119. *
  120. * Decrement this object's ref count. We should always Release when finished
  121. * with a pointer to this object.
  122. *
  123. * @rvalue Count |
  124. * The reference count after the count has been decremented.
  125. *****************************************************************************/
  126. ULONG __stdcall WiaEventInfo::Release()
  127. {
  128. ULONG ulRefCount = m_cRef - 1;
  129. if (InterlockedDecrement((long*) &m_cRef) == 0) {
  130. delete this;
  131. return 0;
  132. }
  133. return ulRefCount;
  134. }
  135. /*****************************************************************************
  136. * @doc INTERNAL
  137. *
  138. * @mfunc GUID | WiaEventInfo | getEventGuid |
  139. *
  140. * Accessor method for <md WiaEventInfo::m_guidEvent>
  141. *
  142. * @rvalue GUID |
  143. * The event guid.
  144. *****************************************************************************/
  145. GUID WiaEventInfo::getEventGuid()
  146. {
  147. return m_guidEvent;
  148. }
  149. /*****************************************************************************
  150. * @doc INTERNAL
  151. *
  152. * @mfunc BSTR | WiaEventInfo | getEventDescription |
  153. *
  154. * Accessor method for <md WiaEventInfo::m_bstrEventDescription>
  155. *
  156. * @rvalue BSTR |
  157. * The event description.
  158. *****************************************************************************/
  159. BSTR WiaEventInfo::getEventDescription()
  160. {
  161. return m_bstrEventDescription;
  162. }
  163. /*****************************************************************************
  164. * @doc INTERNAL
  165. *
  166. * @mfunc BSTR | WiaEventInfo | getDeviceID |
  167. *
  168. * Accessor method for <md WiaEventInfo::m_bstrDeviceID>
  169. *
  170. * @rvalue BSTR |
  171. * The event description.
  172. *****************************************************************************/
  173. BSTR WiaEventInfo::getDeviceID()
  174. {
  175. return m_bstrDeviceID;
  176. }
  177. /*****************************************************************************
  178. * @doc INTERNAL
  179. *
  180. * @mfunc BSTR | WiaEventInfo | getDeviceDescription |
  181. *
  182. * Accessor method for <md WiaEventInfo::m_bstrDeviceDescription>
  183. *
  184. * @rvalue BSTR |
  185. * The device description.
  186. *****************************************************************************/
  187. BSTR WiaEventInfo::getDeviceDescription()
  188. {
  189. return m_bstrDeviceDescription;
  190. }
  191. /*****************************************************************************
  192. * @doc INTERNAL
  193. *
  194. * @mfunc BSTR | WiaEventInfo | getFullItemName |
  195. *
  196. * Accessor method for <md WiaEventInfo::m_bstrFullItemName>
  197. *
  198. * @rvalue BSTR |
  199. * The full item name.
  200. *****************************************************************************/
  201. BSTR WiaEventInfo::getFullItemName()
  202. {
  203. return m_bstrFullItemName;
  204. }
  205. /*****************************************************************************
  206. * @doc INTERNAL
  207. *
  208. * @mfunc DWORD | WiaEventInfo | getDeviceType |
  209. *
  210. * Accessor method for <md WiaEventInfo::m_dwDeviceType>
  211. *
  212. * @rvalue DWORD |
  213. * The STI device type.
  214. *****************************************************************************/
  215. DWORD WiaEventInfo::getDeviceType()
  216. {
  217. return m_dwDeviceType;
  218. }
  219. /*****************************************************************************
  220. * @doc INTERNAL
  221. *
  222. * @mfunc ULONG | WiaEventInfo | getEventType |
  223. *
  224. * Accessor method for <md WiaEventInfo::m_ulEventType>
  225. *
  226. * @rvalue ULONG |
  227. * The event type.
  228. *****************************************************************************/
  229. ULONG WiaEventInfo::getEventType()
  230. {
  231. return m_ulEventType;
  232. }
  233. /*****************************************************************************
  234. * @doc INTERNAL
  235. *
  236. * @mfunc VOID | WiaEventInfo | setEventGuid |
  237. *
  238. * Accessor method for <md WiaEventInfo::m_guidEvent>
  239. *
  240. *****************************************************************************/
  241. VOID WiaEventInfo::setEventGuid(
  242. GUID guidEvent)
  243. {
  244. m_guidEvent = guidEvent;
  245. }
  246. /*****************************************************************************
  247. * @doc INTERNAL
  248. *
  249. * @mfunc VOID | WiaEventInfo | setEventDescription |
  250. *
  251. * Accessor method for <md WiaEventInfo::m_bstrEventDescription>
  252. * We allocate our own copy of the incoming string.
  253. *
  254. *****************************************************************************/
  255. VOID WiaEventInfo::setEventDescription(
  256. WCHAR* wszEventDescription)
  257. {
  258. if (m_bstrEventDescription)
  259. {
  260. SysFreeString(m_bstrEventDescription);
  261. m_bstrEventDescription = NULL;
  262. }
  263. m_bstrEventDescription = SysAllocString(wszEventDescription);
  264. }
  265. /*****************************************************************************
  266. * @doc INTERNAL
  267. *
  268. * @mfunc VOID | WiaEventInfo | setDeviceID |
  269. *
  270. * Accessor method for <md WiaEventInfo::m_bstrDeviceID>
  271. * We allocate our own copy of the incoming string.
  272. *
  273. *****************************************************************************/
  274. VOID WiaEventInfo::setDeviceID(
  275. WCHAR* wszDeviceID)
  276. {
  277. if (m_bstrDeviceID)
  278. {
  279. SysFreeString(m_bstrDeviceID);
  280. m_bstrDeviceID = NULL;
  281. }
  282. m_bstrDeviceID = SysAllocString(wszDeviceID);
  283. }
  284. /*****************************************************************************
  285. * @doc INTERNAL
  286. *
  287. * @mfunc VOID | WiaEventInfo | setDeviceDescription |
  288. *
  289. * We allocate our own copy of the incoming string.
  290. * Accessor method for <md WiaEventInfo::m_bstrDeviceDescription>
  291. *
  292. *****************************************************************************/
  293. VOID WiaEventInfo::setDeviceDescription(
  294. WCHAR* wszDeviceDescription)
  295. {
  296. if (m_bstrDeviceDescription)
  297. {
  298. SysFreeString(m_bstrDeviceDescription);
  299. m_bstrDeviceDescription = NULL;
  300. }
  301. m_bstrDeviceDescription = SysAllocString(wszDeviceDescription);
  302. }
  303. /*****************************************************************************
  304. * @doc INTERNAL
  305. *
  306. * @mfunc VOID | WiaEventInfo | setFullItemName |
  307. *
  308. * Accessor method for <md WiaEventInfo::m_bstrFullItemName>
  309. * We allocate our own copy of the incoming string.
  310. *
  311. *****************************************************************************/
  312. VOID WiaEventInfo::setFullItemName(
  313. WCHAR* wszFullItemName)
  314. {
  315. if (m_bstrFullItemName)
  316. {
  317. SysFreeString(m_bstrFullItemName);
  318. m_bstrFullItemName = NULL;
  319. }
  320. m_bstrFullItemName = SysAllocString(wszFullItemName);
  321. }
  322. /*****************************************************************************
  323. * @doc INTERNAL
  324. *
  325. * @mfunc VOID | WiaEventInfo | setDeviceType |
  326. *
  327. * Accessor method for <md WiaEventInfo::m_dwDeviceType>
  328. *
  329. *****************************************************************************/
  330. VOID WiaEventInfo::setDeviceType(
  331. DWORD dwDeviceType)
  332. {
  333. m_dwDeviceType = dwDeviceType;
  334. }
  335. /*****************************************************************************
  336. * @doc INTERNAL
  337. *
  338. * @mfunc VOID | WiaEventInfo | setEventType |
  339. *
  340. * Accessor method for <md WiaEventInfo::m_ulEventType>
  341. *
  342. *****************************************************************************/
  343. VOID WiaEventInfo::setEventType(
  344. ULONG ulEventType)
  345. {
  346. m_ulEventType = ulEventType;
  347. }