InterfaceProxy.h
上传用户:baixin
上传日期:2008-03-13
资源大小:4795k
文件大小:4k
- /* InterfaceProxy.h - COM/DCOM InterfaceProxy class definition */
- /* Copyright (c) 1998 Wind River Systems, Inc. */
- /*
- modification history
- --------------------
- 01n,24jul01,dbs add public inner-proxy structure
- 01m,19jul01,dbs fix include-path of Remoting.h
- 01l,13jul01,dbs fix up includes
- 01k,06jul99,dbs add copy-ctor and assignment-operator
- 01j,10jun99,dbs remove inclusion of comNew.h
- 01i,03jun99,dbs remove refs to comSyncLib
- 01h,13may99,dbs remove usage of IRpcChannelBuffer
- 01g,11may99,dbs simplify proxy remoting architecture
- 01f,11may99,dbs change name of ChannelBuffer.h to Remoting.h
- 01e,29apr99,dbs fix -Wall warnings
- 01d,28apr99,dbs make all classes allocate from same pool
- 01c,27apr99,dbs add mem-pool to class
- 01b,21apr99,dbs add include for IRpcChannelBuffer
- 01a,20apr99,dbs created during Grand Renaming
- */
- #ifndef __INCInterfaceProxy_h
- #define __INCInterfaceProxy_h
- #include "private/comMisc.h"
- #include "dcomLib.h"
- #include "orpc.h"
- ///////////////////////////////////////////////////////////////////////////
- //
- // VxInterfaceProxy - a single-interface proxy object that can be
- // aggregated by the 'proxy manager' VxStdProxy and represents a
- // single interface on a 'remoted' object.
- //
- // It will be used by the proxy-stub generation code to implement the
- // methods for the real proxy when standard marshaling is used. The
- // actual implementation of the managed-interface methods takes place
- // in functions in the managed vtable.
- //
- // The class implements IUnknown directly -- this is the 'real'
- // IUnknown for the facelet, and so it manages the facelet's own
- // reference count. The 'managed interface' is contained in a
- // 'interface_t' structure, which is returned when a VxInterfaceProxy
- // is QI'ed for the managed IID.
- //
- // This implements the aggregation necessary for the managed interface
- // to appear as part of the containing StdProxy -- the interface_t
- // object defers its IUnknown methods to the StdProxy, and the
- // VxInterfaceProxy's own implementation of IUnknown provides the
- // private IUnknown that is only seen by the aggregating StdProxy...
- //
- // The XXX_vxproxy functions generated by WIDL for the managed
- // interface are conceptually the methods of this interface-proxy's
- // implementation of the managed interface. They are present in the
- // vtable and so are effectively part fo this interface proxy.
- //
- // However, for method calls to be dispatched, the only requirement is
- // that the proxy eventually calls IOprcClientChannel::InvokeMethod()
- // which happens in the SendReceive() method of RpcProxyMsg for normal
- // interfaces (i.e. those handled by standard marshaling). If an
- // alternate proxy/stub class were associated with a particular
- // interface (e.g. to do custom marshaling), then it would either need
- // to call that function itself (which is why the IOrpcProxy interface
- // has the Connect() and Disconnect() methods, so it has access to the
- // channel), or it must arrange for data to be sent to the remote
- // machine itself, somehow.
- //
- class VxInterfaceProxy;
- struct interface_t
- {
- const void * lpVtbl; // inner interface impl
- long magic; // magic ID value
- VxInterfaceProxy * backptr; // validation pointer
- };
- class VxInterfaceProxy : public IOrpcProxy
- {
- interface_t m_interface; // managed interface
- IID m_iidManaged; // IID of inner interface
- IPID m_ipid; // IPID of exposed interface
- LONG m_dwRefCount; // reference count
- IUnknown * m_pUnkOuter; // aggregating outer
- IOrpcClientChannel* m_pChannel; // client channel
- VxInterfaceProxy& operator= (const VxInterfaceProxy&);
- VxInterfaceProxy::VxInterfaceProxy (const VxInterfaceProxy&);
- public:
- // ctor and dtor
- VxInterfaceProxy (REFIID, REFIPID, IUnknown*, const void*);
- virtual ~VxInterfaceProxy ();
- HRESULT interfaceInfoGet (IPID*, IOrpcClientChannel**);
- IUnknown* pUnkOuter () const { return m_pUnkOuter; }
-
- // find containing interface-proxy from any interface pointer
- static VxInterfaceProxy* safe_cast (const void*);
- // IOrpcProxy methods
- STDMETHOD(QueryInterface) (REFIID riid, void** ppv);
- STDMETHOD_(ULONG, AddRef) ();
- STDMETHOD_(ULONG, Release) ();
- STDMETHOD(Connect) (IOrpcClientChannel*);
- STDMETHOD(Disconnect) ();
- };
- #endif