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 _ANNOTATION_DELTA_H_
00029 #define _ANNOTATION_DELTA_H_
00030
00031 #include <api_delta.h>
00032
00033 namespace coco {
00034
00036
00040 class annotation_undelta : public undelta_base
00041 {
00042 public:
00044 std::vector<annotation> added_ann;
00046 std::vector<annotation> removed_ann;
00047
00048 public:
00051 annotation_undelta(const std::vector<annotation>& __a,
00052 const std::vector<annotation>& __r) : undelta_base(),
00053 added_ann(__a),
00054 removed_ann(__r) {}
00055
00058 annotation_undelta(const std::vector<annotation>& __a) : undelta_base(),
00059 added_ann(__a),
00060 removed_ann() {}
00061
00063 annotation_undelta(const annotation& __a) : undelta_base(),
00064 added_ann(1,__a),
00065 removed_ann() {}
00066
00068 annotation_undelta(const annotation_undelta& __d) : undelta_base(__d),
00069 added_ann(__d.added_ann),
00070 removed_ann(__d.removed_ann)
00071 {
00072 #if DEBUG_DELTA
00073 std::cerr << "Called annotation_undelta copy constructor" << std::endl;
00074 #endif
00075 }
00076
00078 annotation_undelta* new_copy() const { return new annotation_undelta(*this); }
00080 void destroy_copy(undelta_base* __d) const { delete (annotation_undelta*)__d; }
00081
00084 bool unapply(work_node& _x, const delta_id& _did) const;
00085
00086 friend class annotation_delta;
00087 };
00088
00090
00095 class annotation_delta : public delta_base
00096 {
00097 public:
00099 std::vector<annotation> add;
00101 std::vector<annotation> rm;
00102
00103 public:
00107 annotation_delta(const std::string& _act) : delta_base(_act), add(), rm() {}
00108
00112 annotation_delta(const std::string& _act,
00113 const std::vector<annotation>& __a,
00114 const std::vector<annotation>& __r)
00115 : delta_base(_act), add(__a), rm(__r) {}
00116
00120 annotation_delta(const std::string& _act, const annotation& _ad)
00121 : delta_base(_act), add(1,_ad), rm() {}
00122
00127 annotation_delta(const std::string& _act, bool _dummy, const annotation& _rm)
00128 : delta_base(_act), add(), rm(1,_rm) {}
00129
00131 annotation_delta(const annotation_delta& __d)
00132 : delta_base(__d), add(__d.add), rm(__d.rm)
00133 {
00134 #if DEBUG_DELTA
00135 std::cerr << "Called annotation_delta copy constructor" << std::endl;
00136 #endif
00137 }
00138
00142 annotation_delta(const char* _act,
00143 const std::vector<annotation>& __a,
00144 const std::vector<annotation>& __r)
00145 : delta_base(_act), add(__a), rm(__r) {}
00146
00150 annotation_delta(const char* _act, const annotation& _ad)
00151 : delta_base(_act), add(1,_ad), rm() {}
00152
00157 annotation_delta(const char* _act, bool _dummy, const annotation& _rm)
00158 : delta_base(_act), add(), rm(1,_rm) {}
00159
00161 virtual annotation_delta* new_copy() const
00162 { return new annotation_delta(*this); }
00164 virtual void destroy_copy(delta_base* __d) const
00165 { delete (annotation_delta*)__d; }
00166
00170 virtual bool apply(work_node& _x, undelta_base*& _u, const delta_id& _did) const;
00171
00173 bool operator==(const delta_base& _c) const
00174 { return _c.get_action() == get_action() &&
00175 this->operator==(*(annotation_delta*)&_c); }
00176 bool operator!=(const delta_base& _c) const
00177 { return _c.get_action() != get_action() ||
00178 this->operator!=(*(annotation_delta*)&_c); }
00179
00181 bool operator==(const annotation_delta& _c) const
00182 { return this == &_c || (add == _c.add && rm == _c.rm); }
00183 bool operator!=(const annotation_delta& _c) const
00184 { return this != &_c && (add != _c.add || rm != _c.rm); }
00185 };
00186
00187 }
00188
00189 #endif