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

vdbl_hrview.h

Go to the documentation of this file.
00001 // Hierarchical view implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2003 Hermann Schichl
00004 //
00005 // This file is part of the Vienna Database Library.  This library is free
00006 // 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 
00030 #ifndef __VDBL_HRVIEW_H
00031 #define __VDBL_HRVIEW_H
00032 
00033 #include <iostream>
00034 #include <vdbl_table.h>
00035 #include <vdbl_view.h>
00036 
00037 __VDBL_BEGIN_NAMESPACE
00038 
00039 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00040 #pragma set woff 1209
00041 #endif
00042 
00044 
00048 class _VDBL_hierarchicalview : public _VDBL_view
00049 {
00050 private:
00051   typedef _VDBL_view _Base;
00052   
00054   typedef _VDBL_colid _V_colref;
00056   typedef std::pair<_VDBL_tableid,_VDBL_rowid> _V_rowref;
00058   typedef std::map<_V_rowref, _VDBL_col> _V_colentry;
00060   typedef std::map<_V_colref, _V_colentry> _V_colcache;
00062   typedef std::vector<_V_rowref> _V_rows;
00064   typedef std::vector<_V_colref> _V_cols;
00066   typedef std::map<std::pair<_VDBL_tableid,_VDBL_colid>,_VDBL_colid> _V_colxref;
00068   typedef std::map<_VDBL_tableid,std::pair<_VDBL_table *,unsigned int> > _V_tref;
00069   
00070 private:
00072   std::vector<_VDBL_tableid> _V_th;
00074   _V_tref _V_t;
00076   const _VDBL_context* _V_ctx;
00077 
00079   _V_colcache _V_cc;
00080 
00081 protected:
00085   _V_rows _V_r;
00089   _V_cols _V_c;
00093   _V_colxref _V_cx;
00094 
00095 private:
00097   std::map<std::string,_V_colref> _V_colnames;
00098 
00099   friend class _VDBL_table;
00100 
00101 public:
00102   typedef _Base::default_const_iterator defaults_const_iterator;
00103 
00104 private:
00106   _VDBL_tableid get_master_table_id() const
00107   {
00108     std::vector<_VDBL_tableid>::const_iterator _e = _V_th.end();
00109     return *(--_e);
00110   }
00111 
00113   _VDBL_table* get_table(const _VDBL_tableid& _ti) const
00114   {
00115     _V_tref::const_iterator _tr(_V_t.find(_ti));
00116     if(_tr == _V_t.end())
00117       return NULL;
00118     return (*_tr).second.first;
00119   }
00120 
00122   _VDBL_table* get_master_table() const
00123   {
00124     std::vector<_VDBL_tableid>::const_iterator _e = _V_th.end();
00125     _V_tref::const_iterator _tr(_V_t.find(*(--_e)));
00126     if(_tr == _V_t.end())
00127     {
00128       std::cerr << "Error: hierarchical view is corrupted!" << std::endl;
00129       throw "Programming Error";
00130     }
00131     return (*_tr).second.first;
00132   }
00133 
00140   std::pair<_VDBL_tableid,_VDBL_colid> _find_def(const _VDBL_colid& _c) const
00141   {
00142     std::vector<_VDBL_tableid>::const_iterator _x, _e(_V_th.end());
00143     for(_x = _V_th.begin(); _x != _e; ++_x)
00144     {
00145       _V_colxref::const_iterator _cy(_V_cx.find(std::make_pair(*_x,_c)));
00146       if(_cy != _V_cx.end())
00147       {
00148         _VDBL_table* _tp = get_table(*_x);
00149         if(_tp && _tp->has_def((*_cy).second))
00150           return std::make_pair(*_x,(*_cy).second);
00151       }
00152     }
00153     return std::make_pair(0,0);
00154   }
00155 
00161   std::pair<_VDBL_tableid,_VDBL_colid> _find_col(const _VDBL_rowid& _r,
00162                                                  const _VDBL_colid& _c) const
00163   {
00164     std::vector<_VDBL_tableid>::const_iterator _x, _e(_V_th.end());
00165     for(_x = _V_th.begin(); _x != _e; ++_x)
00166     {
00167       _V_colxref::const_iterator _cy(_V_cx.find(std::make_pair(*_x,_c)));
00168       if(_cy != _V_cx.end())
00169       {
00170         _VDBL_table* _tp = get_table(*_x);
00171         if(_tp && _tp->has_col(_r,(*_cy).second))
00172           return std::make_pair(*_x,(*_cy).second);
00173       }
00174     }
00175     return _find_def(_c);
00176   }
00177   
00178 protected:
00179   triple<_VDBL_tableid,_VDBL_colid,void*>
00180         _next_def_col(const _VDBL_tableid& _t, const _VDBL_colid& _c,
00181                       void *_d) const
00182     {
00183       _V_cols::const_iterator& _cit(*(_V_cols::const_iterator*)_d);
00184       std::pair<_VDBL_tableid,_VDBL_colid> _tc(0,0);
00185       if(_t == 0 && _c == 0) // end
00186         return make_triple(0,0,_d);
00187       ++_cit;
00188       while(_cit != _V_c.end())
00189       {
00190         _tc = _find_def(*_cit);
00191         if(_tc.first != 0)
00192           break;
00193         ++_cit;
00194       }
00195       if(_cit == _V_c.end())
00196         return make_triple(0,0,_d);
00197       else
00198         return make_triple(_tc.first,_tc.second,_d);
00199     }
00200 
00201   triple<_VDBL_tableid,_VDBL_colid,void*>
00202         _prev_def_col(const _VDBL_tableid& _t, const _VDBL_colid& _c,
00203                       void *_d) const
00204     {
00205       _V_cols::const_iterator& _cit(*(_V_cols::const_iterator*)_d);
00206       std::pair<_VDBL_tableid,_VDBL_colid> _tc(0,0);
00207       if(_t == 0 && _c == 0) // end
00208         _cit = _V_c.end();
00209       --_cit;
00210       while(_cit != _V_c.begin())
00211       {
00212         _tc = _find_def(*_cit);
00213         if(_tc.first != 0)
00214           break;
00215         --_cit;
00216       }
00217       if(_cit == _V_c.begin())
00218       {
00219         _tc = _find_def(*_cit);
00220         if(_tc.first == 0)
00221           return make_triple(0,0,_d);
00222       }
00223       if(_cit == _V_c.end())
00224         return make_triple(0,0,_d);
00225       else
00226         return make_triple(_tc.first,_tc.second,_d);
00227     }
00228 
00229   void _destroy_def_data(void *&_d) const
00230     { delete (_V_cols::const_iterator*)_d; }
00231   
00232   void* _copy_def_data(void *_d) const
00233     { return (void*)
00234         new _V_cols::const_iterator(*(_V_cols::const_iterator*)_d); }
00235   
00236   triple<_VDBL_tableid,_VDBL_colid,void*>
00237         _next_col(const _VDBL_tableid& _t, const _VDBL_rowid& _r,
00238                   const _VDBL_colid& _c, void *_d) const
00239     {
00240       _V_cols::const_iterator& _cit(*(_V_cols::const_iterator*)_d);
00241       std::pair<_VDBL_tableid,_VDBL_colid> _tc(0,0);
00242       if(_t == 0 && _c == 0) // end
00243         return make_triple(0,0,_d);
00244       ++_cit;
00245       while(_cit != _V_c.end())
00246       {
00247         _tc = _find_col(_r,*_cit);
00248         if(_tc.first != 0)
00249           break;
00250         ++_cit;
00251       }
00252       if(_cit == _V_c.end())
00253         return make_triple(0,0,_d);
00254       else
00255         return make_triple(_tc.first,_tc.second,_d);
00256     }
00257 
00258   triple<_VDBL_tableid,_VDBL_colid,void*>
00259         _prev_col(const _VDBL_tableid& _t, const _VDBL_rowid& _r,
00260                   const _VDBL_colid& _c, void *_d) const
00261     {
00262       _V_cols::const_iterator& _cit(*(_V_cols::const_iterator*)_d);
00263       std::pair<_VDBL_tableid,_VDBL_colid> _tc(0,0);
00264       if(_t == 0 && _c == 0) // end
00265         _cit = _V_c.end();
00266       --_cit;
00267       while(_cit != _V_c.begin())
00268       {
00269         _tc = _find_col(_r,*_cit);
00270         if(_tc.first != 0)
00271           break;
00272         --_cit;
00273       }
00274       if(_cit == _V_c.begin())
00275       {
00276         _tc = _find_def(*_cit);
00277         if(_tc.first == 0)
00278            return make_triple(0,0,_d);
00279       }
00280       if(_cit == _V_c.end())
00281         return make_triple(0,0,_d);
00282       else
00283         return make_triple(_tc.first,_tc.second,_d);
00284     }
00285 
00286   void _destroy_col_data(void *&_d) const
00287     { delete (_V_cols::const_iterator*)_d; }
00288   
00289   void* _copy_col_data(void *_d) const
00290     { return (void*)
00291         new _V_cols::const_iterator(*(_V_cols::const_iterator*)_d); }
00292   
00293   triple<_VDBL_tableid,_VDBL_rowid,void*>
00294         _next_row(const _VDBL_tableid& _t, const _VDBL_rowid& _r,
00295                       void *_d) const
00296     {
00297       _V_rows::const_iterator& _rit(*(_V_rows::const_iterator*)_d);
00298       if(_t == 0 && _r == 0) // end
00299         return make_triple(0,0,_d);
00300       ++_rit;
00301       if(_rit == _V_r.end())
00302         return make_triple(0,0,_d);
00303       else
00304         return make_triple((*_rit).first,(*_rit).second,_d);
00305     }
00306 
00307   triple<_VDBL_tableid,_VDBL_rowid,void*>
00308         _prev_row(const _VDBL_tableid& _t, const _VDBL_rowid& _r,
00309                       void *_d) const
00310     {
00311       _V_rows::const_iterator& _rit(*(_V_rows::const_iterator*)_d);
00312       if(_t == 0 && _r == 0) // end
00313         _rit = _V_r.end();
00314       if(_rit == _V_r.begin())
00315         return make_triple(0,0,_d);
00316       --_rit;
00317       if(_rit == _V_r.end())
00318         return make_triple(0,0,_d);
00319       else
00320         return make_triple((*_rit).first,(*_rit).second,_d);
00321     }
00322   
00323   void _destroy_row_data(void *&_d) const
00324     { delete (_V_rows::const_iterator*)_d; }
00325   
00326   void* _copy_row_data(void *_d) const
00327     { return (void*)
00328         new _V_rows::const_iterator(*(_V_rows::const_iterator*)_d); }
00329   
00330 private:
00331   bool _row_visible(const std::pair<_VDBL_tableid,_VDBL_rowid>& _r) const
00332   {
00333     return std::binary_search(_V_r.begin(), _V_r.end(), _r);
00334   }
00335 
00336 public:
00341   _VDBL_hierarchicalview(const _VDBL_tableid& __ti, _VDBL_table* __t,
00342                      const _VDBL_context& __c, _V_enum __en)
00343               : _Base(__en), _V_th(1,__ti), _V_t(), _V_ctx(&__c),
00344                 _V_cc(), _V_r(), _V_c(), _V_cx(), _V_colnames()
00345       {
00346         _V_t.insert(std::make_pair(__ti,
00347                                 std::make_pair(__t,__t->get_change_ctr())));
00348         _VDBL_table::col_const_iterator __x, __e(__t->col_end());
00349         for(__x = __t->col_begin(); __x != __e; ++__x)
00350         {
00351           _V_colnames.insert(*__x);
00352           _V_c.push_back((*__x).second);
00353           _V_cx.insert(std::make_pair(std::make_pair(__ti,(*__x).second),
00354                                         (*__x).second));
00355         }
00356         _VDBL_table::row_const_iterator __y, __f(__t->row_end());
00357         for(__y = __t->row_begin(); __y != __f; ++__y)
00358           _V_r.push_back(std::make_pair(__ti,*__y));
00359         std::sort(_V_r.begin(), _V_r.end());
00360       }
00361 
00368   _VDBL_hierarchicalview(const _VDBL_tableid& __ti, _VDBL_table* __t,
00369                      const _VDBL_context& __c, _V_enum __en,
00370                      const std::vector<_VDBL_rowid>& _rs)
00371               : _Base(__en), _V_th(1,__ti), _V_t(), _V_ctx(&__c),
00372                 _V_cc(), _V_r(), _V_c(), _V_cx(), _V_colnames()
00373       {
00374         _V_t.insert(std::make_pair(__ti,
00375                                 std::make_pair(__t,__t->get_change_ctr())));
00376         _VDBL_table::col_const_iterator __x, __e(__t->col_end());
00377         for(__x = __t->col_begin(); __x != __e; ++__x)
00378         {
00379           _V_colnames.insert(*__x);
00380           _V_c.push_back((*__x).second);
00381           _V_cx.insert(std::make_pair(std::make_pair(__ti,(*__x).second),
00382                                                                 (*__x).second));
00383         }
00384         std::vector<_VDBL_rowid>::const_iterator __y, __f(_rs.end());
00385         _V_r.reserve(_rs.size());
00386         for(__y = _rs.begin(); __y != __f; ++__y)
00387           _V_r.push_back(std::make_pair(__ti,*__y));
00388         std::sort(_V_r.begin(), _V_r.end());
00389       }
00390 
00394   _VDBL_hierarchicalview(const _VDBL_hierarchicalview& __v)
00395                 : _Base(__v), _V_th(__v._V_th), _V_t(__v._V_t),
00396                   _V_ctx(__v._V_ctx), _V_cc(__v._V_cc), _V_r(__v._V_r),
00397                   _V_c(__v._V_c), _V_cx(__v._V_cx), _V_colnames(__v._V_colnames)
00398       {}
00399 
00403   virtual ~_VDBL_hierarchicalview() {}
00404 
00408   void push_table(const _VDBL_tableid& __ti, _VDBL_table* __t)
00409   {
00410     _V_th.insert(_V_th.begin(), __ti);
00411     _V_t.insert(std::make_pair(__ti,std::make_pair(__t,__t->get_change_ctr())));
00412     _VDBL_table::col_const_iterator __x, __e(__t->col_end());
00413     for(__x = __t->col_begin(); __x != __e; ++__x)
00414     {
00415       std::map<std::string,_V_colref>::iterator
00416                                          _ccr(_V_colnames.find((*__x).first));
00417       if(_ccr == _V_colnames.end())
00418         continue;
00419       _V_cx.insert(std::make_pair(std::make_pair(__ti,(*__x).second),
00420                                                               (*_ccr).second));
00421     }
00422     _VDBL_table::row_const_iterator __y, __f(__t->row_end());
00423     for(__y = __t->row_begin(); __y != __f; ++__y)
00424       _V_r.push_back(std::make_pair(__ti,*__y));
00425     std::sort(_V_r.begin(), _V_r.end());
00426   }
00427 
00433   void push_table(const _VDBL_tableid& __ti, _VDBL_table* __t,
00434                  const std::vector<_VDBL_rowid>& _rs)
00435   {
00436     _V_th.insert(_V_th.begin(), __ti);
00437     _V_t.insert(std::make_pair(__ti,std::make_pair(__t,__t->get_change_ctr())));
00438     _VDBL_table::col_const_iterator __x, __e(__t->col_end());
00439     for(__x = __t->col_begin(); __x != __e; ++__x)
00440     {
00441       std::map<std::string,_V_colref>::iterator
00442                                          _ccr(_V_colnames.find((*__x).first));
00443       if(_ccr == _V_colnames.end())
00444         continue;
00445       _V_cx.insert(std::make_pair(std::make_pair(__ti,(*__x).second),
00446                                                             (*_ccr).second));
00447     }
00448     std::vector<_VDBL_rowid>::const_iterator __y, __f(_rs.end());
00449     _V_r.reserve(_rs.size()+_V_r.size());
00450     for(__y = _rs.begin(); __y != __f; ++__y)
00451       _V_r.push_back(std::make_pair(__ti,*__y));
00452     std::sort(_V_r.begin(), _V_r.end());
00453   }
00454 
00458   _VDBL_tableid pop_table()
00459   {
00460     if(_V_th.empty())
00461       return _VDBL_tableid();
00462     _VDBL_tableid ti(*_V_th.begin());
00463     _V_th.erase(_V_th.begin());
00464     _V_tref::iterator _tri(_V_t.find(ti));
00465     if(_tri != _V_t.end())
00466       _V_t.erase(_tri);
00467     std::vector<int> erase_r;
00468     unsigned int j(0);
00469     for(unsigned int i = 0; i < _V_r.size(); ++i)
00470     {
00471       if(_V_r[i].first == ti)
00472         ++j;
00473       else if(j > 0)
00474         _V_r[i-j] = _V_r[i];
00475     }
00476     _V_r.erase(_V_r.end()-j, _V_r.end());
00477     for(_V_colxref::iterator __x = _V_colxref.begin(); __x != _V_colxref.end();
00478         ++__x)
00479     {
00480       if((*__x).first.first == ti)
00481         _V_colxref.erase(__x);
00482     }
00483     return ti;
00484   }
00485 
00486 public:
00487   const std::type_info& get_colinfo(const std::string& _C_n,
00488                 triple<bool,_VDBL_colid,_VDBL_colflags>& _r) const
00489   {
00490     std::map<std::string,_V_colref>::const_iterator __x(_V_colnames.find(_C_n));
00491     if(__x == _V_colnames.end())
00492     {
00493       _r = make_triple(false, _VDBL_colid(), _VDBL_colflags());
00494       return typeid(void);
00495     }
00496     return get_master_table()->get_colinfo(_C_n, _r);
00497   }
00498 
00499   bool insert(const std::vector<_T_colspec>& _row)
00500   {
00501     if(view_type() != V_window)
00502       return false;
00505     _V_rowref _ri;
00506     std::vector<std::pair<const std::string*,const _VDBL_col*> > _v;
00507     _v.reserve(_row.size());
00508     for(std::vector<_T_colspec>::const_iterator _x = _row.begin();
00509         _x != _row.end(); ++_x)
00510       _v.push_back(std::make_pair(&(*_x).first,&(*_x).second));
00511     _ri.first = *_V_th.begin();
00512     _VDBL_table* _tp = get_table(_ri.first);
00513     if(!_tp) return false;
00514     bool ret = _tp->insert(_v, _ri.second);
00515     _V_r.insert(std::upper_bound(_V_r.begin(), _V_r.end(), _ri), _ri);
00516     return ret;
00517   }
00518 
00519   bool remove(std::pair<_VDBL_tableid,_VDBL_rowid> _r)
00520   {
00521     if(!_row_visible(_r))
00522       return false;
00523     if(view_type() != V_window)
00524       return false;
00525     _VDBL_table* _tp = get_table(_r.first);
00526     if(!_tp) return false;
00527     return _tp->remove(_r.second);
00528   }
00529 
00530   bool has_col(const std::string& _C_n) const
00531   {
00532     std::map<std::string,_V_colref>::const_iterator __x(_V_colnames.find(_C_n));
00533     return __x != _V_colnames.end();
00534   }
00535 
00536   std::pair<_VDBL_tableid,_VDBL_colid> get_col_id(const std::string& _C_n) const
00537   {
00538     std::map<std::string,_V_colref>::const_iterator __x(_V_colnames.find(_C_n));
00539     if(__x == _V_colnames.end())
00540       return std::make_pair(_VDBL_tableid(),_VDBL_colid());
00541     return std::make_pair(get_master_table_id(),(*__x).second);
00542   }
00543 
00544   const _VDBL_row& get_row(const std::pair<_VDBL_tableid,_VDBL_rowid>& _ri,
00545                            bool& error) const
00546   {
00547     if(!_row_visible(_ri))
00548     {
00549       error = true;
00550       return ___empty_row_return;
00551     }
00552     _VDBL_table* _tp = get_table(_ri.first);
00553     if(!_tp)
00554     {
00555       error = true;
00556       return ___empty_row_return;
00557     }
00558     return _tp->get_row(_ri.second, error);
00559   }
00560  
00561   const _VDBL_col& get_raw_col(const std::pair<_VDBL_tableid,_VDBL_rowid>& _ri,
00562                            const _VDBL_colid& _ci, _VDBL_row const *& _rr,
00563                            bool& error) const
00564   {
00565     if(!_row_visible(_ri))
00566     {
00567       error = true;
00568       return ___empty_col_return;
00569     }
00570     _VDBL_table* _tp = get_table(_ri.first);
00571     if(!_tp)
00572     {
00573       error = true;
00574       return ___empty_col_return;
00575     }
00576     const _VDBL_row& _r(_tp->get_row(_ri.second, error));
00577     if(error)
00578       return ___empty_col_return;
00579     _rr = &_r;
00580     const _VDBL_col& _c(_r.get_col(_ci, error));
00581     if(error)
00582     {
00583       std::pair<_VDBL_tableid,_VDBL_colid> _tc = _find_def(_ci);
00584       if(_tc.first == 0)
00585         return ___empty_col_return;
00586       _tp = get_table(_tc.first);
00587       if(!_tp)
00588         return ___empty_col_return;
00589       return _tp->get_def(_ci, error);
00590     }
00591     else
00592       return _c;
00593   }                                             
00594 
00599   std::ostream& print_col(std::ostream& o,
00600                           const std::pair<_VDBL_tableid,_VDBL_rowid>& _ri,
00601                           const _VDBL_colid& _ci, bool& printed) const
00602   {
00603     bool error;
00604     const _VDBL_row* _rr;
00605     vdbl::col c(get_raw_col(_ri, _ci, _rr, error));
00606     if(error)
00607     {
00608       printed = false;
00609       return o;
00610     }
00611     printed = true;
00612     c.setcontext(_V_ctx, _rr);
00613     return o << c;
00614   }
00615  
00624   template <class _R>
00625   bool get_raw_ptr(const std::pair<_VDBL_tableid,_VDBL_rowid>& _ri,
00626                    const _VDBL_colid& _ci, _R const *& r) const
00627   {
00628     bool error;
00629     const _VDBL_row *_rr;
00630     vdbl::col c(get_raw_col(_ri, _ci, _rr, error));
00631     if(error)
00632       return false;
00633     c.setcontext(_V_ctx, _rr);
00634     c.get_ptr(r);
00635     return true;
00636   }
00637  
00643   template <class _R>
00644   bool get(const std::pair<_VDBL_tableid,_VDBL_rowid>& _ri,
00645                                  const _VDBL_colid& _ci, _R& r) const
00646   {
00647     bool error;
00648     const _VDBL_row *_rr;
00649     vdbl::col c(get_raw_col(_ri, _ci, _rr, error));
00650     if(error)
00651       return false;
00652     c.setcontext(_V_ctx, _rr);
00653     c.get(r);
00654     return true;
00655   }
00656  
00657   const _VDBL_col& get_def(const std::pair<_VDBL_tableid,_VDBL_colid>& _ri,
00658                            bool& error) const
00659   { return get_table(_ri.first)->get_def(_ri.second, error); }
00660 
00661   default_const_iterator defaults_begin() const
00662   {
00663     _V_cols::const_iterator* _rit = new _V_cols::const_iterator(_V_c.begin());
00664     std::pair<_VDBL_tableid,_VDBL_colid> _tc(0,0);
00665     while(*_rit != _V_c.end())
00666     {
00667       _tc = _find_def(**_rit);
00668       if(_tc.first != 0)
00669         break;
00670       ++*_rit;
00671     }
00672     if(*_rit == _V_c.end())
00673       return default_const_iterator(this,0,0,(void*)_rit);
00674     return default_const_iterator(this,_tc.first,**_rit,(void*)_rit);
00675   }
00676 
00677   default_const_iterator defaults_end() const
00678   {
00679     _V_cols::const_iterator* _rit = new _V_cols::const_iterator(_V_c.begin());
00680     return default_const_iterator(this,0,0,(void*)_rit);
00681   }
00682 
00683   col_const_iterator cols_begin(const _VDBL_rowid& _r) const
00684   {
00685     _V_cols::const_iterator* _rit = new _V_cols::const_iterator(_V_c.begin());
00686     std::pair<_VDBL_tableid,_VDBL_colid> _tc(0,0);
00687     while(*_rit != _V_c.end())
00688     {
00689       _tc = _find_col(_r,**_rit);
00690       if(_tc.first != 0)
00691         break;
00692       ++*_rit;
00693     }
00694     if(*_rit == _V_c.end())
00695       return col_const_iterator(this,0,_r,0,(void*)_rit);
00696     return col_const_iterator(this,_tc.first,_r,**_rit,(void*)_rit);
00697   }
00698 
00699   col_const_iterator cols_end(const _VDBL_rowid& _r) const
00700   {
00701     _V_cols::const_iterator* _rit = new _V_cols::const_iterator(_V_c.begin());
00702     return col_const_iterator(this,0,_r,0,(void*)_rit);
00703   }
00704 
00705   row_const_iterator rows_begin() const
00706   {
00707     _V_rows::const_iterator* _rit = new _V_rows::const_iterator(_V_r.begin());
00708     if(*_rit == _V_r.end())
00709       return row_const_iterator(this,0,0,(void*)_rit);
00710     return row_const_iterator(this,(**_rit).first,(**_rit).second,(void*)_rit);
00711   }
00712 
00713   row_const_iterator rows_end() const
00714   {
00715     _V_rows::const_iterator* _rit = new _V_rows::const_iterator(_V_r.end());
00716     return row_const_iterator(this,0,0,(void*)_rit);
00717   }
00718 };
00719 
00721 
00731 class hierarchical_view : public _VDBL_hierarchicalview
00732 {
00733   typedef _VDBL_hierarchicalview _Base;
00734 
00735 public:
00736   typedef _V_enum view_enum;
00737 
00738 public:
00743   hierarchical_view(const _VDBL_tableid& __ti, _VDBL_table* __t,
00744        const _VDBL_context& __c, _V_enum __e = V_window)
00745                 : _VDBL_hierarchicalview(__ti,__t,__c,__e) {}
00746 
00750   hierarchical_view(const hierarchical_view& _v) : _VDBL_hierarchicalview(_v) {}
00751 
00756   template <class _R>
00757   bool get(const tableid& _ti, const rowid& _ri, const colid& _ci, _R& r) const
00758   { return _Base::get(std::make_pair(_ti, _ri), _ci, r); }
00759 
00766   template <class _R>
00767   bool get_raw_ptr(const tableid& _ti, const rowid& _ri, const colid& _ci,
00768                    _R const *& r) const
00769   { return _Base::get_raw_ptr(std::make_pair(_ti, _ri), _ci, r); }
00770 
00772 
00776   template <class _R>
00777   bool get(const rowid& _ri, const std::string& _c, _R& r) const
00778   { std::pair<tableid,colid> _tci(get_col_id(_c));
00779     return _Base::get(std::make_pair(_tci.first, _ri), _tci.second, r); }
00780 
00781   template <class _R>
00782   bool get(const rowid& _ri, const char* _c, _R& r) const
00783   { return get(_ri, std::string(_c), r); }
00785 };
00786 
00787 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00788 #pragma reset woff 1209
00789 #endif
00790 
00791 __VDBL_END_NAMESPACE
00792 
00793 #endif /* __VDBL_HRVIEW_H */
00794 
00795 // Local Variables:
00796 // mode:C++
00797 // End:

Generated on Tue Nov 4 01:29:11 2003 for Vienna Database Library by doxygen1.2.18