COOPY » Guide
version 0.6.5
|
00001 #ifndef COOPY_POOLIMPL 00002 #define COOPY_POOLIMPL 00003 00004 #include <coopy/Pool.h> 00005 #include <coopy/PolyBook.h> 00006 00007 #include <map> 00008 00009 namespace coopy { 00010 namespace store { 00011 class PoolLinkImpl; 00012 class PoolSlice; 00013 class PoolImpl; 00014 } 00015 } 00016 00017 00018 class coopy::store::PoolLinkImpl { 00019 public: 00020 std::string name; 00021 std::string table_name; 00022 std::string column_name; 00023 bool invent; 00024 00025 PoolLinkImpl() { 00026 invent = 0; 00027 } 00028 }; 00029 00030 class coopy::store::PoolSlice : public PoolColumn { 00031 public: 00032 PoolRecord dud; 00033 std::string pool_name; 00034 std::map<std::string,PoolRecord> item; 00035 00036 virtual bool isValid() const { 00037 return pool_name!=""; 00038 } 00039 00040 virtual PoolRecord& lookupMod(const SheetCell& val, bool& match); 00041 00042 virtual const PoolRecord& lookup(const SheetCell& val, bool& match) const; 00043 00044 virtual PoolRecord& put(const SheetCell& src, const SheetCell& dest) { 00045 PoolRecord rec = {dest,true,false,true}; 00046 return item[src.toString()] = rec; 00047 } 00048 }; 00049 00050 class coopy::store::PoolImpl : public Pool { 00051 private: 00052 PolyBook book; 00053 std::map<std::string,PoolLinkImpl> pool_link; 00054 std::map<std::string,PoolLinkImpl *> pool_link_root; 00055 std::map<std::string,PoolSlice> pool; 00056 PoolSlice null_column; 00057 00058 std::string getKey(const std::string& table_name, 00059 const std::string& column_name) { 00060 std::string key = table_name + ":::" + column_name; 00061 return key; 00062 } 00063 00064 PoolRecord dud; 00065 00066 public: 00067 void attachBook(PolyBook& book) { 00068 this->book = book; 00069 load(); 00070 } 00071 00072 bool load(); 00073 00074 bool save(); 00075 00076 virtual bool create(const std::string& key, 00077 const std::string& table_name, 00078 const std::string& column_name, 00079 bool invent); 00080 00081 virtual PoolColumnLink lookup(const std::string& table_name, 00082 const std::string& column_name); 00083 00084 virtual PoolRecord& lookup(const std::string& table_name, 00085 const std::string& column_name, 00086 const SheetCell& val, 00087 bool& match); 00088 00089 virtual PoolColumnLink trace(const PoolColumnLink& src); 00090 00091 }; 00092 00093 #endif