summaryrefslogtreecommitdiff
path: root/cpp/src/Freeze/MapDb.h
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-12-12 12:03:04 -0500
committerBernard Normier <bernard@zeroc.com>2007-12-12 12:03:04 -0500
commit28c22de9b812daeffa630656818da6ec5411a7da (patch)
treea3b5142c2144ead6aafb62dd71baf0657296e014 /cpp/src/Freeze/MapDb.h
parentFixed bug #2546 (diff)
downloadice-28c22de9b812daeffa630656818da6ec5411a7da.tar.bz2
ice-28c22de9b812daeffa630656818da6ec5411a7da.tar.xz
ice-28c22de9b812daeffa630656818da6ec5411a7da.zip
Fixed bug #2557 (closing database within transaction)
Diffstat (limited to 'cpp/src/Freeze/MapDb.h')
-rw-r--r--cpp/src/Freeze/MapDb.h123
1 files changed, 123 insertions, 0 deletions
diff --git a/cpp/src/Freeze/MapDb.h b/cpp/src/Freeze/MapDb.h
new file mode 100644
index 00000000000..cf4355385bc
--- /dev/null
+++ b/cpp/src/Freeze/MapDb.h
@@ -0,0 +1,123 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef FREEZE_MAP_DB_H
+#define FREEZE_MAP_DB_H
+
+#include <IceUtil/Config.h>
+#include <db_cxx.h>
+#include <Freeze/ConnectionI.h>
+#include <Freeze/Map.h>
+
+
+namespace Freeze
+{
+
+class SharedDbEnv;
+class MapDb;
+
+class MapIndexI
+{
+public:
+
+ MapIndexI(const ConnectionIPtr&, MapDb&,
+ DbTxn*, bool, const MapIndexBasePtr&);
+
+ ~MapIndexI();
+
+ IteratorHelper* begin(bool, const MapHelperI&) const;
+ IteratorHelper* untypedFind(const Key&, bool, const MapHelperI&, bool) const;
+ IteratorHelper* untypedLowerBound(const Key&, bool, const MapHelperI&) const;
+ IteratorHelper* untypedUpperBound(const Key&, bool, const MapHelperI&) const;
+
+ int untypedCount(const Key&, const ConnectionIPtr&) const;
+
+ int secondaryKeyCreate(Db*, const Dbt*, const Dbt*, Dbt*);
+
+ const std::string& name() const
+ {
+ return _index->name();
+ }
+
+ Db* db() const
+ {
+ return _db.get();
+ }
+
+ const MapIndexBasePtr& getKeyCompare() const
+ {
+ return _index;
+ }
+
+private:
+
+ const MapIndexBasePtr _index;
+ std::auto_ptr<Db> _db;
+ std::string _dbName;
+};
+
+
+//
+// A MapDb represents the Db object underneath Freeze Maps. Several Freeze Maps often
+// share the very same MapDb object; SharedDbEnv manages these shared MapDb objects.
+//
+
+class MapDb : public ::Db
+{
+public:
+
+ MapDb(const ConnectionIPtr&, const std::string&,
+ const std::string&, const std::string&,
+ const KeyCompareBasePtr&, const std::vector<MapIndexBasePtr>&, bool);
+
+
+ //
+ // The constructor for catalogs
+ //
+ MapDb(const Ice::CommunicatorPtr&, const std::string&, const std::string&, const std::string&, DbEnv*);
+
+ ~MapDb();
+
+ void connectIndices(const std::vector<MapIndexBasePtr>&) const;
+ void clearIndices();
+
+ void checkTypes(const std::string&, const std::string&) const;
+
+ const std::string& dbName() const;
+
+ const KeyCompareBasePtr& getKeyCompare() const;
+
+ typedef std::map<std::string, MapIndexI*> IndexMap;
+
+private:
+
+ const Ice::CommunicatorPtr _communicator;
+ const std::string _dbName;
+ std::string _key;
+ std::string _value;
+ const int _trace;
+
+ KeyCompareBasePtr _keyCompare;
+ IndexMap _indices;
+};
+
+inline const std::string&
+MapDb::dbName() const
+{
+ return _dbName;
+}
+
+inline const Freeze::KeyCompareBasePtr&
+MapDb::getKeyCompare() const
+{
+ return _keyCompare;
+}
+
+}
+#endif