Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

cxx_proxy.h

00001 #ifndef __UPF_CXX_PROXY_H__
00002 #define __UPF_CXX_PROXY_H__
00003 
00004 #include <assert.h>
00005 
00006 namespace upf {
00007 
00008 template<class T> class _ProxyBase : public T
00009 {
00010 public:
00011     virtual upf_Object* _upf_getABIObject() { return m_object; }
00012 
00013 protected:
00014     enum
00015     {
00016         // NB: keep this in sync with code generate from upf.IObject definition
00017         //     in core.idl !
00018         METHOD_INCREF = 0,
00019         METHOD_DECREF = 1,
00020         METHOD_QUERYINTERFACE = 2
00021     };
00022     
00023     _ProxyBase() : m_refCnt(0), m_object(NULL) { m_dispatch.function = NULL; }
00024 
00025     void init_proxy(upf_Object *object, const upf_InterfaceData& dispatch) 
00026     {
00027         m_object = object;
00028         m_dispatch = dispatch;
00029         assert(object != NULL);
00030         assert(object->queryInterface != NULL);
00031         assert(dispatch.data != NULL);
00032         _real_incRef();
00033     }
00034 
00035     virtual ~_ProxyBase()
00036     {
00037         assert(m_object != NULL);
00038         _real_decRef();
00039     }
00040 
00041     void _real_incRef()
00042     {
00043         ArgumentsOwned _upf_args;
00044         m_dispatch.function(m_dispatch.data, METHOD_INCREF, _upf_args.getMarchalled());
00045     }
00046     
00047     void _real_decRef()
00048     {
00049         ArgumentsOwned _upf_args;
00050         m_dispatch.function(m_dispatch.data, METHOD_DECREF, _upf_args.getMarchalled());
00051     }
00052     
00053     InterfacePtr _real_queryInterface(const IID& interface_id)
00054     {
00055         ArgumentsOwned _upf_args;
00056         _upf_args << interface_id;
00057         m_dispatch.function(m_dispatch.data, METHOD_QUERYINTERFACE, _upf_args.getMarchalled());
00058         ::upf::InterfacePtr _upf_retval;
00059         _upf_args >> _upf_retval;
00060         return _upf_retval;
00061     }
00062 
00063     InterfacePtr _proxy_queryInterface(const IID& iid)
00064     {
00065         return _real_queryInterface(iid);
00066     }
00067 
00068     void _proxy_incRef()
00069         { m_refCnt++; }
00070 
00071     void _proxy_decRef()
00072         { if (--m_refCnt == 0) delete this; }
00073 
00074     int                m_refCnt;
00075     upf_Object        *m_object;
00076     upf_InterfaceData  m_dispatch;
00077 };
00078 
00079 }
00080 
00081 #endif

Generated on Wed Jan 15 23:10:55 2003 for Universal Plugins Framework by doxygen1.2.18