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

# User Rev Content
1 afaq 1.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 afaq 1.7 #include "SQLOracle.hpp"
18 afaq 1.1 #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 sekhri 1.3 void dispose();
30 afaq 1.1 TableTemplate(DBManagement* dbmanager);
31     void addRow(RowInterface* aRow);
32     void addRow(R* aRow);
33     void delRows();
34 afaq 1.7 bool next();
35     void reset();
36     std::string getStrValue(std::string colName);
37     int getIntValue(std::string colName);
38 afaq 1.1 //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 afaq 1.7 void executeOperation(std::string op);
45 afaq 1.1 std::string* getTableName();
46     void setDBManager(DBManagement* dbmanager);
47     Dictionary* getSchema();
48 sekhri 1.2 Dictionary* getMultiRefrence();
49 sekhri 1.3 std::vector<R*>& getRows();
50     int getNoOfRows();
51     std::string getStrValue(int index, string name);
52 afaq 1.1
53     private:
54     void init();
55     RowSchemaNConstraintsBinding<R> schemaNconstraints;
56     int getSeqValue(std::string, std::string);
57 afaq 1.7 int getSeqValue(R* aRow, std::string tableName, std::string colName);
58 afaq 1.1
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 afaq 1.7 ResultSet* rs;
76     bool isRs;
77 afaq 1.1
78    
79     protected :
80     log4cxx::LoggerPtr logger;
81     virtual void doSmartInsert(R*){cout <<"doSmartInsert virtual"<<endl; };
82 afaq 1.7 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 afaq 1.1 void insertSingle(R*, std::string, std::string);
87 afaq 1.7 void updateSingle(R*, std::string, std::string);
88     void operationMulti(R*, std::string, std::string);
89 afaq 1.1 void insertMulti(R*, std::string);
90 afaq 1.7 void updateMulti(R*, std::string);
91 afaq 1.1 void fixPKWithSeq(R*);
92     void setTimeInRow(R*);
93     void setPersonInRow(R*);
94     ResultSet* doSelect(std::string, std::string);
95 afaq 1.7 //void convertIntoRow(ResultSet*,int,R*);
96     void convertIntoRow(ResultSet*,R*);
97 afaq 1.1 void reSetColNamesInRS(ResultSet* rs);
98     Dictionary* multiRefrences;
99 afaq 1.7 Dictionary* schema;
100 afaq 1.1 Keys primaryKeysReal;
101     ListOfLists* uniqueKeys;
102    
103     Util util;
104     SQL* sql;
105     DBManagement* dbmanager;
106     Keys* schemaOrder;
107 afaq 1.4 Keys* notNullKeys;
108 afaq 1.1
109     };
110    
111     #endif
112