Manager.h
上传用户:lianquan
上传日期:2007-01-02
资源大小:197k
文件大小:2k
源码类别:

ActiveX/DCOM/ATL

开发平台:

Visual C++

  1. //
  2. // Manager.h
  3. //
  4. #ifndef GenericManager_H_
  5. #define GenericManager_H_
  6. #include "..RnsoSupportObserverNotification.h"
  7. #include "..RnsoSupportCCriticalArray.h"
  8. class GenericObjectsIds
  9. {
  10. CArray<DWORD,DWORD> m_adwUsedIDs;
  11. LONG m_dwNextID;
  12. public:
  13. CArray<void*,void*> m_apObject;
  14. GenericObjectsIds();
  15. DWORD GenerateID(void * pObject);
  16. BOOL Find(DWORD dwID,void*& pObject);
  17. void RemoveObjects(void * pObject);
  18. };
  19. class GenericSubscription
  20. {
  21. public:
  22. DWORD m_dwObserver;
  23. DWORD m_dwSubject;
  24. void *  m_pObserver;
  25. void *  m_pSubject;
  26. GenericSubscription( DWORD dwObserverID,void * pObserver,
  27. DWORD dwSubjectID,void * pSubject);
  28. };
  29. class GenericManager
  30. {
  31. static  HANDLE m_hThread;
  32. static DWORD m_ThreadId;
  33. static BOOL m_bContinueToRun;
  34. static  CEvent m_evtStopThread;
  35. static  CEvent m_evtNotification;
  36. static  CCriticalSection m_csServer;
  37. static GenericObjectsIds m_aUsedObjectIDs;
  38. static  CCriticalArray<GenericSubscription*,GenericSubscription*> m_aSubscriptions;
  39. static CCriticalArray<ObserverNotification*,ObserverNotification*> m_aNotifications;
  40. static void  DispatchNotification(ObserverNotification *pNotification);
  41. static  void RemoveSubscriptions(void * pObject);
  42. public:
  43. static  void RemoveObject(void * pObject);
  44. static DWORD GenerateObjectID(BOOL& bOk,void * pObject);
  45. static BOOL AddSubscription(DWORD dwObserverID,DWORD dwSubjectID);
  46. static BOOL RemoveSubscription(DWORD m_dwObserverID,DWORD dwSubjectID,BOOL bAllSubjects);
  47. static BOOL AddNotification(ObserverNotification * pGenericNotification);
  48. static BOOL IsObserverSubscribedToSubject(DWORD dwObserverID,DWORD dwSubjectID);
  49. static BOOL FindObjectID(BSTR strname,DWORD * dwObjectID);
  50. static int FindName(CComBSTR bstr);
  51. static void StartManager();
  52. static void StopManager();
  53. static DWORD   _stdcall ThreadProc( LPVOID lpParam ) ;
  54. };
  55. #endif