COOPY » Guide
version 0.6.5
|
00001 #ifndef COOPY_POOL 00002 #define COOPY_POOL 00003 00004 #include <coopy/SheetCell.h> 00005 00006 #include <map> 00007 00008 namespace coopy { 00009 namespace store { 00010 class PoolRecord; 00011 class Pool; 00012 class PoolColumnLink; 00013 class PoolColumn; 00014 } 00015 } 00016 00017 class coopy::store::PoolRecord { 00018 public: 00019 SheetCell cell; 00020 bool novel; 00021 bool stale; 00022 bool linked; 00023 }; 00024 00025 class coopy::store::PoolColumn { 00026 public: 00027 virtual ~PoolColumn() {} 00028 virtual bool isValid() const = 0; 00029 00030 virtual PoolRecord& lookupMod(const SheetCell& val, bool& match) = 0; 00031 00032 virtual const PoolRecord& lookup(const SheetCell& val, bool& match) const = 0; 00033 00034 virtual PoolRecord& put(const SheetCell& src, const SheetCell& dest) = 0; 00035 }; 00036 00037 class coopy::store::PoolColumnLink { 00038 private: 00039 PoolColumn *column; 00040 bool invent; 00041 std::string table_name; 00042 std::string column_name; 00043 std::string pool_name; 00044 public: 00045 PoolColumnLink() { 00046 column = 0 /*NULL*/; 00047 invent = false; 00048 } 00049 00050 PoolColumnLink(PoolColumn& column, bool invent) : column(&column), 00051 invent(invent) { 00052 } 00053 00054 PoolColumnLink(PoolColumn& column, bool invent, 00055 const std::string& table_name, 00056 const std::string& column_name, 00057 const std::string& pool_name) : column(&column), 00058 invent(invent), 00059 table_name(table_name), 00060 column_name(column_name), 00061 pool_name(pool_name) { 00062 } 00063 00064 PoolColumnLink(const PoolColumnLink& alt) { 00065 this->column = alt.column; 00066 this->invent = alt.invent; 00067 this->table_name = table_name; 00068 this->column_name = column_name; 00069 this->pool_name = pool_name; 00070 } 00071 00072 const PoolColumnLink& operator = (const PoolColumnLink& alt) { 00073 this->column = alt.column; 00074 this->invent = alt.invent; 00075 this->table_name = alt.table_name; 00076 this->column_name = alt.column_name; 00077 this->pool_name = alt.pool_name; 00078 return *this; 00079 } 00080 00081 bool isInventor() { return invent; } 00082 00083 PoolColumn& getColumn() { return *column; } 00084 00085 bool isValid() const { 00086 if (!column) return false; 00087 return column->isValid(); 00088 } 00089 00090 std::string getTableName() const { 00091 return table_name; 00092 } 00093 00094 std::string getColumnName() const { 00095 return column_name; 00096 } 00097 00098 std::string getPoolName() const { 00099 return pool_name; 00100 } 00101 }; 00102 00103 class coopy::store::Pool { 00104 private: 00105 bool scanned; 00106 public: 00107 Pool() { 00108 scanned = false; 00109 } 00110 00111 virtual ~Pool() {} 00112 00113 virtual bool create(const std::string& key, 00114 const std::string& table_name, 00115 const std::string& column_name, 00116 bool invent) = 0; 00117 00118 virtual PoolColumnLink lookup(const std::string& table_name, 00119 const std::string& column_name) = 0; 00120 00121 virtual PoolColumnLink trace(const PoolColumnLink& src) = 0; 00122 00123 00124 virtual PoolRecord& lookup(const std::string& table_name, 00125 const std::string& column_name, 00126 const SheetCell& val, 00127 bool& match) = 0; 00128 00129 void setScanned() { 00130 scanned = true; 00131 } 00132 00133 bool isScanned() const { 00134 return scanned; 00135 } 00136 }; 00137 00138 #endif