00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __CONNECTIONCONTAINER_H__
00024 #define __CONNECTIONCONTAINER_H__
00025
00026 #include <ocidl.h>
00027 #include <vector>
00028 #include <queue>
00029
00030 class VLCConnectionPoint : public IConnectionPoint
00031 {
00032
00033 public:
00034
00035 VLCConnectionPoint(IConnectionPointContainer *p_cpc, REFIID iid) :
00036 _iid(iid), _p_cpc(p_cpc) {};
00037 virtual ~VLCConnectionPoint() {};
00038
00039
00040 STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
00041 {
00042 if( NULL == ppv ) return E_POINTER;
00043 if( (IID_IUnknown == riid)
00044 && (IID_IConnectionPoint == riid) ) {
00045 AddRef();
00046 *ppv = reinterpret_cast<LPVOID>(this);
00047 return NOERROR;
00048 }
00049
00050 return E_NOINTERFACE;
00051 };
00052
00053 STDMETHODIMP_(ULONG) AddRef(void) { return _p_cpc->AddRef(); };
00054 STDMETHODIMP_(ULONG) Release(void) { return _p_cpc->Release(); };
00055
00056
00057 STDMETHODIMP GetConnectionInterface(IID *);
00058 STDMETHODIMP GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *);
00059 STDMETHODIMP Advise(IUnknown *, DWORD *);
00060 STDMETHODIMP Unadvise(DWORD);
00061 STDMETHODIMP EnumConnections(LPENUMCONNECTIONS *);
00062
00063 void fireEvent(DISPID dispIdMember, DISPPARAMS* pDispParams);
00064 void firePropChangedEvent(DISPID dispId);
00065
00066 private:
00067
00068 REFIID _iid;
00069 IConnectionPointContainer *_p_cpc;
00070 std::vector<CONNECTDATA> _connections;
00071 };
00072
00074
00075 class VLCDispatchEvent {
00076
00077 public:
00078 VLCDispatchEvent(DISPID dispId, DISPPARAMS dispParams) :
00079 _dispId(dispId), _dispParams(dispParams) {};
00080 VLCDispatchEvent(const VLCDispatchEvent&);
00081 ~VLCDispatchEvent();
00082
00083 DISPID _dispId;
00084 DISPPARAMS _dispParams;
00085 };
00086
00087 class VLCConnectionPointContainer : public IConnectionPointContainer
00088 {
00089
00090 public:
00091
00092 VLCConnectionPointContainer(VLCPlugin *p_instance);
00093 virtual ~VLCConnectionPointContainer();
00094
00095
00096 STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
00097 {
00098 if( (NULL != ppv)
00099 && (IID_IUnknown == riid)
00100 && (IID_IConnectionPointContainer == riid) ) {
00101 AddRef();
00102 *ppv = reinterpret_cast<LPVOID>(this);
00103 return NOERROR;
00104 }
00105 return _p_instance->pUnkOuter->QueryInterface(riid, ppv);
00106 };
00107
00108 STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
00109 STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
00110
00111
00112 STDMETHODIMP EnumConnectionPoints(LPENUMCONNECTIONPOINTS *);
00113 STDMETHODIMP FindConnectionPoint(REFIID, LPCONNECTIONPOINT *);
00114
00115 void freezeEvents(BOOL);
00116 void fireEvent(DISPID, DISPPARAMS*);
00117 void firePropChangedEvent(DISPID dispId);
00118
00119 private:
00120
00121 VLCPlugin *_p_instance;
00122 BOOL _b_freeze;
00123 VLCConnectionPoint *_p_events;
00124 VLCConnectionPoint *_p_props;
00125 std::vector<LPCONNECTIONPOINT> _v_cps;
00126 std::queue<class VLCDispatchEvent *> _q_events;
00127 };
00128
00129 #endif
00130