00001 /* 00002 read_base.hpp 00003 base class for data read access 00004 00005 */ 00006 #ifndef Read_Base_Hpp 00007 #define Read_Base_Hpp 00008 00009 // includes 00010 // #include "connectstring" 00011 #include "openDB.hpp" 00012 00013 // for separate db instances 00014 class read_base 00015 { 00016 protected: 00017 openDbFactory DbMaker; 00018 openDB & db; 00019 openRsFactory RsMaker; 00020 openRS & rs; 00021 00022 public: 00023 read_base():DbMaker(PROVIDER,CONNECTSTRING),db(DbMaker.db()) 00024 ,RsMaker(db),rs(RsMaker.rs()){;} 00025 virtual~read_base(){;} 00026 }; 00027 00028 00029 // for shared db instances 00030 class ref_base 00031 { 00032 protected: 00033 openDB & db; 00034 openRsFactory RsMaker; 00035 openRS & rs; 00036 public: 00037 ref_base(openDB & dbIn) 00038 :db(dbIn) 00039 ,RsMaker(db) 00040 ,rs(RsMaker.rs()) 00041 {;} 00042 virtual~ref_base() 00043 {;} 00044 }; 00045 00046 class quickQuery: protected read_base 00047 { 00048 public: 00049 bool opened; 00050 quickQuery():read_base(),opened(false){;} 00051 virtual ~quickQuery(){;} 00052 openRS & getData ( string query ) 00053 { 00054 if( rs.open(query) ) opened = true; 00055 return rs; 00056 } 00057 openRS & getRS() 00058 { 00059 return rs; 00060 } 00061 }; 00062 00063 /* 00064 quickerQuery is like quickQuery, 00065 but it re-uses a db connection for faster access 00066 to data. 00067 00068 */ 00069 class quickerQuery: protected ref_base 00070 { 00071 public: 00072 bool opened; 00073 quickerQuery(openDB & dbIn):ref_base(dbIn),opened(false){;} 00074 virtual ~quickerQuery(){;} 00075 openRS & getData ( string query ) 00076 { 00077 if( rs.open(query) ) opened = true; 00078 return rs; 00079 } 00080 openRS & getRS() 00081 { 00082 return rs; 00083 } 00084 }; 00085 00086 #endif
1.5.5