summaryrefslogtreecommitdiff
path: root/stl/dbstl_inner_utility.h
diff options
context:
space:
mode:
authorZhang Qiang <qiang.z.zhang@intel.com>2012-05-29 12:22:00 +0800
committerZhang Qiang <qiang.z.zhang@intel.com>2012-05-29 12:22:00 +0800
commit02f0634ac29e19c68279e5544cac963e7f1203b8 (patch)
treeb983472f94ef063cedf866d8ecfb55939171779d /stl/dbstl_inner_utility.h
parente776056ea09ba0b6d9505ced6913c9190a12d632 (diff)
downloaddb4-master.tar.gz
db4-master.tar.bz2
db4-master.zip
Sync source code from Tizen:BaseHEAD2.0_alphamaster2.0alpha1.0_post
Diffstat (limited to 'stl/dbstl_inner_utility.h')
-rw-r--r--stl/dbstl_inner_utility.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/stl/dbstl_inner_utility.h b/stl/dbstl_inner_utility.h
new file mode 100644
index 0000000..fcf1431
--- /dev/null
+++ b/stl/dbstl_inner_utility.h
@@ -0,0 +1,59 @@
+/*-
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 2009 Oracle. All rights reserved.
+ *
+ * $Id$
+ */
+
+#ifndef _DB_STL_GLOBAL_INNER_OBJECT_
+#define _DB_STL_GLOBAL_INNER_OBJECT_
+
+#include "dbstl_common.h"
+
+START_NS(dbstl)
+/*
+ * This is the interface for all classes that has some global/singleton
+ * instances that will survive during the entire process lifetime and
+ * need to be deleted before process exit. Not deleting them won't make
+ * a difference because they have to be alive when the process is alive,
+ * they are not memory leaks. However, we will still delete them before
+ * process exit, to make no memory leak reports by memory leak checkers.
+ */
+class _exported DbstlGlobalInnerObject
+{
+public:
+ DbstlGlobalInnerObject(){}
+ virtual ~DbstlGlobalInnerObject(){}
+
+}; // DbstlGlobalInnerObject
+
+void _exported register_global_object(DbstlGlobalInnerObject *gio);
+
+// This class stores the pointer of an object allocated on heap, and when
+// an instance of this class is destructed, it deletes that object.
+// Any instance of this class can only be created on the heap so that we
+// can control when to destruct its instances. It derives from
+// DbstlGlobalInnerObject so that we can register pointers to instances of
+// this class into ResourceManager, just like other objects which implements
+// the DbstlGlobalInnerObject interface. So the ultimate purpose for this
+// template is to manage objects which can't implement DbstlGlobalInnerObject
+// interface, like objects of Db, DbEnv, etc.
+//
+template<typename T>
+class _exported DbstlHeapObject : public DbstlGlobalInnerObject
+{
+private:
+ typedef DbstlHeapObject<T> self;
+ T *obj;
+
+ // Only allow creating to heap.
+ DbstlHeapObject(T *obj1) { obj = obj1; }
+public:
+ static self *instance(T *obj1) { return new self(obj1); }
+ virtual ~DbstlHeapObject() { delete obj; }
+}; // DbstlHeapObject
+
+END_NS
+#endif // !_DB_STL_GLOBAL_INNER_OBJECT_
+