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

table_delta.h

Go to the documentation of this file.
00001 // Table 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 _TABLE_DELTA_H_
00028 #define _TABLE_DELTA_H_
00029 
00030 #include <api_delta.h>
00031 
00032 class table_delta : public delta_base
00033 {
00034 public:
00035   typedef std::pair<std::string,dbt_row> t_line;
00036   typedef std::vector<t_line> t_ctr;
00037 
00038 private:
00039   t_ctr t_new;
00040   std::vector<annotation> t_rm;
00041 
00042 public:
00043   table_delta(const std::string& a) : delta_base(a), t_new(), t_rm() {}
00044 
00045   table_delta(const std::string& a, const t_ctr& _n,
00046               const std::vector<annotation>& _r) : delta_base(a), t_new(_n),
00047                                                    t_rm(_r) {}
00048 
00049   table_delta(const table_delta& __d) : delta_base(__d), t_new(__d.t_new),
00050                                         t_rm(__d.t_rm)
00051     {
00052 #if DEBUG_DELTA
00053         std::cerr << "Called table_delta copy constructor" << std::endl;
00054 #endif
00055     }
00056   
00057   table_delta(const std::string& a, const std::string& __tn, const dbt_row& __t)
00058                                       : delta_base(a), t_new(), t_rm()
00059     { t_new.push_back(std::make_pair(__tn, __t)); }
00060 
00061   table_delta(const std::string& a, const std::string& __tn,
00062               const std::vector<dbt_row>& __t)
00063                                       : delta_base(a), t_new(), t_rm()
00064     { t_new.reserve(__t.size());
00065       for(std::vector<dbt_row>::const_iterator __x = __t.begin();
00066           __x != __t.end(); ++__x)
00067         t_new.push_back(std::make_pair(__tn, *__x));
00068     }
00069 
00070   void add(const t_line& _tl) { t_new.push_back(_tl); }
00071   void add(const std::string& _tn, const dbt_row& _r)
00072         { add(std::make_pair(_tn, _r)); }
00073   void add(const std::vector<t_line>& _tlv)
00074         { t_new.insert(t_new.end(), _tlv.begin(), _tlv.end()); }
00075   void rm(const annotation& _tr) { t_rm.push_back(_tr); }
00076   void rm(const std::vector<annotation>& _trv)
00077         { t_rm.insert(t_rm.end(), _trv.begin(), _trv.end()); }
00078 
00079   virtual table_delta* new_copy() const { return new table_delta(*this); }
00080 
00081   virtual void destroy_copy(table_delta* __d) { delete __d; }
00082 
00083   virtual void create_table(work_node& _x, vdbl::standard_table*& ptb,
00084                             const std::string& __t) const {};
00085 
00086   virtual bool apply(work_node& _x, undelta_base*& _u) const;
00087 
00088   void convert(work_node& _x, delta_base*& _u);
00089 };
00090 
00091 #endif /* _TABLE_DELTA_H_ */

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