You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ad...@apache.org on 2007/05/11 23:36:57 UTC
svn commit: r537297 [8/10] - in /incubator/tuscany/cpp/das:
VSExpress/tuscany_das/ VSExpress/tuscany_das/das_lite/
VSExpress/tuscany_das/das_runtime/ das_java_classes/
das_java_classes/config/ runtime/core/include/ runtime/core/include/apache/
runtime/...
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/RefCountingObject.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/RefCountingObject.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/RefCountingObject.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/RefCountingObject.h Fri May 11 14:36:45 2007
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+#ifndef REF_COUNTING_OBJECT_H
+#define REF_COUNTING_OBJECT_H
+
+#include <iostream>
+#include <list>
+
+#include "apache/das/RefCountingPointer.h"
+
+namespace apache {
+ namespace das {
+
+/**
+ * RefcountingObject is the base class for all objects in SDO
+ * These objects keep a count of references to themselves, then
+ * free themselves when they are unused.
+ */
+template <class T>
+ class RefCountingObject
+ {
+
+ public:
+ RefCountingObject();
+ RefCountingObject(const RefCountingObject<T>& rc);
+ T& operator=(const T& rc);
+ virtual ~RefCountingObject();
+/**
+ * Add to the reference count - a new pointer has been created.
+ */
+ void addRef(RefCountingPointer<T>* refPtr);
+/**
+ * Subtract from the the reference count - a reference has dropped.
+ */
+ virtual void releaseRef(RefCountingPointer<T>* refPtr);
+
+/**
+ * Print contents to stream
+ */
+ virtual std::ostream& printSelf(std::ostream &os);
+
+ protected:
+ virtual void free(void);
+
+ private:
+ bool freed;
+ unsigned int refCount;
+ std::list<RefCountingPointer<T>*>* refPtrs;
+
+ };
+
+ };
+};
+
+
+#endif //REF_COUNTING_OBJECT_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/RefCountingPointer.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/RefCountingPointer.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/RefCountingPointer.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/RefCountingPointer.h Fri May 11 14:36:45 2007
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+#ifndef REF_COUNTING_POINTER_H
+#define REF_COUNTING_POINTER_H
+
+#include <iostream>
+
+#include "apache/das/NullPointerException.h"
+
+namespace apache {
+ namespace das {
+
+ template <class T>
+class RefCountingPointer {
+
+ public:
+ /*SDO_API*/ RefCountingPointer(T* realPtr = 0, bool objectOwner = true);
+ RefCountingPointer(const RefCountingPointer<T>& rhs, bool objectOwner = true);
+ /*SDO_API*/ RefCountingPointer(T& rhs, bool objectOwner = true);
+ /*SDO_API*/ virtual ~RefCountingPointer(void);
+ /*SDO_API*/ RefCountingPointer& operator=(const RefCountingPointer<T>& rhs);
+
+ /*SDO_API*/ bool operator==(RefCountingPointer<T>& test) const;
+ /*SDO_API*/ T* operator->() const;
+ /*SDO_API*/ T& operator*() const;
+ /*SDO_API*/ bool operator!() const;
+ bool isObjectOwner(void) const;
+
+#ifdef MFT
+ // MFT == member function templates
+ // Notes on the items below.
+ // In our code, we use subclasses to expose the API, and super
+ // classes to implement. E,g DataObject and DataObjectImpl.
+ // In some cases, we know that the DataObject given to us is a
+ // DataObjectImpl, and cast it. With RefCountingPointers, however,
+ // the cast cannot work, as the RefCountingPointer to the superclass
+ // is not related to the RCP to the subclass. Recent changes in the
+ // C++ language allow this to work by defining an operator which
+ // causes a pointer of the other type to be returned, as long as pointee
+ // is acceptable as a parameter to the cosntructor of the other type
+ // of pointer. This works in C++.NET, but not in C++6:
+ operator RefCountingPointer<otherType>()
+ {
+ return RefCountingPointer<otherType>(pointee);
+ }
+
+ // Since we are using C6, a possible workround is to provide a method
+ // which returns the dumb pointer, then construct a pointer to the
+ // base class from the pointer returned. This is that the operator T* does.
+ // The code in DataObject could be simpler if we used C7,and we should
+ // discusss changing.
+#else
+ operator T*() {return pointee;}
+#endif
+
+ template <class otherType>
+ operator RefCountingPointer<otherType>()
+ {
+ return RefCountingPointer<otherType>(pointee);
+ }
+
+ friend std::ostream& operator<< (std::ostream &os, const RefCountingPointer<T>& ptr)
+ {
+ if (!ptr)
+ {
+ os << "NULL" << std::endl;
+ }
+ else
+ {
+ ptr->printSelf(os);
+ }
+
+ return os;
+ }
+
+ private:
+ T *pointee;
+ bool objectOwner;
+ void init();
+
+};
+
+ };
+};
+
+#endif //REF_COUNTING_POINTER_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Column.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Column.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Column.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Column.h Fri May 11 14:36:45 2007
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef COLUMN_H
+#define COLUMN_H
+
+#include <windows.h>
+#include <sql.h>
+#include <sqlext.h>
+#include <string>
+#include <list>
+
+#include "apache/das/rdb/Table.h"
+#include "apache/das/rdb/das_constants.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class Table;
+class KeyPair;
+
+class Column {
+
+ friend class Table;
+
+ private:
+ bool pk;
+ std::string columnName;
+ std::string mappedName;
+ SQLSMALLINT sqlType;
+ Table* containerTable;
+ std::list<KeyPair*>* keyPairs;
+
+ void setContainerTable(Table* containerTable);
+
+ public:
+ Column(std::string columnName, SQLSMALLINT sqlType);
+ virtual ~Column(void);
+
+ void setReferencedTableAndColumn(std::string referencedTableName, std::string referencedColumnName);
+ void setPK(bool pk);
+ void setMappedName(std::string mappedName);
+ void addKeyPair(KeyPair& keyPair);
+
+ std::string getMappedName(void) const;
+ bool isFK(void) const;
+ std::string getReferencedTableName(void) const;
+ std::string getReferencedColumnName(void) const;
+ bool isPK(void) const;
+ SQLSMALLINT getSQLType(void) const;
+ Table* getContainerTable(void) const;
+ std::list<KeyPair*>& getKeyPairs(void) const;
+ std::string getName(void) const;
+
+};
+
+ };
+ };
+};
+
+#endif //COLUMN_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ColumnData.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ColumnData.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ColumnData.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ColumnData.h Fri May 11 14:36:45 2007
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef COLUMN_DATA_H
+#define COLUMN_DATA_H
+
+#include <windows.h>
+#include <sql.h>
+#include <sqlext.h>
+#include <string>
+
+#include "apache/das/rdb/Column.h"
+#include "apache/das/rdb/TableData.h"
+
+#include "commonj/sdo/DataObject.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class TableData;
+
+class ColumnData {
+
+ private:
+ Column* column;
+ void* data;
+
+ public:
+ ColumnData(Column& column, ResultSetPtr resultSet);
+ virtual ~ColumnData(void);
+
+ bool operator==(ColumnData& columnData) const;
+ bool operator!=(ColumnData& columnData) const;
+ bool operator<(ColumnData& columnData) const;
+ bool operator>(ColumnData& columnData) const;
+ Column& getColumn(void) const;
+
+ void populateDataGraph(TableData& tableData) const;
+
+};
+
+ };
+ };
+};
+
+#endif //COLUMN_DATA_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/CommandImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/CommandImpl.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/CommandImpl.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/CommandImpl.h Fri May 11 14:36:45 2007
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef COMMAND_IMPL_H
+#define COMMAND_IMPL_H
+
+#include <string>
+
+#include "apache/das/Command.h"
+#include "apache/das/rdb/Connection.h"
+
+#include "commonj/sdo/DataObject.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class DASImpl;
+
+class CommandImpl : public Command {
+
+ protected:
+ DASImpl* das;
+ std::string sql;
+ StatementPtr statement;
+
+ public:
+ CommandImpl(DASImpl& das, std::string sqlString);
+ virtual ~CommandImpl(void);
+ virtual commonj::sdo::DataObjectPtr executeQuery(void) = 0;
+ virtual DASImpl& getDAS(void);
+ virtual void close(void);
+
+};
+
+ };
+ };
+};
+
+#endif //COMMAND_IMPL_H
+
+
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Config.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Config.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Config.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Config.h Fri May 11 14:36:45 2007
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include <list>
+#include <map>
+
+#include "apache/das/DAS.h"
+#include "apache/das/rdb/Table.h"
+#include "apache/das/rdb/Column.h"
+#include "apache/das/rdb/Relationship.h"
+#include "apache/das/rdb/RelationshipWrapper.h"
+
+class Column;
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class Table;
+
+class Config {
+
+ private:
+ std::map<std::string, Relationship*>* relationships;
+ std::map<std::string, Table*>* tables;
+ DAS* das;
+ bool convOverConfig;
+
+ public:
+ Config(DAS& das);
+ virtual ~Config(void);
+
+ void addTable(Table& table);
+ void addRelationship(Relationship& relationship);
+
+ std::map<std::string, Relationship*>& getRelationships(void) const;
+ std::map<std::string, Table*>& getTables(void) const;
+
+ DAS& getDAS(void) const;
+ bool isConvOverConfig(void) const;
+
+ void loadConvOverConfigFKs(std::list<Column*>& columns);
+ Table* getTable(std::string tableName) const;
+ Relationship* getRelationship(std::string tableName, std::string referencedTableName) const;
+
+};
+
+ };
+ };
+};
+
+#endif //CONFIG_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Connection.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Connection.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Connection.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Connection.h Fri May 11 14:36:45 2007
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef CONNECTION_H
+#define CONNECTION_H
+
+#include <windows.h>
+#include <sql.h>
+#include <sqlext.h>
+
+#include <string>
+#include <list>
+#include <iostream>
+#include <algorithm>
+
+#include "apache/das/rdb/StatementPtr.h"
+#include "apache/das/rdb/Database.h"
+#include "apache/das/rdb/SqlException.h"
+
+using std::string;
+using std::exception;
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class Database;
+
+class Connection {
+
+ private:
+ SQLHDBC connection;
+ SQLHENV environment;
+ Database* database;
+ std::list<StatementPtr*> statements;
+
+ public:
+ Connection(string dns, string user, string password) throw (SqlException);
+ virtual ~Connection(void);
+ SQLHDBC getODBCConnection(void) const;
+ void commit(void);
+ void rollback(void);
+ void setAutoCommit(bool autoCommit);
+ Database& getDatabase(void) const;
+ StatementPtr createStatement(void) throw (exception);
+ //PreparedStatement& prepareStatement(string sql);
+
+};
+
+ };
+ };
+};
+
+#endif //CONNECTION_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/DASFactoryImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/DASFactoryImpl.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/DASFactoryImpl.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/DASFactoryImpl.h Fri May 11 14:36:45 2007
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef D_A_S_FACTORY_IMPL_H
+#define D_A_S_FACTORY_IMPL_H
+
+#include <windows.h>
+#include <sql.h>
+#include <sqlext.h>
+
+#include "apache/das/DAS.h"
+#include "apache/das/rdb/DASImpl.h"
+#include "apache/das/DASFactory.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class DASFactoryImpl : public DASFactory {
+
+ public:
+ DASFactoryImpl(void);
+ virtual ~DASFactoryImpl(void);
+ DAS* createDAS(Connection& connection);
+
+};
+
+ };
+ };
+};
+
+#endif //D_A_S_FACTORY_IMPL_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/DASImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/DASImpl.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/DASImpl.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/DASImpl.h Fri May 11 14:36:45 2007
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef D_A_S_IMPL_H
+#define D_A_S_IMPL_H
+
+#include <windows.h>
+#include <sql.h>
+#include <map>
+#include <string>
+#include <cctype>
+#include <list>
+
+#include "apache/das/DAS.h"
+#include "apache/das/rdb/Connection.h"
+#include "apache/das/rdb/Config.h"
+#include "apache/das/rdb/ReadCommandImpl.h"
+
+#include "commonj/sdo/DataFactory.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class Config;
+class CommandImpl;
+class ReadCommandImpl;
+
+class DASImpl : public DAS {
+
+ private:
+ Connection* connection;
+ std::list<Command*>* createdCommands;
+ Config* config;
+
+ Command& baseCreateCommand(std::string inSql);
+
+ public:
+ DASImpl(Connection& inConnection);
+ virtual ~DASImpl(void);
+ Connection* getConnection(void);
+ Config& getConfig(void) const;
+ void setConnection(Connection* aConnection);
+ void releaseResources(void);
+ Command& createCommand(std::string sql);
+ void closeConnection(void);
+
+};
+
+ };
+ };
+};
+
+#endif //D_A_S_IMPL_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Database.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Database.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Database.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Database.h Fri May 11 14:36:45 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef DATABASE_H
+#define DATABASE_H
+
+#include <windows.h>
+#include <sql.h>
+#include <sqlext.h>
+#include <string>
+
+#include "apache/das/rdb/ResultSetPtr.h"
+#include "apache/das/rdb/Statement.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class ResultSet;
+class Connection;
+
+class Database {
+
+ private:
+ Connection* connection;
+
+ public:
+ Database(Connection& connection);
+ virtual ~Database(void);
+
+ ResultSetPtr getPKs(std::string tableName) const;
+ ResultSetPtr getFKs(std::string tableName) const;
+
+};
+
+ };
+ };
+};
+
+#endif //DATABASE_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/GraphBuilder.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/GraphBuilder.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/GraphBuilder.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/GraphBuilder.h Fri May 11 14:36:45 2007
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef GRAPH_BUILDER_H
+#define GRAPH_BUILDER_H
+
+#include "apache/das/rdb/ResultSet.h"
+#include "apache/das/rdb/Config.h"
+#include "apache/das/rdb/TableData.h"
+#include "apache/das/rdb/das_constants.h"
+#include "apache/das/rdb/GraphBuilderMetaData.h"
+
+#include "commonj/sdo/DataFactory.h"
+#include "commonj/sdo/DataObject.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class TableData;
+class GraphBuilderMetaData;
+
+class GraphBuilder {
+ private:
+ ResultSet* resultSet;
+ GraphBuilderMetaData* graphBuilderMetaData;
+ commonj::sdo::DataObjectPtr root;
+ std::map<std::string, std::list<TableData*>*> tablesData;
+
+ public:
+ GraphBuilder(Config& config, ResultSetPtr resultSet);
+ virtual ~GraphBuilder(void);
+
+ commonj::sdo::DataObjectPtr getRoot(void) const;
+
+
+};
+
+ };
+ };
+};
+
+#endif //GRAPH_BUILDER_META_DATA_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/GraphBuilderMetaData.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/GraphBuilderMetaData.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/GraphBuilderMetaData.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/GraphBuilderMetaData.h Fri May 11 14:36:45 2007
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef GRAPH_BUILDER_META_DATA_H
+#define GRAPH_BUILDER_META_DATA_H
+
+#include <string>
+#include <map>
+#include <list>
+
+#include "apache/das/rdb/ResultSet.h"
+#include "apache/das/rdb/Table.h"
+#include "apache/das/rdb/Config.h"
+#include "apache/das/rdb/Relationship.h"
+#include "apache/das/rdb/KeyPair.h"
+#include "apache/das/rdb/ResultSetMetaData.h"
+#include "apache/das/rdb/das_constants.h"
+
+#include "commonj/sdo/DataFactory.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class Config;
+
+class GraphBuilderMetaData {
+
+ private:
+ ResultSetMetaData* resultSetMetaData;
+ std::map<std::string, Table*>* graphTables;
+ std::list<Relationship*>* relationships;
+ Config* config;
+
+ public:
+ GraphBuilderMetaData(Config& config, ResultSetMetaData& resultSet);
+ virtual ~GraphBuilderMetaData(void);
+
+ ResultSetMetaData& getResultSetMetaData(void) const;
+ std::map<std::string, Table*>& getTables(void) const;
+ Config& getConfig(void) const;
+ Table* getTable(std::string tableName) const;
+ std::list<Relationship*>& getRelationships(void) const;
+ commonj::sdo::DataFactoryPtr createGraph(void) const;
+
+};
+
+ };
+ };
+};
+
+#endif //GRAPH_BUILDER_META_DATA_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/KeyPair.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/KeyPair.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/KeyPair.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/KeyPair.h Fri May 11 14:36:45 2007
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef KEY_PAIR_H
+#define KEY_PAIR_H
+
+#include <map>
+#include <string>
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class Relationship;
+
+class KeyPair {
+
+ friend class Relationship;
+
+ private:
+ std::string pkColumnName;
+ std::string fkColumnName;
+ Relationship* relationship;
+
+ void setRelationship(Relationship* relationship);
+
+ public:
+ KeyPair(std::string pkColumnName, std::string fkColumnName);
+ virtual ~KeyPair(void);
+
+ std::string getPKColumnName(void) const;
+ std::string getFKColumnName(void) const;
+ Relationship* getRelationship(void) const;
+
+};
+
+ };
+ };
+};
+
+#endif //KEY_PAIR_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ODBCTypeHelper.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ODBCTypeHelper.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ODBCTypeHelper.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ODBCTypeHelper.h Fri May 11 14:36:45 2007
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef ODBC_TYPE_HELPER_H
+#define ODBC_TYPE_HELPER_H
+
+#include <windows.h>
+#include <sql.h>
+#include <string>
+
+#include "commonj/sdo/Type.h"
+
+#include "apache/das/rdb/das_constants.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class ODBCTypeHelper {
+
+ public:
+ static const std::string getSDOType(SQLSMALLINT sqlType);
+
+};
+
+ };
+ };
+};
+
+#endif //ODBC_TYPE_HELPER_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/PreparedStatement.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/PreparedStatement.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/PreparedStatement.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/PreparedStatement.h Fri May 11 14:36:45 2007
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+#ifndef PREPARED_STATEMENT_H
+#define PREPARED_STATEMENT_H
+
+#include<vector>
+
+#include "apache/das/rdb/Statement.h"
+
+using std::vector;
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class PreparedStatement : Statement {
+
+ private:
+ string sql;
+ vector<int> positions;
+
+ public:
+ PreparedStatement(Connection& connection, SQLHSTMT statementHandle, string sql);
+ ~PreparedStatement(void);
+
+ void setInt(int index, int elem);
+
+};
+
+ };
+ };
+};
+
+#endif //PREPARED_STATEMENT_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ReadCommandImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ReadCommandImpl.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ReadCommandImpl.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ReadCommandImpl.h Fri May 11 14:36:45 2007
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef READ_COMMAND_IMPL_H
+#define READ_COMMAND_IMPL_H
+
+#include <list>
+
+#include "apache/das/rdb/GraphBuilder.h"
+#include "apache/das/rdb/CommandImpl.h"
+#include "apache/das/rdb/das_constants.h"
+
+#include "commonj/sdo/DataFactory.h"
+#include "commonj/sdo/DataObject.h"
+#include "commonj/sdo/ChangeSummary.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class ReadCommandImpl : public CommandImpl {
+
+ private:
+ unsigned int startRow;
+ unsigned int endRow;
+
+ public:
+ commonj::sdo::DataObjectPtr buildGraph(ResultSetPtr resultSet); /*throws SQLException*/
+
+
+ ReadCommandImpl(DASImpl& das, std::string sqlString);
+ ~ReadCommandImpl(void);
+ commonj::sdo::DataObjectPtr executeQuery(void);
+
+};
+
+ };
+ };
+};
+
+#endif //READ_COMMAND_IMPL_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Relationship.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Relationship.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Relationship.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Relationship.h Fri May 11 14:36:45 2007
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef RELATIONSHIP_H
+#define RELATIONSHIP_H
+
+#include <string>
+#include <map>
+
+#include "apache/das/rdb/KeyPair.h"
+#include "apache/das/rdb/Config.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class Relationship {
+
+ friend class Config;
+
+ private:
+ std::string relationshipName;
+ std::string pkTableName;
+ std::string fkTableName;
+ std::map<std::string, KeyPair*>* keyPairs;
+ Config* config;
+
+ void setConfig(Config* config);
+
+ public:
+ Relationship(std::string pkTableName, std::string fkTableName);
+ Relationship(std::string pkTableName, std::string fkTableName, std::string relationshipName);
+ virtual ~Relationship(void);
+
+ void addKeyPair(KeyPair& keyPair);
+
+ std::string getPKTableName(void) const;
+ std::string getFKTableName(void) const;
+ std::string getName(void) const;
+
+ std::map<std::string, KeyPair*>& getKeyPairs(void) const;
+ KeyPair* getKeyPair(std::string pkColumnName, std::string fkColumnName) const;
+ std::list<KeyPair*>* getKeyPair(std::string columnName, bool pkColumn = true) const;
+ bool containsColumn(std::string columnName, bool pkColumn = true) const;
+
+};
+
+ };
+ };
+};
+
+#endif //RELATIONSHIP_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/RelationshipWrapper.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/RelationshipWrapper.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/RelationshipWrapper.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/RelationshipWrapper.h Fri May 11 14:36:45 2007
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef RELATIONSHIP_WRAPPER_H
+#define RELATIONSHIP_WRAPPER_H
+
+#include <string>
+#include <map>
+#include <list>
+
+#include "apache/das/rdb/Relationship.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class RelationshipWrapper {
+
+ public:
+ static std::list<Relationship*>* getRelationshipsByTableName(const std::map<std::string,
+ Relationship*>& relationships, std::string tableName,
+ bool pkTable = true);
+
+ static std::list<Relationship*>* getRelationshipsByTableName(const std::list<
+ Relationship*>& relationships, std::string tableName,
+ bool pkTable = true);
+
+};
+
+ };
+ };
+};
+
+#endif //RELATIONSHIP_WRAPPER_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSet.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSet.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSet.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSet.h Fri May 11 14:36:45 2007
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef RESULT_SET_H
+#define RESULT_SET_H
+
+#include <windows.h>
+#include <sql.h>
+#include <sqlext.h>
+#include <string>
+
+#include "apache/das/rdb/StatementPtr.h"
+#include "apache/das/RefCountingObject.h"
+#include "apache/das/rdb/ResultSetMetaData.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class Statement;
+class ResultSetMetaData;
+class ResultSet;
+
+typedef RefCountingObject<ResultSet> ResultSetObject;
+
+class ResultSet : public ResultSetObject {
+
+ private:
+ ResultSetMetaData* metaData;
+ StatementPtr stmt;
+
+ public:
+ ResultSet(StatementPtr aStmt);
+ virtual ~ResultSet(void);
+
+ ResultSetMetaData& getResultSetMetaData(void) const;
+ StatementPtr getStatement(void) const;
+
+ wchar_t getSQLChar(unsigned int columnIndex) const;
+ wchar_t getSQLChar(std::string tableName, std::string columnName) const;
+
+ std::string getSQLVarchar(unsigned int columnIndex) const;
+ std::string getSQLVarchar(std::string tableName, std::string columnName) const;
+
+ float getSQLReal(unsigned int columnIndex) const;
+ float getSQLReal(std::string tableName, std::string columnName) const;
+
+ double getSQLFloat(unsigned int columnIndex) const;
+ double getSQLFloat(std::string tableName, std::string columnName) const;
+
+ double getSQLDouble(unsigned int columnIndex) const;
+ double getSQLDouble(std::string tableName, std::string columnName) const;
+
+ std::string getSQLDecimal(unsigned int columnIndex) const;
+ std::string getSQLDecimal(std::string tableName, std::string columnName) const;
+
+ long getSQLInteger(unsigned int columnIndex) const;
+ long getSQLInteger(std::string tableName, std::string columnName) const;
+
+ bool isNull(unsigned int columnIndex) const;
+ bool isNull(std::string tableName, std::string columnName) const;
+
+ unsigned int rowCount(void) const;
+
+ bool next(void);
+
+};
+
+ };
+ };
+};
+
+#endif //RESULT_SET_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSetMetaData.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSetMetaData.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSetMetaData.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSetMetaData.h Fri May 11 14:36:45 2007
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef RESULT_SET_META_DATA_H
+#define RESULT_SET_META_DATA_H
+
+#include <string>
+#include <map>
+
+#include "apache/das/rdb/Statement.h"
+#include "apache/das/rdb/ResultSet.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class ResultSet;
+
+class ResultSetMetaData {
+
+ private:
+ ResultSet* resultSet;
+ std::map<std::string, unsigned int> columnsIndexes;
+
+ static SQLSMALLINT getSQLCType(SQLSMALLINT sqlType);
+
+ public:
+ ResultSetMetaData(ResultSet* aResultSet);
+ virtual ~ResultSetMetaData(void);
+
+ const ResultSet& getResultSet(void) const;
+
+ std::string getSQLTypeName(unsigned int columnIndex) const;
+ std::string getSQLTypeName(std::string tableName, std::string columnName) const;
+
+ std::string getColumnName(unsigned int columnIndex) const;
+ unsigned int getColumnIndex(std::string tableName, std::string columnName) const;
+
+ std::string getTableName(unsigned int columnIndex) const;
+ std::string getTableName(std::string tableName, std::string columnName) const;
+
+ SQLSMALLINT getSQLType(unsigned int columnIndex) const;
+ SQLSMALLINT getSQLType(std::string tableName, std::string columnName) const;
+
+ SQLSMALLINT getSQLCType(unsigned int columnIndex) const;
+ SQLSMALLINT getSQLCType(std::string tableName, std::string columnName) const;
+
+ unsigned int getColumnCount(void) const;
+
+ bool containsColumn(std::string tableName, std::string columnName) const;
+
+};
+
+ };
+ };
+};
+
+#endif //RESULT_SET_META_DATA_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSetPtr.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSetPtr.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSetPtr.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/ResultSetPtr.h Fri May 11 14:36:45 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/* $Rev: 452786 $ $Date: 2006-10-04 08:57:36 +0100 (Wed, 04 Oct 2006) $ */
+
+#ifndef RESULT_SET_PTR_H
+#define RESULT_SET_PTR_H
+
+#include "apache/das/RefCountingPointer.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+ class ResultSet;
+ typedef ::apache::das::RefCountingPointer<ResultSet> ResultSetPtr;
+
+ };
+ };
+};
+
+#endif //RESULT_SET_PTR_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/SqlException.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/SqlException.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/SqlException.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/SqlException.h Fri May 11 14:36:45 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+#ifndef SQL_EXCEPTION_H
+#define SQL_EXCEPTION_H
+
+#include <string>
+
+using std::exception;
+using std::string;
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class SqlException : public exception{
+ public:
+ SqlException(string errorText);
+ ~SqlException();
+};
+
+ };
+ };
+};
+
+#endif;
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Statement.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Statement.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Statement.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Statement.h Fri May 11 14:36:45 2007
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef STATEMENT_H
+#define STATEMENT_H
+
+#include <list>
+#include <windows.h>
+#include <sql.h>
+
+#include "apache/das/rdb/ResultSetPtr.h"
+
+#include "apache/das/rdb/Connection.h"
+#include "apache/das/rdb/ResultSet.h"
+
+using std::string;
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class ResultSet;
+class Statement;
+class Connection;
+
+typedef RefCountingObject<Statement> StatementObject;
+
+class Statement : public StatementObject {
+
+ friend class ResultSet;
+ friend class Database;
+
+ private:
+ SQLHSTMT statementHandle;
+ ResultSetPtr resultSet;
+ Connection* connection;
+
+ protected:
+ string queryString;
+
+ ResultSetPtr createResultSet(void);
+
+ public:
+ Statement(Connection& connection, SQLHSTMT statementHandle);
+ virtual ~Statement(void);
+ virtual SQLHSTMT getODBCStatement(void) const;
+ virtual ResultSetPtr executeQuery(string sql); /*throws SQLException*/
+ virtual void close(void);
+ virtual Connection& getConnection(void) const;
+
+};
+
+ };
+ };
+};
+
+#endif //STATEMENT_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/StatementPtr.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/StatementPtr.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/StatementPtr.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/StatementPtr.h Fri May 11 14:36:45 2007
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+#ifndef STATEMENT_PTR_H
+#define STATEMENT_PTR_H
+
+#include "apache/das/RefCountingPointer.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+ class Statement;
+ typedef ::apache::das::RefCountingPointer<Statement> StatementPtr;
+
+ };
+ };
+};
+
+#endif //STATEMENT_PTR_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Table.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Table.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Table.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Table.h Fri May 11 14:36:45 2007
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef TABLE_H
+#define TABLE_H
+
+#include <map>
+#include <list>
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+
+#include "apache/das/rdb/das_constants.h"
+#include "apache/das/rdb/RelationshipWrapper.h"
+#include "apache/das/rdb/Relationship.h"
+#include "apache/das/rdb/Config.h"
+#include "apache/das/rdb/KeyPair.h"
+#include "apache/das/rdb/ResultSet.h"
+#include "apache/das/rdb/Column.h"
+#include "apache/das/rdb/DASImpl.h"
+#include "apache/das/rdb/GraphBuilderMetaData.h"
+#include "apache/das/rdb/ODBCTypeHelper.h"
+
+#include "commonj/sdo/DataFactory.h"
+#include "commonj/sdo/DataObject.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class Config;
+class GraphBuilderMetaData;
+class Column;
+
+class Table {
+
+ private:
+ std::map<std::string, Column*>* columns;
+ std::list<std::string> pkColumns;
+ std::list<Relationship*> relationships;
+ GraphBuilderMetaData* graphBuilderMetaData;
+ std::string tableName;
+ std::string mappedName;
+
+ public:
+ Table(GraphBuilderMetaData& graphBuilderMetaData, std::string tableName);
+ virtual ~Table(void);
+
+ void addColumns(std::list<Column*>& columns);
+ void setMappedName(std::string mappedName);
+ void addPKColumn(std::string columnName);
+ void addRelationship(Relationship& relationship);
+
+ std::string getMappedName(void) const;
+ GraphBuilderMetaData& getGraphBuilderMetaData(void) const;
+ std::string getTableName(void) const;
+ Column* getColumn(std::string columnName) const;
+ const std::map<std::string, Column*>& getColumns(void) const;
+ unsigned int getPKColumnCount(void) const;
+
+ void createGraph(const GraphBuilderMetaData& graphBuilderMetaData, commonj::sdo::DataFactoryPtr dataFactory) const;
+
+};
+
+ };
+ };
+ };
+
+#endif //TABLE_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/TableData.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/TableData.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/TableData.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/TableData.h Fri May 11 14:36:45 2007
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#ifndef TABLE_DATA_H
+#define TABLE_DATA_H
+
+#include <list>
+#include <map>
+#include <string>
+#include <stdexcept>
+
+#include "apache/das/rdb/ColumnData.h"
+#include "apache/das/rdb/GraphBuilder.h"
+#include "apache/das/rdb/ResultSetMetaData.h"
+
+#include "commonj/sdo/DataObject.h"
+
+class ColumnData;
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+class ResultSet;
+class GraphBuilder;
+
+typedef std::map<std::string, ColumnData*> KeyDataList;
+
+class TableData {
+
+ private:
+ Table* table;
+ commonj::sdo::DataObjectPtr dataObject;
+ std::map<std::string, ColumnData*> columnsData;
+ KeyDataList* primaryKeys;
+ std::map<std::string, ColumnData*> foreignKeys;
+
+ public:
+ TableData(Table& table, ResultSetPtr resultSet);
+ virtual ~TableData(void);
+
+ Table& getTable(void) const;
+ bool hasPK(void) const;
+ commonj::sdo::DataObjectPtr getGraphObject(void) const;
+
+ bool operator==(const TableData& tableData) const;
+ bool operator==(const KeyDataList* primaryKeyList) const;
+ bool operator!=(const TableData& tableData) const;
+ bool operator!=(const KeyDataList* primaryKeyList) const;
+ bool operator<(const TableData& tableData) const;
+ bool operator<(const KeyDataList* primaryKeyList) const;
+
+ ColumnData* getColumnData(std::string columnName) const;
+ KeyDataList& getPrimaryKeys(void) const;
+
+ void addFK(std::string columnName);
+ void populateDataGraph(GraphBuilder& graphBuilder);
+
+};
+
+class KeyDataCmp {
+ public:
+ bool operator() (const KeyDataList* keyDataList1, const KeyDataList* keyDataList2 ) const;
+};
+
+ };
+ };
+};
+
+#endif //TABLE_DATA_H
Added: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/das_constants.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/das_constants.h?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/das_constants.h (added)
+++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/das_constants.h Fri May 11 14:36:45 2007
@@ -0,0 +1,3 @@
+#define DAS_ROOT_NAME "DAS_ROOT"
+#define DAS_NAMESPACE "das.lite"
+#define SDO_NAMESPACE "commonj.sdo"
Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/Command.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/Command.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/Command.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/Command.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+#include "apache/das/Command.h"
+
+namespace apache {
+ namespace das {
+
+Command::Command(void) {}
+
+Command::~Command(void) {}
+
+commonj::sdo::DataObjectPtr Command::executeQuery(void) {
+ return 0;
+};
+
+ };
+};
Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/DAS.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/DAS.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/DAS.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/DAS.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#include "apache/das/DAS.h"
+#include "apache/das/rdb/DASFactoryImpl.h"
+
+namespace apache {
+ namespace das {
+
+DASFactory* DAS::FACTORY = new rdb::DASFactoryImpl();
+
+DAS::DAS(void) {}
+
+DASFactory* DAS::getFACTORY(void) {
+ return FACTORY;
+}
+
+DAS::~DAS(void) {}
+
+ };
+};
Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/DASFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/DASFactory.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/DASFactory.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/DASFactory.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+#include "apache/das/DASFactory.h"
+
+namespace apache {
+ namespace das {
+
+DASFactory::DASFactory(void) {}
+
+DASFactory::~DASFactory(void) {}
+
+DAS* DASFactory::createDAS(rdb::Connection& connection) {
+ return 0;
+}
+
+ };
+};
Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/NullPointerException.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/NullPointerException.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/NullPointerException.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/NullPointerException.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+#include "apache/das/NullPointerException.h"
+
+namespace apache {
+ namespace das {
+
+NullPointerException::NullPointerException(void) {}
+
+NullPointerException::~NullPointerException(void) {}
+
+ };
+};
Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/RefCountingPointer.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/RefCountingPointer.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/RefCountingPointer.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/RefCountingPointer.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+#include "apache/das/RefCountingPointer.h"
+#include "apache/das/rdb/Statement.h"
+#include "apache/das/rdb/Connection.h"
+
+namespace apache {
+ namespace das {
+
+template<class T>
+void RefCountingPointer<T>::init()
+{
+ if (pointee == 0) return;
+ pointee->addRef(this);
+}
+
+template<class T>
+/*SDO_API*/ RefCountingPointer<T>::RefCountingPointer(T* realPtr, bool objectOwner)
+:pointee(realPtr)
+{
+ this->objectOwner = objectOwner;
+ init();
+}
+
+template<class T>
+/*SDO_API*/ RefCountingPointer<T>::RefCountingPointer(T& realPtr, bool objectOwner)
+:pointee(&realPtr)
+{
+ this->objectOwner = objectOwner;
+ init();
+}
+
+template<class T>
+RefCountingPointer<T>::RefCountingPointer(const RefCountingPointer<T>& rhs, bool objectOwner)
+: pointee(rhs.pointee)
+{
+ this->objectOwner = objectOwner;
+ init();
+}
+
+template<class T>
+/*SDO_API*/ RefCountingPointer<T>::~RefCountingPointer(void)
+{
+ if (pointee)pointee->releaseRef(this);
+}
+
+template<class T>
+/*SDO_API*/ RefCountingPointer<T>& RefCountingPointer<T>::operator=(const RefCountingPointer<T>& rhs)
+{
+ if (pointee != rhs.pointee)
+ {
+ T *oldP = pointee;
+ pointee = rhs.pointee;
+ init();
+ if (oldP) oldP->releaseRef(this);
+ }
+ return *this;
+}
+
+//RefCountingPointer& operator=(const RefCountingObject<T>& rhs)
+//{
+// if (pointee != &rhs)
+// {
+// T *oldP = pointee;
+// pointee = &pointee;
+// init();
+// if (oldP) oldP->releaseRef(this);
+// }
+// return *this;
+//}
+//
+//RefCountingPointer& operator=(const RefCountingObject<T>* rhs)
+//{
+// if (pointee != rhs)
+// {
+// T *oldP = pointee;
+// pointee = rhs;
+// init();
+// if (oldP) oldP->releaseRef(this);
+// }
+// return *this;
+//}
+
+template<class T>
+/*SDO_API*/ bool RefCountingPointer<T>::operator!() const
+{
+ return (pointee == 0);
+}
+
+template<class T>
+/*SDO_API*/ bool RefCountingPointer<T>::operator==(RefCountingPointer<T>& test) const
+{
+ return (pointee == test.pointee);
+}
+
+template<class T>
+/*SDO_API*/ T* RefCountingPointer<T>::operator->() const
+{
+ if (pointee == 0)
+ throw NullPointerException();
+ return pointee;
+}
+
+template<class T>
+/*SDO_API*/ T& RefCountingPointer<T>::operator*() const
+{
+ return *pointee;
+}
+
+template<class T>
+bool RefCountingPointer<T>::isObjectOwner(void) const {
+ return objectOwner;
+}
+
+
+ // officially, there is nothing here- but if I dont use the overrides in
+ // the templates, then they dont get generated.
+ void Test2()
+ {
+
+#if defined(WIN32) || defined (_WINDOWS)
+ {
+ /* 1) construct */
+ rdb::Connection* conn = new rdb::Connection("","","");
+ rdb::StatementPtr fptr = conn->createStatement();
+ rdb::StatementPtr a(new rdb::Statement(*conn, 0));
+ rdb::Statement& st = *(new rdb::Statement(*conn, 0));
+ rdb::StatementPtr* c = new rdb::StatementPtr(st);
+ c->isObjectOwner();
+
+ /* 2) use the & operator= */
+ fptr = conn->createStatement();
+
+ /* 3) copy */
+ rdb::StatementPtr fptr2 = fptr;
+
+ /* 4) use the == and ! */
+ if (fptr2 == fptr || !fptr){}
+
+ /* 5) Use the T* and * */
+ rdb::Statement* dmsf = fptr;
+ rdb::Statement& dmsr = *fptr;
+
+ /* 1) construct */
+ rdb::StatementPtr dfptr(fptr);
+
+ /* 3) copy */
+ rdb::StatementPtr dfptr2 = dfptr;
+
+ /* 2) use the & operator= */
+ dfptr = dfptr2;
+
+ /* 4) use the == and ! */
+ if (dfptr2 == dfptr || !dfptr){}
+
+ /* 5) Use the T* and * */
+ rdb::Statement* ddmsf = dfptr;
+ rdb::Statement& ddmsr = *dfptr;
+
+ /* 6) Use the -> */
+ dfptr->close();
+
+ /* and again to catch the = */
+ fptr = conn->createStatement();
+ delete fptr2;
+
+ }
+ {
+ /* 1) construct */
+ rdb::Connection* conn = new rdb::Connection("","","");
+ rdb::StatementPtr fptr = conn->createStatement();
+ rdb::ResultSetPtr a(new rdb::ResultSet(fptr));
+ rdb::ResultSetPtr b(new rdb::ResultSet(fptr));
+ rdb::ResultSet& st = *(new rdb::ResultSet(fptr));
+ rdb::ResultSetPtr* c = new rdb::ResultSetPtr(st);
+ c->isObjectOwner();
+ /* 2) use the & operator= */
+ a = b;
+
+ /* 3) copy */
+ rdb::ResultSetPtr d = a;
+
+ a = new rdb::ResultSet(fptr);
+ a = *(new rdb::ResultSet(fptr));
+
+ /* 4) use the == and ! */
+ if (a == b || !b){}
+
+ /* 5) Use the T* and * */
+ rdb::ResultSet* dmsf = a;
+ rdb::ResultSet& dmsr = *b;
+
+ /* 6) Use the -> */
+ a->getStatement();
+
+ /* and again to catch the = */
+ delete c;
+
+
+ }
+
+
+#endif
+
+ }
+
+ };
+};
Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Column.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Column.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Column.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Column.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#include "apache/das/rdb/Column.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+Column::Column(std::string columnName, SQLSMALLINT sqlType) {
+ this->columnName = columnName;
+ this->mappedName = columnName;
+ this->sqlType = sqlType;
+ containerTable = 0;
+ pk = false;
+ keyPairs = 0;
+
+}
+
+Column::~Column(void) {}
+
+void Column::setContainerTable(Table* containerTable) {
+ this->containerTable = containerTable;
+}
+
+Table* Column::getContainerTable(void) const {
+ return containerTable;
+}
+
+void Column::setPK(bool pk) {
+ this->pk = pk;
+}
+
+bool Column::isPK(void) const {
+ return pk;
+}
+
+std::string Column::getName(void) const {
+ return columnName;
+}
+
+SQLSMALLINT Column::getSQLType(void) const {
+ return sqlType;
+}
+
+std::list<KeyPair*>& Column::getKeyPairs(void) const {
+ return *keyPairs;
+}
+
+bool Column::isFK(void) const {
+ return (keyPairs != 0 && keyPairs->size() > 0);
+}
+
+void Column::setMappedName(std::string mappedName) {
+ this->mappedName = mappedName;
+}
+
+std::string Column::getMappedName(void) const {
+ return mappedName;
+}
+
+void Column::addKeyPair(KeyPair& keyPair) {
+
+ if (keyPairs == 0) {
+ keyPairs = new std::list<KeyPair*>();
+ }
+
+ keyPairs->push_back(&keyPair);
+
+}
+
+ };
+ };
+};
+
+//void Column::populateDataGraph(commonj::sdo::DataObjectPtr dataObject, ResultSet& resultSet) const {
+//
+// switch (sqlType) {
+//
+// case SQL_INTEGER :
+// dataObject->setInteger(columnName.c_str(), resultSet.getSQLInteger(
+// containerTable->getTableName(), columnName));
+// break;
+//
+// case SQL_CHAR :
+// dataObject->setCharacter(columnName.c_str(), resultSet.getSQLChar(
+// containerTable->getTableName(), columnName));
+// break;
+//
+// case SQL_DOUBLE :
+// dataObject->setDouble(columnName.c_str(), resultSet.getSQLDouble(
+// containerTable->getTableName(), columnName));
+// break;
+//
+// case SQL_FLOAT :
+// dataObject->setDouble(columnName.c_str(), resultSet.getSQLFloat(
+// containerTable->getTableName(), columnName));
+// break;
+//
+// case SQL_REAL :
+// dataObject->setFloat(columnName.c_str(), resultSet.getSQLReal(
+// containerTable->getTableName(), columnName));
+// break;
+//
+// case SQL_VARCHAR :
+// {
+// std::string varchar = resultSet.getSQLVarchar(containerTable->getTableName(),
+// columnName);
+//
+// unsigned int size = varchar.size();
+// wchar_t* aux = new wchar_t[size];
+// for (int i = 0 ; i < varchar.size() ; i++) {
+// aux[i] = (wchar_t) varchar[i];
+// }
+//
+// dataObject->setString(columnName.c_str(), aux, varchar.size());
+// delete [] aux;
+// }
+//
+// break;
+//
+// default :
+// throw std::logic_error("Invalid sql type!");
+//
+// }
+//
+//}
Added: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ColumnData.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ColumnData.cpp?view=auto&rev=537297
==============================================================================
--- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ColumnData.cpp (added)
+++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/ColumnData.cpp Fri May 11 14:36:45 2007
@@ -0,0 +1,343 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+#include "apache/das/rdb/ColumnData.h"
+
+namespace apache {
+ namespace das {
+ namespace rdb {
+
+ColumnData::ColumnData(Column& column, ResultSetPtr resultSet) {
+ this->column = &column;
+
+ switch (column.getSQLType()) {
+
+ case SQL_INTEGER :
+ {
+ long sqlInteger = resultSet->getSQLInteger(
+ column.getContainerTable()->getTableName(), column.getName());
+
+ data = new long;
+ long* aux = (long*) data;
+ *aux = sqlInteger;
+ }
+
+ break;
+
+ case SQL_CHAR :
+ {
+ wchar_t sqlChar = resultSet->getSQLChar(column.getContainerTable()->getTableName(),
+ column.getName());
+
+ data = new wchar_t;
+ wchar_t* aux = (wchar_t*) data;
+ *aux= sqlChar;
+ }
+
+ break;
+
+ case SQL_DOUBLE :
+ {
+ double sqlDouble = resultSet->getSQLDouble(column.getContainerTable()->getTableName(),
+ column.getName());
+
+ data = new double;
+ double* aux = (double*) data;
+ *aux = sqlDouble;
+ }
+
+ break;
+
+ case SQL_FLOAT :
+ {
+ double sqlFloat = resultSet->getSQLFloat(column.getContainerTable()->getTableName(),
+ column.getName());
+
+ data = new double;
+ double* aux = (double*) data;
+ *aux = sqlFloat;
+ }
+
+ break;
+
+ case SQL_REAL :
+ {
+ float sqlReal = resultSet->getSQLReal(column.getContainerTable()->getTableName(),
+ column.getName());
+
+ data = new float;
+ float* aux = (float*) data;
+ *aux = sqlReal;
+ }
+
+ break;
+
+ case SQL_VARCHAR :
+ {
+ std::string varchar = resultSet->getSQLVarchar(column.getContainerTable()->getTableName(),
+ column.getName());
+
+ data = new std::wstring(varchar.begin(), varchar.end());
+ std::wstring* aux = (std::wstring*) data;
+ (*aux).assign(varchar.begin(), varchar.end());
+ }
+
+ break;
+
+ default :
+ throw std::logic_error("Invalid sql type!");
+
+ }
+
+}
+
+ColumnData::~ColumnData(void) {
+ delete data;
+}
+
+void ColumnData::populateDataGraph(TableData& tableData) const {
+
+ if (!tableData.getGraphObject()->hasProperty(column->getName().c_str())) {
+ return;
+ }
+
+ switch (column->getSQLType()) {
+
+ case SQL_INTEGER :
+ tableData.getGraphObject()->setInteger(column->getName().c_str(), *((long*) data));
+
+ break;
+
+ case SQL_CHAR :
+ tableData.getGraphObject()->setCharacter(column->getName().c_str(), *((wchar_t*) data));
+
+ break;
+
+ case SQL_DOUBLE :
+ tableData.getGraphObject()->setDouble(column->getName().c_str(), *((double*) data));
+
+ break;
+
+ case SQL_FLOAT :
+ tableData.getGraphObject()->setDouble(column->getName().c_str(), *((double*) data));
+
+ break;
+
+ case SQL_REAL :
+ tableData.getGraphObject()->setFloat(column->getName().c_str(), *((float*) data));
+
+ break;
+
+ case SQL_VARCHAR :
+ {
+ std::wstring* varchar = (std::wstring*) data;
+ tableData.getGraphObject()->setString(column->getName().c_str(),
+ (*varchar).c_str(), (*varchar).size());
+ }
+
+ break;
+
+ default :
+ throw std::logic_error("Invalid sql type!");
+
+ }
+
+}
+
+bool ColumnData::operator==(ColumnData& columnData) const {
+
+ if (column->getSQLType() != columnData.column->getSQLType()) {
+ throw std::invalid_argument("Different sql types!");
+ }
+
+ switch (column->getSQLType()) {
+
+ case SQL_INTEGER :
+
+ if (*((long*) columnData.data) == *((long*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_CHAR :
+
+ if (*((wchar_t*) columnData.data) == *((wchar_t*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_DOUBLE :
+ case SQL_FLOAT :
+
+ if (*((double*) columnData.data) == *((double*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_REAL :
+
+ if (*((float*) columnData.data) == *((float*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_VARCHAR :
+ if (*((std::wstring*) columnData.data) == *((std::wstring*) data)) {
+ return true;
+ }
+
+ break;
+
+ default :
+ throw std::logic_error("Invalid sql type!");
+
+ }
+
+ return false;
+
+}
+
+bool ColumnData::operator!=(ColumnData& columnData) const {
+ return !(*this == columnData);
+}
+
+Column& ColumnData::getColumn(void) const {
+ return *column;
+}
+
+bool ColumnData::operator<(ColumnData& columnData) const {
+
+ if (column->getSQLType() != columnData.column->getSQLType()) {
+ throw std::invalid_argument("Different sql types!");
+ }
+
+ switch (column->getSQLType()) {
+
+ case SQL_INTEGER :
+
+ if (*((long*) columnData.data) > *((long*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_CHAR :
+
+ if (*((wchar_t*) columnData.data) > *((wchar_t*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_DOUBLE :
+ case SQL_FLOAT :
+
+ if (*((double*) columnData.data) > *((double*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_REAL :
+
+ if (*((float*) columnData.data) > *((float*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_VARCHAR :
+ if (*((std::wstring*) columnData.data) > *((std::wstring*) data)) {
+ return true;
+ }
+
+ break;
+
+ default :
+ throw std::logic_error("Invalid sql type!");
+
+ }
+
+ return false;
+
+}
+
+bool ColumnData::operator>(ColumnData& columnData) const {
+
+ if (column->getSQLType() != columnData.column->getSQLType()) {
+ throw std::invalid_argument("Different sql types!");
+ }
+
+ switch (column->getSQLType()) {
+
+ case SQL_INTEGER :
+
+ if (*((long*) columnData.data) < *((long*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_CHAR :
+
+ if (*((wchar_t*) columnData.data) < *((wchar_t*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_DOUBLE :
+ case SQL_FLOAT :
+
+ if (*((double*) columnData.data) < *((double*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_REAL :
+
+ if (*((float*) columnData.data) < *((float*) data)) {
+ return true;
+ }
+
+ break;
+
+ case SQL_VARCHAR :
+ if (*((std::wstring*) columnData.data) < *((std::wstring*) data)) {
+ return true;
+ }
+
+ break;
+
+ default :
+ throw std::logic_error("Invalid sql type!");
+
+ }
+
+ return false;
+
+}
+
+ };
+ };
+};
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org