00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00028 #ifndef _TABLE_DELTA_H_
00029 #define _TABLE_DELTA_H_
00030
00031 #include <api_delta.h>
00032
00033 namespace coco {
00034
00036
00043 class table_delta : public delta_base
00044 {
00045 public:
00047 typedef std::pair<std::string,dbt_row> t_line;
00049 typedef std::vector<t_line> t_ctr;
00050
00051 private:
00053 t_ctr t_new;
00055 std::vector<annotation> t_rm;
00056
00057 public:
00059 table_delta(const std::string& a) : delta_base(a), t_new(), t_rm() {}
00060
00064 table_delta(const std::string& a, const t_ctr& _n,
00065 const std::vector<annotation>& _r) : delta_base(a), t_new(_n),
00066 t_rm(_r) {}
00067
00069 table_delta(const table_delta& __d) : delta_base(__d), t_new(__d.t_new),
00070 t_rm(__d.t_rm)
00071 {
00072 #if DEBUG_DELTA
00073 std::cerr << "Called table_delta copy constructor" << std::endl;
00074 #endif
00075 }
00076
00079 table_delta(const std::string& a, const std::string& __tn, const dbt_row& __t)
00080 : delta_base(a), t_new(), t_rm()
00081 { t_new.push_back(std::make_pair(__tn, __t)); }
00082
00085 table_delta(const std::string& a, const std::string& __tn,
00086 const std::vector<dbt_row>& __t)
00087 : delta_base(a), t_new(), t_rm()
00088 { t_new.reserve(__t.size());
00089 for(std::vector<dbt_row>::const_iterator __x = __t.begin();
00090 __x != __t.end(); ++__x)
00091 t_new.push_back(std::make_pair(__tn, *__x));
00092 }
00093
00095 void add(const t_line& _tl) { t_new.push_back(_tl); }
00097 void add(const std::string& _tn, const dbt_row& _r)
00098 { add(std::make_pair(_tn, _r)); }
00100 void add(const std::vector<t_line>& _tlv)
00101 { t_new.insert(t_new.end(), _tlv.begin(), _tlv.end()); }
00104 void rm(const annotation& _tr) { t_rm.push_back(_tr); }
00107 void rm(const std::vector<annotation>& _trv)
00108 { t_rm.insert(t_rm.end(), _trv.begin(), _trv.end()); }
00109
00111 virtual table_delta* new_copy() const { return new table_delta(*this); }
00112
00114 virtual void destroy_copy(delta_base* __d) const { delete (table_delta*)__d; }
00115
00119 virtual void create_table(work_node& _x, vdbl::standard_table*& ptb,
00120 const std::string& __t) const {};
00121
00125 virtual bool apply(work_node& _x, undelta_base*& _u, const delta_id& _did) const;
00126
00131 void convert(work_node& _x, delta_base*& _u);
00132
00134 bool operator==(const delta_base& _c) const
00135 { return _c.get_action() == get_action() &&
00136 this->operator==(*(table_delta*)&_c); }
00137 bool operator!=(const delta_base& _c) const
00138 { return _c.get_action() != get_action() ||
00139 this->operator!=(*(table_delta*)&_c); }
00140
00142 bool operator==(const table_delta& _c) const { return this == &_c; }
00143 bool operator!=(const table_delta& _c) const { return this != &_c; }
00144 };
00145
00146 }
00147
00148 #endif