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

ActiveX/DCOM/ATL

开发平台:

Visual C++

  1. // GenericObserver.h : Declaration of the CGenericObserver
  2. #ifndef __GENERICOBSERVER_H_
  3. #define __GENERICOBSERVER_H_
  4. #include "resource.h"       // main symbols
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CGenericObserver
  7. class ATL_NO_VTABLE CGenericObserver : 
  8. public CComObjectRootEx<CComMultiThreadModel>,
  9. public CComCoClass<CGenericObserver, &CLSID_GenericObserver>,
  10. public IConnectionPointContainerImpl<CGenericObserver>,
  11. public IGenericObserver,
  12. public IConnectionPointImpl<CGenericObserver,&IID_IGenericObserverNotification>
  13. {
  14. public:
  15. DWORD  m_dwObserverID;
  16. LONG     m_lCountSubjects;
  17. LONG     m_lCountObservers;
  18. CComBSTR m_sname;
  19. CGenericObserver()
  20. {
  21. m_dwObserverID=0;
  22. m_lCountObservers=0;
  23. m_lCountSubjects=0;
  24. }
  25. void FinalRelease( );
  26. HRESULT FinalConstruct( );
  27. void IncSub();
  28. void SubSub();
  29. void IncObs();
  30. void SubObs();
  31. DECLARE_REGISTRY_RESOURCEID(IDR_GENERICOBSERVER)
  32. BEGIN_COM_MAP(CGenericObserver)
  33. COM_INTERFACE_ENTRY(IGenericObserver)
  34. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  35. END_COM_MAP()
  36. BEGIN_CONNECTION_POINT_MAP(CGenericObserver)
  37. CONNECTION_POINT_ENTRY(IID_IGenericObserverNotification)
  38. END_CONNECTION_POINT_MAP()
  39. // Outgoing interface helpers
  40. void OnNotify(DWORD dwSubjectSender,LONG nSize,byte * pBytes);
  41. void OnNotifySubjectBroken(DWORD dwSubject);
  42. // IGenericObserver
  43. public:
  44. STDMETHOD(GetObjectID)(/*[out]*/DWORD * dwID);
  45. STDMETHOD_(HRESULT, GetCountSubscriptions)(/*[out]*/ long * lCount);
  46. STDMETHOD_(HRESULT, GetCountSubscribers)(/*[out]*/ long * lCount);
  47. STDMETHOD_(HRESULT, IsSubscribed)(DWORD dwSubjectID);
  48. STDMETHOD_(HRESULT, Unsubscribe)(/*[in]*/DWORD dwSubjectID,/*[in]*/BOOL bAllSubjects);
  49. STDMETHOD_(HRESULT, Subscribe)(/*[in]*/ DWORD dwSubjectID);
  50. STDMETHOD_(HRESULT, Notify)(/*[in]*/ long nSizeNotification,/*[in,size_is(nSizeNotification)]*/ byte* pNotification);
  51. STDMETHOD_(HRESULT, FindObjectID)(/*[in]*/ BSTR strname,/*[out]*/ DWORD * dwObjectID);
  52. STDMETHOD_(HRESULT, GetName)(/*[out,retval]*/BSTR *strName);
  53. STDMETHOD_(HRESULT, SetName)(/*[in,string]*/BSTR  strName);
  54. };
  55. #endif //__GENERICOBSERVER_H_