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

table_delta.cc

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 #include <table_delta.h>
00028 #include <annotation_delta.h>
00029 
00030 bool table_delta::apply(work_node& _x, undelta_base*& _u) const
00031 {
00032   std::cerr << "Cannot directly apply a table_delta: convert missing!" <<
00033         std::endl;
00034   return false;
00035 }
00036 
00037 void table_delta::convert(work_node& _x, delta_base*& _d)
00038 {
00039   std::vector<annotation> t_add;
00040   for(t_ctr::const_iterator _tl = t_new.begin(); _tl != t_new.end(); ++_tl)
00041   {
00042     const t_line& tl(*_tl);
00043     vdbl::standard_table* ptb = (vdbl::standard_table*)
00044                 _x.get_database_ptr()->get_table(tl.first, _x.get_dbuserid());
00045     if(ptb == NULL)
00046     {
00047       _x.get_database_ptr()->create_table(tl.first, _x.get_dbuserid());
00048       ptb = (vdbl::standard_table*)
00049                 _x.get_database_ptr()->get_table(tl.first, _x.get_dbuserid());
00050       if(ptb == NULL)
00051         throw "Database inconsistency: Programming Error!";
00052       this->create_table(_x, ptb, tl.first);
00053       if(ptb == NULL)
00054         throw "Create table failed: Programming Error!";
00055     }
00056     vdbl::tableid tbi =
00057                _x.get_database_ptr()->get_tableid(tl.first, _x.get_dbuserid());
00058     vdbl::rowid _ri;
00059     if(!ptb->insert_row(tl.second, _ri))
00060       throw "Database inconsistency: Programming error!";
00061     t_add.push_back(annotation(tbi,_ri));
00062   }
00063   _x.keep(t_add);
00064   _d = (delta_base*) new annotation_delta(get_action(), t_add, t_rm);
00065 }
00066 

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