summaryrefslogtreecommitdiff
path: root/TAO/tao
diff options
context:
space:
mode:
authordai_y <dai_y@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-12-06 02:02:35 +0000
committerdai_y <dai_y@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-12-06 02:02:35 +0000
commit027b8b09c9a1c59a1f2e0f048d607d12b9dd034e (patch)
tree021ca242561491addb761c7b0e575528ff099daa /TAO/tao
parent6e53bd8a1bf3c835b5c016884b52bf60d453a23a (diff)
downloadATCD-027b8b09c9a1c59a1f2e0f048d607d12b9dd034e.tar.gz
Sun Dec 6 02:01:17 UTC 2009 Yan Dai <dai_y@ociweb.com>
Diffstat (limited to 'TAO/tao')
-rw-r--r--TAO/tao/Intrusive_Ref_Count_Object_T.cpp22
-rw-r--r--TAO/tao/Intrusive_Ref_Count_Object_T.h76
-rw-r--r--TAO/tao/Intrusive_Ref_Count_Object_T.inl26
3 files changed, 124 insertions, 0 deletions
diff --git a/TAO/tao/Intrusive_Ref_Count_Object_T.cpp b/TAO/tao/Intrusive_Ref_Count_Object_T.cpp
new file mode 100644
index 00000000000..d5789743340
--- /dev/null
+++ b/TAO/tao/Intrusive_Ref_Count_Object_T.cpp
@@ -0,0 +1,22 @@
+// $Id$
+
+#ifndef TAO_INTRUSIVE_REF_COUNT_OBJECT_T_CPP
+#define TAO_INTRUSIVE_REF_COUNT_OBJECT_T_CPP
+
+#include "tao/Intrusive_Ref_Count_Object_T.h"
+
+#if !defined (__ACE_INLINE__)
+#include "tao/Intrusive_Ref_Count_Object_T.inl"
+#endif /* __ACE_INLINE__ */
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <typename OBJ, typename ACE_Lock>
+TAO_Intrusive_Ref_Count_Object<OBJ,ACE_Lock>::~TAO_Intrusive_Ref_Count_Object()
+{
+ delete this->obj_;
+}
+
+TAO_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* TAO_INTRUSIVE_REF_COUNT_OBJECT_T_CPP */
diff --git a/TAO/tao/Intrusive_Ref_Count_Object_T.h b/TAO/tao/Intrusive_Ref_Count_Object_T.h
new file mode 100644
index 00000000000..b4c0c44bfe4
--- /dev/null
+++ b/TAO/tao/Intrusive_Ref_Count_Object_T.h
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Intrusive_Ref_Count_Object_T.h
+ *
+ * $Id$
+ *
+ * @authors Yan Dai <dai_y@ociweb.com>
+ */
+//=============================================================================
+
+#ifndef TAO_INTRUSIVE_REF_COUNT_OBJECT_T_H
+#define TAO_INTRUSIVE_REF_COUNT_OBJECT_T_H
+
+#include /**/ "ace/pre.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include /**/ "tao/Versioned_Namespace.h"
+#include /**/ "tao/Intrusive_Ref_Count_Base_T.h"
+
+#include "ace/Atomic_Op.h"
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class TAO_Intrusive_Ref_Count_Object<ACE_LOCK>
+ *
+ * @brief Template class as wrapper of a non reference counted data type but provide
+ * intrusive reference-counting feature by inherited from TAO_Intrusive_Ref_Count_Base.
+ * This makes the parameterized type data be smart pointer by using a
+ * TAO_Intrusive_Ref_Count_Handle<X> to an this wrapper object.
+ */
+template <class OBJ, class ACE_LOCK>
+class TAO_Intrusive_Ref_Count_Object : public TAO_Intrusive_Ref_Count_Base <ACE_LOCK>
+{
+public:
+
+ /// take ownership of obj.
+ TAO_Intrusive_Ref_Count_Object (OBJ* obj);
+ virtual ~TAO_Intrusive_Ref_Count_Object (void);
+
+ OBJ* get () const;
+
+private:
+
+ // Prevent default constructor used.
+ TAO_Intrusive_Ref_Count_Object (void);
+
+ // Prevent copying/assignment.
+ TAO_Intrusive_Ref_Count_Object (const TAO_Intrusive_Ref_Count_Object&);
+ TAO_Intrusive_Ref_Count_Object& operator= (const TAO_Intrusive_Ref_Count_Object&);
+
+ OBJ* obj_;
+};
+
+TAO_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (__ACE_INLINE__)
+#include "tao/Intrusive_Ref_Count_Object_T.inl"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
+#include "tao/Intrusive_Ref_Count_Object_T.cpp"
+#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
+
+#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
+#pragma implementation ("Intrusive_Ref_Count_Object_T.cpp")
+#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
+
+#include /**/ "ace/post.h"
+
+#endif /* TAO_INTRUSIVE_REF_COUNT_OBJECT_T_H */
diff --git a/TAO/tao/Intrusive_Ref_Count_Object_T.inl b/TAO/tao/Intrusive_Ref_Count_Object_T.inl
new file mode 100644
index 00000000000..64c04a5772a
--- /dev/null
+++ b/TAO/tao/Intrusive_Ref_Count_Object_T.inl
@@ -0,0 +1,26 @@
+// -*- C++ -*-
+//
+// $Id$
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template <typename OBJ, typename ACE_LOCK>
+ACE_INLINE
+TAO_Intrusive_Ref_Count_Object<OBJ,ACE_LOCK>::TAO_Intrusive_Ref_Count_Object (void)
+{}
+
+template <typename OBJ, typename ACE_LOCK>
+ACE_INLINE
+TAO_Intrusive_Ref_Count_Object<OBJ,ACE_LOCK>::TAO_Intrusive_Ref_Count_Object (OBJ* obj)
+: obj_ (obj)
+{}
+
+
+template <typename OBJ, typename ACE_LOCK>
+ACE_INLINE OBJ*
+TAO_Intrusive_Ref_Count_Object<OBJ,ACE_LOCK>::get () const
+{
+ return this->obj_;
+}
+
+TAO_END_VERSIONED_NAMESPACE_DECL