LocalObject.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_DCPS_LOCALOBJECT_H
00009 #define OPENDDS_DCPS_LOCALOBJECT_H
00010 
00011 #include "tao/LocalObject.h"
00012 #include "tao/Version.h"
00013 #include "dds/DCPS/PoolAllocationBase.h"
00014 
00015 namespace OpenDDS {
00016 namespace DCPS {
00017 
00018 // support TAO-style _ptr and _var
00019 typedef CORBA::LocalObject_ptr LocalObject_ptr;
00020 typedef CORBA::LocalObject_var LocalObject_var;
00021 
00022 /// OpenDDS::DCPS::LocalObject resolves ambigously-inherited members like
00023 /// _narrow and _ptr_type.  It is used from client code like so:
00024 /// class MyReaderListener
00025 ///   : public OpenDDS::DCPS::LocalObject<OpenDDS::DCPS::DataReaderListener> {...};
00026 template <class Stub>
00027 class LocalObject
00028   : public virtual Stub
00029   , public virtual CORBA::LocalObject
00030   , public virtual PoolAllocationBase
00031 {
00032 public:
00033   typedef typename Stub::_ptr_type _ptr_type;
00034   typedef typename Stub::_var_type _var_type;
00035   static _ptr_type _narrow(CORBA::Object_ptr obj) {
00036     return Stub::_narrow(obj);
00037   }
00038 };
00039 
00040 /// OpenDDS::DCPS::LocalObject_NoRefCount is the same as LocalObject, but needs to
00041 /// be inherited from if the user wishes to allocate a "Local Object" on the stack.
00042 /// class MyReaderListener
00043 ///   : public OpenDDS::DCPS::LocalObject_NoRefCount<OpenDDS::DCPS::DataReaderListener> {...};
00044 template <class Stub>
00045 class LocalObject_NoRefCount
00046   : public virtual Stub {
00047 public:
00048   typedef typename Stub::_ptr_type _ptr_type;
00049   static _ptr_type _narrow(CORBA::Object_ptr obj) {
00050     return Stub::_narrow(obj);
00051   }
00052 
00053   // we want to keep refcounting from happening
00054   virtual void _add_ref() {}
00055   virtual void _remove_ref() {}
00056 };
00057 
00058 } // namespace DCPS
00059 } // namespace OpenDDS
00060 
00061 #endif /* OPENDDS_DCPS_LOCALOBJECT_H */

Generated on Fri Feb 12 20:05:23 2016 for OpenDDS by  doxygen 1.4.7