ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DBS/Servers/AppServer/include/TableTemplate.hpp
Revision: 1.1
Committed: Mon Oct 31 22:10:36 2005 UTC (19 years, 6 months ago) by afaq
Branch: MAIN
Branch point for: v00
Log Message:
Initial revision

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     #include "TableInterface.hpp"
18     #include <log4cxx/logger.h>
19    
20     /// Template Class for a Table
21     template <class R>
22     class TableTemplate : public TableInterface {
23    
24     public:
25     //Default constructor
26     TableTemplate();
27     ~TableTemplate();
28     TableTemplate(DBManagement* dbmanager);
29     void addRow(RowInterface* aRow);
30     void addRow(R* aRow);
31     void delRows();
32     //RowIter getRowsBegin();
33     //RowIter getRowsEnd();
34     std::vector<R*>& select(std::string whereClause);
35     //std::vector<RowInterface*>& select(std::string whereClause);
36     void insert();
37     void update();
38     std::string* getTableName();
39     void setDBManager(DBManagement* dbmanager);
40     Dictionary* getSchema();
41    
42     private:
43     void init();
44     RowSchemaNConstraintsBinding<R> schemaNconstraints;
45     int getSeqValue(std::string, std::string);
46    
47     std::string makeSelectQuery(std::string);
48     std::string makeWhereClause(std::string);
49     std::vector<std::string> makeInsertQuery(R*);
50     Dictionary getSatisfiedRefrences(ResultSet*,int);
51     void makeRefrences(void);
52    
53     Dictionary* schema;
54     Dictionary* constraints;
55     Dictionary* refrences;
56    
57    
58     Keys* primaryKeys;
59     Keys* notNullKeys;
60     Keys* foreignKeys;
61    
62     std::string *tableName;
63     std::vector<R*> rows;
64     typedef std::vector<R*>::iterator RowIter;
65     RowIter rowIterator;
66    
67    
68     protected :
69     log4cxx::LoggerPtr logger;
70     virtual void doSmartInsert(R*){cout <<"doSmartInsert virtual"<<endl; };
71     void doSimpleInsert(R*);
72     void insertSingle(R*, std::string, std::string);
73     void insertMulti(R*, std::string);
74     void fixPKWithSeq(R*);
75     void setTimeInRow(R*);
76     void setPersonInRow(R*);
77     ResultSet* doSelect(std::string, std::string);
78     void convertIntoRow(ResultSet*,int,R*);
79     void reSetColNamesInRS(ResultSet* rs);
80     Dictionary* multiRefrences;
81     Keys primaryKeysReal;
82     ListOfLists* uniqueKeys;
83    
84     Util util;
85     SQL* sql;
86     DBManagement* dbmanager;
87     Keys* schemaOrder;
88    
89     };
90    
91     #endif
92