GenericObserver.h
资源名称:rnso.zip [点击查看]
上传用户:lianquan
上传日期:2007-01-02
资源大小:197k
文件大小:2k
源码类别:
ActiveX/DCOM/ATL
开发平台:
Visual C++
- // GenericObserver.h : Declaration of the CGenericObserver
- #ifndef __GENERICOBSERVER_H_
- #define __GENERICOBSERVER_H_
- #include "resource.h" // main symbols
- /////////////////////////////////////////////////////////////////////////////
- // CGenericObserver
- class ATL_NO_VTABLE CGenericObserver :
- public CComObjectRootEx<CComMultiThreadModel>,
- public CComCoClass<CGenericObserver, &CLSID_GenericObserver>,
- public IConnectionPointContainerImpl<CGenericObserver>,
- public IGenericObserver,
- public IConnectionPointImpl<CGenericObserver,&IID_IGenericObserverNotification>
- {
- public:
- DWORD m_dwObserverID;
- LONG m_lCountSubjects;
- LONG m_lCountObservers;
- CComBSTR m_sname;
- CGenericObserver()
- {
- m_dwObserverID=0;
- m_lCountObservers=0;
- m_lCountSubjects=0;
- }
- void FinalRelease( );
- HRESULT FinalConstruct( );
- void IncSub();
- void SubSub();
- void IncObs();
- void SubObs();
- DECLARE_REGISTRY_RESOURCEID(IDR_GENERICOBSERVER)
- BEGIN_COM_MAP(CGenericObserver)
- COM_INTERFACE_ENTRY(IGenericObserver)
- COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
- END_COM_MAP()
- BEGIN_CONNECTION_POINT_MAP(CGenericObserver)
- CONNECTION_POINT_ENTRY(IID_IGenericObserverNotification)
- END_CONNECTION_POINT_MAP()
- // Outgoing interface helpers
- void OnNotify(DWORD dwSubjectSender,LONG nSize,byte * pBytes);
- void OnNotifySubjectBroken(DWORD dwSubject);
- // IGenericObserver
- public:
- STDMETHOD(GetObjectID)(/*[out]*/DWORD * dwID);
- STDMETHOD_(HRESULT, GetCountSubscriptions)(/*[out]*/ long * lCount);
- STDMETHOD_(HRESULT, GetCountSubscribers)(/*[out]*/ long * lCount);
- STDMETHOD_(HRESULT, IsSubscribed)(DWORD dwSubjectID);
- STDMETHOD_(HRESULT, Unsubscribe)(/*[in]*/DWORD dwSubjectID,/*[in]*/BOOL bAllSubjects);
- STDMETHOD_(HRESULT, Subscribe)(/*[in]*/ DWORD dwSubjectID);
- STDMETHOD_(HRESULT, Notify)(/*[in]*/ long nSizeNotification,/*[in,size_is(nSizeNotification)]*/ byte* pNotification);
- STDMETHOD_(HRESULT, FindObjectID)(/*[in]*/ BSTR strname,/*[out]*/ DWORD * dwObjectID);
- STDMETHOD_(HRESULT, GetName)(/*[out,retval]*/BSTR *strName);
- STDMETHOD_(HRESULT, SetName)(/*[in,string]*/BSTR strName);
- };
- #endif //__GENERICOBSERVER_H_