ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DBS/Servers/AppServer/include/TableTemplate.hpp
Revision: 1.3
Committed: Thu Jan 19 22:56:32 2006 UTC (19 years, 3 months ago) by sekhri
Branch: MAIN
CVS Tags: BeforeJan2006SchemaChanges
Changes since 1.2: +4 -0 lines
Log Message:
Removed Message layer completely from the Server

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 sekhri 1.3 void dispose();
29 afaq 1.1 TableTemplate(DBManagement* dbmanager);
30     void addRow(RowInterface* aRow);
31     void addRow(R* aRow);
32     void delRows();
33     //RowIter getRowsBegin();
34     //RowIter getRowsEnd();
35     std::vector<R*>& select(std::string whereClause);
36     //std::vector<RowInterface*>& select(std::string whereClause);
37     void insert();
38     void update();
39     std::string* getTableName();
40     void setDBManager(DBManagement* dbmanager);
41     Dictionary* getSchema();
42 sekhri 1.2 Dictionary* getMultiRefrence();
43 sekhri 1.3 std::vector<R*>& getRows();
44     int getNoOfRows();
45     std::string getStrValue(int index, string name);
46 afaq 1.1
47     private:
48     void init();
49     RowSchemaNConstraintsBinding<R> schemaNconstraints;
50     int getSeqValue(std::string, std::string);
51    
52     std::string makeSelectQuery(std::string);
53     std::string makeWhereClause(std::string);
54     std::vector<std::string> makeInsertQuery(R*);
55     Dictionary getSatisfiedRefrences(ResultSet*,int);
56     void makeRefrences(void);
57    
58     Dictionary* schema;
59     Dictionary* constraints;
60     Dictionary* refrences;
61    
62    
63     Keys* primaryKeys;
64     Keys* notNullKeys;
65     Keys* foreignKeys;
66    
67     std::string *tableName;
68     std::vector<R*> rows;
69     typedef std::vector<R*>::iterator RowIter;
70     RowIter rowIterator;
71    
72    
73     protected :
74     log4cxx::LoggerPtr logger;
75     virtual void doSmartInsert(R*){cout <<"doSmartInsert virtual"<<endl; };
76     void doSimpleInsert(R*);
77     void insertSingle(R*, std::string, std::string);
78     void insertMulti(R*, std::string);
79     void fixPKWithSeq(R*);
80     void setTimeInRow(R*);
81     void setPersonInRow(R*);
82     ResultSet* doSelect(std::string, std::string);
83     void convertIntoRow(ResultSet*,int,R*);
84     void reSetColNamesInRS(ResultSet* rs);
85     Dictionary* multiRefrences;
86     Keys primaryKeysReal;
87     ListOfLists* uniqueKeys;
88    
89     Util util;
90     SQL* sql;
91     DBManagement* dbmanager;
92     Keys* schemaOrder;
93    
94     };
95    
96     #endif
97