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.

133 lines
4.8 KiB

  1. /*****************************************************************************
  2. * (C) COPYRIGHT MICROSOFT CORPORATION, 2002
  3. *
  4. * AUTHOR: ByronC
  5. *
  6. * DATE: 3/24/2002
  7. *
  8. * @doc INTERNAL
  9. *
  10. * @module WiaEventNotifier.h - Class definition file for <c WiaEventNotifier> |
  11. *
  12. * This file contains the class definition for <c WiaEventNotifier>. This is
  13. * a server-side object used to manage run-time event notifications.
  14. *
  15. *****************************************************************************/
  16. //
  17. // Defines
  18. //
  19. #define WiaEventNotifier_UNINIT_SIG 0x556E6557
  20. #define WiaEventNotifier_INIT_SIG 0x496E6557
  21. #define WiaEventNotifier_TERM_SIG 0x546E6557
  22. #define WiaEventNotifier_DEL_SIG 0x446E6557
  23. /*****************************************************************************
  24. *
  25. * @doc INTERNAL
  26. *
  27. * @class WiaEventNotifier | Manages run-time event notifications to registered clients
  28. *
  29. * @comm
  30. * When WIA receives a device event, it needs to know which client to notify.
  31. * Therefore, each client wishing to receive notifications registers with the
  32. * WIA Service.
  33. *
  34. * The <c WiaEventNotifier> class manages this list of clients. It is
  35. * responsible for notifiying these client when a relevant event occurs.
  36. *
  37. *****************************************************************************/
  38. class WiaEventNotifier
  39. {
  40. //@access Public members
  41. public:
  42. // @cmember Constructor
  43. WiaEventNotifier();
  44. // @cmember Destructor
  45. virtual ~WiaEventNotifier();
  46. // @cmember Increment reference count
  47. virtual ULONG __stdcall AddRef();
  48. // @cmember Decrement reference count
  49. virtual ULONG __stdcall Release();
  50. // @cmember Initializer method
  51. HRESULT Initialize();
  52. // @cmember Add this client to our list of clients
  53. HRESULT AddClient(WiaEventClient *pWiaEventClient);
  54. // @cmember Remove client to our list of clients
  55. HRESULT RemoveClient(STI_CLIENT_CONTEXT ClientContext);
  56. // @cmember Returns the appropriate <c WiaEventClient> from its context
  57. WiaEventClient* GetClientFromContext(STI_CLIENT_CONTEXT ClientContext);
  58. // @cmember Marks the appropriate <c WiaEventClient> for later removal
  59. VOID MarkClientForRemoval(STI_CLIENT_CONTEXT ClientContext);
  60. // @cmember Walks the client list and notifies suitably registered clients of an event
  61. VOID NotifyClients(WiaEventInfo *pWiaEventInfo);
  62. // @cmember Walks the client list and removes any that are marked for removal
  63. VOID CleanupClientList();
  64. // @cmember CreateInstance method
  65. //static void CreateInstance();
  66. //@access Private members
  67. protected:
  68. // @cmember Checks whether the specified client is in the client list
  69. BOOL isRegisteredClient(STI_CLIENT_CONTEXT ClientContext);
  70. // @cmember Walks client list and releases all elements.
  71. VOID DestroyClientList();
  72. // @cmember Copies the client list. Each client in the list is not addref'd.
  73. HRESULT CopyClientListNoAddRef(CSimpleLinkedList<WiaEventClient*> &newList);
  74. // @cmember Signature of class
  75. ULONG m_ulSig;
  76. // @cmember Ref count
  77. ULONG m_cRef;
  78. // @cmember List holding clients who are registered to receive notifications
  79. CSimpleLinkedList<WiaEventClient*> m_ListOfClients;
  80. // @cmember Synchronization primitive used to protect access to the list of client
  81. CRIT_SECT m_csClientListSync;
  82. //
  83. // Comments for member variables
  84. //
  85. // @mdata ULONG | WiaEventNotifier | m_ulSig |
  86. // The signature for this class, used for debugging purposes.
  87. // Doing a <nl>"db [addr_of_class]"<nl> would yield one of the following
  88. // signatures for this class:
  89. // @flag WiaEventNotifier_UNINIT_SIG | 'WenU' - Object has not been successfully
  90. // initialized
  91. // @flag WiaEventNotifier_INIT_SIG | 'WenI' - Object has been successfully
  92. // initialized
  93. // @flag WiaEventNotifier_TERM_SIG | 'WenT' - Object is in the process of
  94. // terminating.
  95. // @flag WiaEventNotifier_INIT_SIG | 'WenD' - Object has been deleted
  96. // (destructor was called)
  97. //
  98. // @mdata ULONG | WiaEventNotifier | m_cRef |
  99. // The reference count for this class. Used for lifetime
  100. // management.
  101. //
  102. // @mdata CSimpleLinkedList<lt>STI_CLIENT_CONTEXT<gt> | WiaEventNotifier | m_ListOfClients |
  103. // This member holds the list of clients who are registered to receive WIA event notifications.
  104. //
  105. //@mdata CRIT_SECT | WiaEventNotifier | m_csClientListSync |
  106. // This is a wrapper for a syncronization primitive used to protect the client list.
  107. //
  108. };
  109. //
  110. // There is only one instance of the WiaEventNotifier
  111. //
  112. extern WiaEventNotifier *g_pWiaEventNotifier;