00001
00002 #ifndef RDBMODEL_CONNECTION_H
00003 #define RDBMODEL_CONNECTION_H
00004 #include <vector>
00005 #include <string>
00006
00007
00008 namespace rdbModel{
00009
00025 enum MATCH {
00026 MATCHequivalent,
00027 MATCHcompatible,
00028 MATCHfail,
00029 MATCHnoConnection
00030 };
00031
00032 class ResultHandle;
00033 class Assertion;
00034 class Rdb;
00052 typedef std::vector<std::string> StringVector;
00053
00054 class Connection {
00059 public:
00060 Connection() {};
00061 virtual ~Connection() {};
00062 virtual bool open(const std::string& host, const std::string& userid,
00063 const std::string& password,
00064 const std::string& dbName) = 0;
00065
00068 virtual bool close() = 0;
00069
00072 virtual bool open(const std::string& parms) = 0;
00073
00075 virtual bool isConnected() = 0;
00076
00077 virtual std::ostream* getOut() const = 0;
00078 virtual std::ostream* getErrOut() const = 0;
00079
00085 virtual MATCH matchSchema(Rdb *rdb, bool matchDbName=true) = 0;
00086
00093 virtual bool insertRow(const std::string& tableName,
00094 const StringVector& colNames,
00095 const StringVector& values,
00096 int* auto_value=0,
00097 const StringVector* nullCols = 0) = 0;
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00121 virtual unsigned int update(const std::string& tableName,
00122 const StringVector& colNames,
00123 const StringVector& values,
00124 const Assertion* where=0,
00125 const StringVector* nullCols = 0) = 0;
00126
00140 virtual ResultHandle* select(const std::string& tableName,
00141 const StringVector& getCols,
00142 const StringVector& orderCols,
00143 const Assertion* where=0,
00144 int rowLimit=0,
00145 int rowOffset=0)=0;
00146
00151 virtual void disableModify(bool disable)=0;
00152
00160 virtual ResultHandle* dbRequest(const std::string& request)=0;
00161
00167 virtual bool compileAssertion(const Assertion* a, std::string& sqlString)
00168 const = 0;
00169
00170 };
00171
00172 }
00173 #endif