ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DBS/Servers/AppServer/include/TableTemplate.hpp
Revision: 1.7
Committed: Fri Apr 21 18:40:42 2006 UTC (19 years ago) by afaq
Branch: MAIN
CVS Tags: DBS_0_0_2, DBS_0_0_1, pre_DBS_0_0_1, post_dict_type_checking_merge, post_MiniPythonAPI_merged_to_trunk, pre_MiniPythonAPI_merge_to_trunk, HEAD
Changes since 1.6: +19 -4 lines
Log Message:
Performance enhanced code

File Contents

# Content
1 #ifndef _TableTemplate_hpp_included_
2 #define _TableTemplate_hpp_included_
3
4 /// This file contains a Tempelate Class that
5 /// Represents a RDMS Table, containing a vector
6 /// of Rows, where each Row is a self describing
7 /// Object.
8
9 #include <iostream.h>
10 #include <vector>
11 #include "common.hpp"
12 #include "ResultSet.hpp"
13 #include "DBManagement.hpp"
14 #include "BaseSchemaNConstratints.hpp"
15 #include "Util.hpp"
16 #include "SQL.hpp"
17 #include "SQLOracle.hpp"
18 #include "TableInterface.hpp"
19 #include <log4cxx/logger.h>
20
21 /// Template Class for a Table
22 template <class R>
23 class TableTemplate : public TableInterface {
24
25 public:
26 //Default constructor
27 TableTemplate();
28 ~TableTemplate();
29 void dispose();
30 TableTemplate(DBManagement* dbmanager);
31 void addRow(RowInterface* aRow);
32 void addRow(R* aRow);
33 void delRows();
34 bool next();
35 void reset();
36 std::string getStrValue(std::string colName);
37 int getIntValue(std::string colName);
38 //RowIter getRowsBegin();
39 //RowIter getRowsEnd();
40 std::vector<R*>& select(std::string whereClause);
41 //std::vector<RowInterface*>& select(std::string whereClause);
42 void insert();
43 void update();
44 void executeOperation(std::string op);
45 std::string* getTableName();
46 void setDBManager(DBManagement* dbmanager);
47 Dictionary* getSchema();
48 Dictionary* getMultiRefrence();
49 std::vector<R*>& getRows();
50 int getNoOfRows();
51 std::string getStrValue(int index, string name);
52
53 private:
54 void init();
55 RowSchemaNConstraintsBinding<R> schemaNconstraints;
56 int getSeqValue(std::string, std::string);
57 int getSeqValue(R* aRow, std::string tableName, std::string colName);
58
59 std::string makeSelectQuery(std::string);
60 std::string makeWhereClause(std::string);
61 Dictionary getSatisfiedRefrences(ResultSet*,int);
62 void makeRefrences(void);
63
64 Dictionary* constraints;
65 Dictionary* refrences;
66
67
68 Keys* primaryKeys;
69 Keys* foreignKeys;
70
71 std::string *tableName;
72 std::vector<R*> rows;
73 typedef std::vector<R*>::iterator RowIter;
74 RowIter rowIterator;
75 ResultSet* rs;
76 bool isRs;
77
78
79 protected :
80 log4cxx::LoggerPtr logger;
81 virtual void doSmartInsert(R*){cout <<"doSmartInsert virtual"<<endl; };
82 virtual void doSmartUpdate(R*){cout <<"doSmartUpdate virtual"<<endl; };
83 //void doSimpleInsert(R*);
84 std::vector<std::string> makeInsertQuery(R*);
85 void operationSingle(R*, std::string, std::string, std::string);
86 void insertSingle(R*, std::string, std::string);
87 void updateSingle(R*, std::string, std::string);
88 void operationMulti(R*, std::string, std::string);
89 void insertMulti(R*, std::string);
90 void updateMulti(R*, std::string);
91 void fixPKWithSeq(R*);
92 void setTimeInRow(R*);
93 void setPersonInRow(R*);
94 ResultSet* doSelect(std::string, std::string);
95 //void convertIntoRow(ResultSet*,int,R*);
96 void convertIntoRow(ResultSet*,R*);
97 void reSetColNamesInRS(ResultSet* rs);
98 Dictionary* multiRefrences;
99 Dictionary* schema;
100 Keys primaryKeysReal;
101 ListOfLists* uniqueKeys;
102
103 Util util;
104 SQL* sql;
105 DBManagement* dbmanager;
106 Keys* schemaOrder;
107 Keys* notNullKeys;
108
109 };
110
111 #endif
112