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 #include <coconut_config.h>
00029 #include <annotation_delta.h>
00030
00031 namespace coco {
00032
00033 typedef std::vector<std::pair<vdbl::tableid,vdbl::rowid> > trvec;
00034
00035 bool annotation_delta::apply(work_node& _x, undelta_base*& _u,
00036 const delta_id& _did) const
00037 {
00038 std::vector<annotation> rmd;
00039 rmd.reserve(rm.size());
00040 std::vector<annotation>::const_iterator __x, __e(rm.end());
00041 std::vector<annotation>::iterator __y, __f;
00042 for(__x = rm.begin(); __x != __e; ++__x)
00043 {
00044 __f = _x._ann.end();
00045 for(__y = _x._ann.begin(); __y != __f; ++__y)
00046 {
00047 if(*__x == *__y)
00048 {
00049 _x._ann.erase(__y);
00050 rmd.push_back(*__x);
00051 break;
00052 }
00053 }
00054 }
00055 _x._ann.insert(_x._ann.end(), add.begin(), add.end());
00056 _x.get_viewdbase().rm_visible(trvec(rm.begin(), rm.end()));
00057 _x.get_viewdbase().add_visible(trvec(add.begin(), add.end()));
00058 _u = (undelta_base *) new annotation_undelta(add, rmd);
00059 return true;
00060 }
00061
00062 bool annotation_undelta::unapply(work_node& _x, const delta_id& _did) const
00063 {
00064 std::vector<annotation>::const_iterator __x, __e(added_ann.end());
00065 std::vector<annotation>::iterator __y, __f;
00066 for(__x = added_ann.begin(); __x != __e; ++__x)
00067 {
00068 __f = _x._ann.end();
00069 for(__y = _x._ann.begin(); __y != __f; ++__y)
00070 {
00071 if(*__x == *__y)
00072 {
00073 _x._ann.erase(__y);
00074 break;
00075 }
00076 }
00077 }
00078 _x.get_viewdbase().rm_visible(trvec(added_ann.begin(), added_ann.end()));
00079 _x.get_viewdbase().add_visible(trvec(removed_ann.begin(), removed_ann.end()));
00080 _x._ann.insert(_x._ann.end(), removed_ann.begin(), removed_ann.end());
00081 return true;
00082 }
00083
00084 }
00085