Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

annotation_delta.cc

Go to the documentation of this file.
00001 // Annotation Delta implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2001-2003 Hermann Schichl
00004 //
00005 // This file is part of the COCONUT API.  This library
00006 // is free software; you can redistribute it and/or modify it under the
00007 // terms of the Library GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // Library GNU General Public License for more details.
00015 
00016 // As a special exception, you may use this file as part of a free software
00017 // library without restriction.  Specifically, if other files instantiate
00018 // templates or use macros or inline functions from this file, or you compile
00019 // this file and link it with other files to produce an executable, this
00020 // file does not by itself cause the resulting executable to be covered by
00021 // the Library GNU General Public License.  This exception does not however
00022 // invalidate any other reasons why the executable file might be covered by
00023 // the Library GNU General Public License.
00024 
00027 #include <annotation_delta.h>
00028 
00029 bool annotation_delta::apply(work_node& _x, undelta_base*& _u) const
00030 {
00031   std::vector<annotation> rmd;
00032   rmd.reserve(rm.size());
00033   std::vector<annotation>::const_iterator __x, __e(rm.end());
00034   std::vector<annotation>::iterator __y, __f;
00035   for(__x = rm.begin(); __x != __e; ++__x)
00036   {
00037     __f = _x._ann.end();
00038     for(__y = _x._ann.begin(); __y != __f; ++__y)
00039     {
00040       if(*__x == *__y)
00041       {
00042         _x._ann.erase(__y);
00043         rmd.push_back(*__x);
00044         break;
00045       }
00046     }
00047   }
00048   _x._ann.insert(_x._ann.end(), add.begin(), add.end());
00049   _u = (undelta_base *) new annotation_undelta(add, rmd);
00050   return true;
00051 }
00052 
00053 bool annotation_undelta::unapply(work_node& _x) const
00054 {
00055   std::vector<annotation>::const_iterator __x, __e(added_ann.end());
00056   std::vector<annotation>::iterator __y, __f;
00057   for(__x = added_ann.begin(); __x != __e; ++__x)
00058   {
00059     __f = _x._ann.end();
00060     for(__y = _x._ann.begin(); __y != __f; ++__y)
00061     {
00062       if(*__x == *__y)
00063       {
00064         _x._ann.erase(__y);
00065         break;
00066       }
00067     }
00068   }
00069   _x._ann.insert(_x._ann.end(), removed_ann.begin(), removed_ann.end());
00070   return true;
00071 }
00072 

Generated on Tue Nov 4 01:57:56 2003 for COCONUT API by doxygen1.2.18