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

annotation_delta.h

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 #ifndef _ANNOTATION_DELTA_H_
00028 #define _ANNOTATION_DELTA_H_
00029 
00030 #include <api_delta.h>
00031 
00032 class annotation_undelta : public undelta_base
00033 {
00034 public:
00035   std::vector<annotation> added_ann;    // these are the new annotations
00036                                         // originally written
00037   std::vector<annotation> removed_ann;  // these are the annotations
00038                                         // originally removed
00039 public:
00040   annotation_undelta(const std::vector<annotation>& __a,
00041                 const std::vector<annotation>& __r) : undelta_base(),
00042                                                     added_ann(__a),
00043                                                     removed_ann(__r) {}
00044   
00045   annotation_undelta(const std::vector<annotation>& __a) : undelta_base(),
00046                                                         added_ann(__a),
00047                                                         removed_ann() {}
00048   
00049   annotation_undelta(const annotation& __a) : undelta_base(),
00050                                               added_ann(1,__a),
00051                                               removed_ann() {}
00052   
00053   annotation_undelta(const annotation_undelta& __d) : undelta_base(__d),
00054                                             added_ann(__d.added_ann),
00055                                             removed_ann(__d.removed_ann)
00056       {
00057 #if DEBUG_DELTA
00058         std::cerr << "Called annotation_undelta copy constructor" << std::endl;
00059 #endif
00060       }
00061 
00062   annotation_undelta* new_copy() const { return new annotation_undelta(*this); }
00063   void destroy_copy(annotation_undelta* __d) { delete __d; }
00064 
00065   bool unapply(work_node& _x) const;
00066 
00067   friend class annotation_delta;
00068 };
00069 
00070 class annotation_delta : public delta_base
00071 {
00072 public:
00073   std::vector<annotation> add;          // these are to be added
00074   std::vector<annotation> rm;           // these are to be removed
00075 
00076 public:
00077   annotation_delta(const std::string& _act) : delta_base(_act), add(), rm() {}
00078 
00079   annotation_delta(const std::string& _act,
00080                    const std::vector<annotation>& __a,
00081                    const std::vector<annotation>& __r)
00082                 : delta_base(_act), add(__a), rm(__r) {}
00083   
00084   annotation_delta(const std::string& _act, const annotation& _ad)
00085                 : delta_base(_act), add(1,_ad), rm() {}
00086   
00087   annotation_delta(const std::string& _act, bool _dummy, const annotation& _rm)
00088                 : delta_base(_act), add(), rm(1,_rm) {}
00089   
00090   annotation_delta(const annotation_delta& __d)
00091                 : delta_base(__d), add(__d.add), rm(__d.rm)
00092     {
00093 #if DEBUG_DELTA
00094         std::cerr << "Called annotation_delta copy constructor" << std::endl;
00095 #endif
00096     }
00097 
00098   annotation_delta(const char* _act,
00099                    const std::vector<annotation>& __a,
00100                    const std::vector<annotation>& __r)
00101                 : delta_base(_act), add(__a), rm(__r) {}
00102   
00103   annotation_delta(const char* _act, const annotation& _ad)
00104                 : delta_base(_act), add(1,_ad), rm() {}
00105   
00106   annotation_delta(const char* _act, bool _dummy, const annotation& _rm)
00107                 : delta_base(_act), add(), rm(1,_rm) {}
00108   
00109   virtual annotation_delta* new_copy() const
00110                                 { return new annotation_delta(*this); }
00111   virtual void destroy_copy(annotation_delta* __d) { delete __d; }
00112 
00113   virtual bool apply(work_node& _x, undelta_base*& _u) const;
00114 };
00115 
00116 #endif /* _ANNOTATION_DELTA_H_ */

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