Date: Friday, January 6, 2006 @ 12:31:22
Author: marc
Path: /cvsroot/carob/odbsequoia/src
Added: abstract_item.hpp (1.1)
Modified: connect.cpp (1.4 -> 1.5) connect.hpp (1.3 -> 1.4) env.cpp (1.3
-> 1.4) env.hpp (1.2 -> 1.3) stmt.hpp (1.1 -> 1.2)
Created abstract class "ODBCItem" to share code.
-------------------+
abstract_item.hpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++
connect.cpp | 3 +--
connect.hpp | 7 +++++--
env.cpp | 3 +--
env.hpp | 6 +++++-
stmt.hpp | 9 +++++----
6 files changed, 64 insertions(+), 11 deletions(-)
Index: odbsequoia/src/abstract_item.hpp
diff -u /dev/null odbsequoia/src/abstract_item.hpp:1.1
--- /dev/null Fri Jan 6 12:31:22 2006
+++ odbsequoia/src/abstract_item.hpp Fri Jan 6 12:31:22 2006
@@ -0,0 +1,47 @@
+
+/*
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2006 Continuent, Inc.
+ * Contact: [EMAIL PROTECTED]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Initial developer(s): Marc Herbert
+ * Contributor(s):
+ */
+
+namespace ODBSeqNS {
+
+
+class ODBCItem
+{
+public:
+ ODBCItem(ODBCItem& creator) : owner(creator) { }
+protected:
+ ODBCItem& owner;
+private:
+ ODBCItem(); // forbidden
+};
+
+
+}
+
+
+
+/*
+ * Local Variables:
+ * c-file-style: "bsd"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Index: odbsequoia/src/connect.cpp
diff -u odbsequoia/src/connect.cpp:1.4 odbsequoia/src/connect.cpp:1.5
--- odbsequoia/src/connect.cpp:1.4 Thu Jan 5 21:34:11 2006
+++ odbsequoia/src/connect.cpp Fri Jan 6 12:31:22 2006
@@ -107,8 +107,7 @@
SQLRETURN
ODBCConnection::AllocStmt(SQLHANDLE * OutputHandle)
{
- ODBCStatement * newstmt = new ODBCStatement;
- newstmt->conn = this;
+ ODBCStatement * newstmt = new ODBCStatement(*this);
newstmt->carob_stmt = carob_conn->createStatement();
newstmt->state = S1;
*OutputHandle = newstmt;
Index: odbsequoia/src/connect.hpp
diff -u odbsequoia/src/connect.hpp:1.3 odbsequoia/src/connect.hpp:1.4
--- odbsequoia/src/connect.hpp:1.3 Thu Jan 5 21:34:11 2006
+++ odbsequoia/src/connect.hpp Fri Jan 6 12:31:22 2006
@@ -28,14 +28,17 @@
namespace ODBSeqNS {
-class ODBCConnection {
+class ODBCConnection : public ODBCItem
+{
public:
- ODBCEnv *env;
+ ODBCConnection(ODBCEnv& creator) : ODBCItem(creator) { } ;
CarobNS::Connection* carob_conn;
// TODO: rely on ConnectionParameters instead
std::wstring serverhost;
std::wstring vdbname;
SQLRETURN AllocStmt(SQLHANDLE * OutputHandle);
+private:
+ ODBCConnection(); // forbidden
};
Index: odbsequoia/src/env.cpp
diff -u odbsequoia/src/env.cpp:1.3 odbsequoia/src/env.cpp:1.4
--- odbsequoia/src/env.cpp:1.3 Thu Jan 5 21:34:11 2006
+++ odbsequoia/src/env.cpp Fri Jan 6 12:31:22 2006
@@ -58,8 +58,7 @@
SQLRETURN
ODBCEnv::AllocConnect(SQLHANDLE * OutputHandle)
{
- ODBCConnection *newconn = new ODBCConnection;
- newconn->env = this;
+ ODBCConnection *newconn = new ODBCConnection(*this);
*OutputHandle = newconn;
return SQL_SUCCESS;
}
Index: odbsequoia/src/env.hpp
diff -u odbsequoia/src/env.hpp:1.2 odbsequoia/src/env.hpp:1.3
--- odbsequoia/src/env.hpp:1.2 Thu Jan 5 21:34:11 2006
+++ odbsequoia/src/env.hpp Fri Jan 6 12:31:22 2006
@@ -27,10 +27,14 @@
#include <sql.h>
+#include "abstract_item.hpp"
+
namespace ODBSeqNS {
-class ODBCEnv {
+class ODBCEnv : public ODBCItem
+{
public:
+ ODBCEnv() : ODBCItem(*this) { }; // I have no father
SQLRETURN ODBCEnv::AllocConnect(SQLHANDLE * OutputHandle);
};
Index: odbsequoia/src/stmt.hpp
diff -u odbsequoia/src/stmt.hpp:1.1 odbsequoia/src/stmt.hpp:1.2
--- odbsequoia/src/stmt.hpp:1.1 Thu Jan 5 21:34:11 2006
+++ odbsequoia/src/stmt.hpp Fri Jan 6 12:31:22 2006
@@ -25,16 +25,17 @@
enum stmt_state_t { S0, S1, S4, S5 };
-class ODBCStatement
+class ODBCStatement : public ODBCItem
{
public:
- // a ref here instead?
- ODBCConnection *conn;
CarobNS::Statement* carob_stmt;
stmt_state_t state; // state according to "Statement Transitions"
// in the ODBC reference (as far as
// possible).
- ODBCStatement() { state = S0; };
+ ODBCStatement(ODBCConnection& creator) : ODBCItem(creator)
+ { state = S0; };
+private:
+ ODBCStatement(); // forbidden
};
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits