00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00031 #ifndef __VDBL_COL_H
00032 #define __VDBL_COL_H
00033
00034 #include <stddef.h>
00035 #include <typeinfo>
00036 #include <iostream>
00037 #include <vdbl_config.h>
00038 #include <vdbl_types.h>
00039 #include <vdbl_context.h>
00040 #include <vdbl_alltype.h>
00041
00042 __VDBL_BEGIN_NAMESPACE
00043
00044 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00045 #pragma set woff 1209
00046 #endif
00047
00054 template <class _TC>
00055 inline std::ostream& print_it(std::ostream& o, const _TC& t)
00056 {
00057 return o << t;
00058 }
00059
00060
00061 class _VDBL_row;
00062 class row;
00063
00065
00073 class __VDBL_colbase
00074 {
00075 public:
00077
00080 __VDBL_colbase() {}
00081 __VDBL_colbase(const __VDBL_colbase& __v) {}
00082 virtual ~__VDBL_colbase() {}
00084
00088 virtual __VDBL_colbase* new_copy() const VDBL_PURE_VIRTUAL
00089
00093 virtual void setcontext(const context* _c, const _VDBL_row* _r) VDBL_PURE_VIRTUAL
00094
00100 virtual void get_copy(_VDBL_alltype_base*& c) const VDBL_PURE_VIRTUAL
00101
00105 virtual void def_copy(_VDBL_alltype_base*& d) const VDBL_PURE_VIRTUAL
00106
00111 virtual const std::type_info& return_type_id() const VDBL_PURE_VIRTUAL
00112
00117 virtual std::ostream& print_contents(std::ostream& o) const VDBL_PURE_VIRTUAL
00118 };
00119
00121
00131 template <class _TR>
00132 class _VDBL_colbase : public __VDBL_colbase
00133 {
00134 public:
00136 typedef _TR return_type;
00137 typedef _VDBL_colbase<_TR> _Self;
00138 typedef __VDBL_colbase _Base;
00139
00141
00144 _VDBL_colbase() {}
00145 _VDBL_colbase(const _Self& __c) {}
00146 virtual ~_VDBL_colbase() {}
00148
00152 virtual _Self* new_copy() const VDBL_PURE_VIRTUAL
00153
00157 virtual void setcontext(const context* _c, const _VDBL_row* _r) VDBL_PURE_VIRTUAL
00158
00162 virtual void get(return_type& c) const VDBL_PURE_VIRTUAL
00163
00167 virtual void def(return_type& d) const VDBL_PURE_VIRTUAL
00168
00173 virtual void get_ptr(return_type const *& c) const VDBL_PURE_VIRTUAL
00174
00180 virtual void get_copy(return_type*& c) const
00181 { c = new return_type(); get(*c); }
00182
00188 virtual void def_copy(return_type*& d) const
00189 { d = new return_type(); def(*d); }
00190
00197 virtual void get_copy(_VDBL_alltype_base*& v) const
00198 {
00199 return_type *c = new return_type();
00200 get(*c);
00201 v = (_VDBL_alltype_base *) new _VDBL_alltype<return_type>(c);
00202 }
00203
00210 virtual void def_copy(_VDBL_alltype_base*& v) const
00211 {
00212 return_type *d = new return_type();
00213 def(*d);
00214 v = (_VDBL_alltype_base *) new _VDBL_alltype<return_type>(d);
00215 }
00216
00221 virtual const std::type_info& return_type_id() const
00222 { return typeid(return_type); }
00223
00228 virtual std::ostream& print_contents(std::ostream& o) const { return o; }
00229 };
00230
00232
00242 class _VDBL_col
00243 {
00244 private:
00248 __VDBL_colbase* _C_p;
00249
00250 public:
00252 _VDBL_col() : _C_p(NULL) {}
00254 _VDBL_col(const _VDBL_col& __c);
00261 explicit _VDBL_col(__VDBL_colbase* __p) : _C_p(__p) {}
00262
00268 template <class _RR>
00269 explicit _VDBL_col(const _RR& _c);
00270
00272 virtual ~_VDBL_col();
00273
00275 void setcontext(const context* _c, const _VDBL_row* _r);
00276
00284 template <class _TR>
00285 void set(_VDBL_colbase<_TR>* _p) { _C_p = (__VDBL_colbase*)_p; }
00286
00290 template <class _TR>
00291 void get(_TR& c) const;
00292
00296 template <class _TR>
00297 void def(_TR& d) const;
00298
00303 template <class _TR>
00304 void get_ptr(_TR const *& c) const;
00305
00311 template <class _TR>
00312 void get_copy(_TR*& p) const;
00313
00319 template <class _TR>
00320 void def_copy(_TR*& p) const;
00321
00328 void get_copy(_VDBL_alltype_base*& v) const;
00329
00336 void def_copy(_VDBL_alltype_base*& d) const;
00337
00342 const std::type_info& return_type_id() const
00343 { return _C_p->return_type_id(); }
00344
00349 const __VDBL_colbase* get_ptr_to_val() const
00350 { return _C_p; }
00351
00357 friend std::ostream& operator<<(std::ostream& o, const _VDBL_col& c);
00358 };
00359
00360 inline std::ostream& operator<<(std::ostream& o, const _VDBL_col& c)
00361 {
00362 return c._C_p->print_contents(o);
00363 }
00364
00365 template <class _RR>
00366 inline _VDBL_col::_VDBL_col(const _RR& _c)
00367 { _C_p = (__VDBL_colbase*)(((__VDBL_colbase*)(&_c))->new_copy()); }
00368
00369 inline _VDBL_col::_VDBL_col(const _VDBL_col& __c)
00370 { _C_p = __c._C_p ? __c._C_p->new_copy() : NULL; }
00371
00372 inline _VDBL_col::~_VDBL_col() { delete _C_p; }
00373
00374 inline void _VDBL_col::setcontext(const context* _c, const _VDBL_row* _r) { _C_p->setcontext(_c, _r); }
00375
00376 template <class _TR>
00377 inline void _VDBL_col::get(_TR& c) const { ((_VDBL_colbase<_TR>*)_C_p)->get(c); }
00378
00379 template <class _TR>
00380 inline void _VDBL_col::def(_TR& c) const { ((_VDBL_colbase<_TR>*)_C_p)->def(c); }
00381
00382 template <class _TR>
00383 inline void _VDBL_col::get_ptr(_TR const *& c) const
00384 { ((_VDBL_colbase<_TR>*)_C_p)->get_ptr(c); }
00385
00386 template <class _TR>
00387 inline void _VDBL_col::get_copy(_TR*& c) const
00388 { ((_VDBL_colbase<_TR>*)_C_p)->get_copy(c); }
00389
00390 template <class _TR>
00391 inline void _VDBL_col::def_copy(_TR*& c) const
00392 { ((_VDBL_colbase<_TR>*)_C_p)->def_copy(c); }
00393
00394 inline void _VDBL_col::get_copy(_VDBL_alltype_base*& v) const
00395 { _C_p->get_copy(v); }
00396
00397 inline void _VDBL_col::def_copy(_VDBL_alltype_base*& v) const
00398 { _C_p->def_copy(v); }
00399
00401
00405 template <class _TT>
00406 class _VDBL_stdcol : public _VDBL_colbase<_TT>
00407 {
00408 private:
00409 typedef _VDBL_colbase<_TT> _Base;
00410 typedef _VDBL_stdcol<_TT> _Self;
00411
00412 typedef typename _Base::return_type return_type;
00413
00414 typedef _TT type;
00415
00416 type _C_t;
00417
00418 public:
00420
00423 _VDBL_stdcol() : _Base(), _C_t() {}
00424 _VDBL_stdcol(const _Self& __c) : _Base(__c), _C_t(__c._C_t) {}
00425 virtual ~_VDBL_stdcol() {}
00427
00431 _VDBL_stdcol(const type& __t) : _Base(), _C_t(__t) {}
00432
00433 _Self* new_copy() const { return new _Self(*this); }
00434
00438 void set(const _Self& _p) { _C_t = _p._C_t; }
00439
00444 void setcontext(const context* _c, const _VDBL_row* _r) {}
00445
00446 void get(type& c) const { c = _C_t; }
00447
00454 void def(type& d) const { d = _C_t; }
00455
00456 void get_ptr(type const *& c) const { c = &_C_t; }
00457
00458 void get_copy(return_type*& c) const { c = new return_type(_C_t); }
00459
00460 void def_copy(return_type*& d) const { d = new return_type(_C_t); }
00461
00462 void get_copy(_VDBL_alltype_base*& v) const
00463 {
00464 return_type *c;
00465 get_copy(c);
00466 v = (_VDBL_alltype_base *) new _VDBL_alltype<return_type>(c);
00467 }
00468
00469 void def_copy(_VDBL_alltype_base*& v) const
00470 {
00471 return_type *d;
00472 def_copy(d);
00473 v = (_VDBL_alltype_base *) new _VDBL_alltype<return_type>(d);
00474 }
00475
00479 void set(const type& __t) { _C_t = __t; }
00480
00486 void set_default(const type& __t) { _C_t = __t; }
00487
00491 const type& get_val() const { return _C_t; }
00492
00493 std::ostream& print_contents(std::ostream& o) const { return o << _C_t; }
00494 };
00495
00497
00504 template <class _TC, class _TM, class _TR>
00505 class _VDBL_mthdcol : public _VDBL_colbase<_TR>
00506 {
00507 private:
00508 typedef _VDBL_colbase<_TR> _Base;
00509 typedef _VDBL_mthdcol<_TC,_TM,_TR> _Self;
00510
00511 typedef typename _Base::return_type return_type;
00512
00513 typedef _TM method;
00514 typedef _TR type;
00515 typedef _TC real_context;
00516
00517 method _C_m;
00518
00519 public:
00521
00524 _VDBL_mthdcol() : _Base(), _C_m() {}
00525 _VDBL_mthdcol(const _Self& __c) : _Base(__c), _C_m(__c._C_m) {}
00526 virtual ~_VDBL_mthdcol() {}
00528
00532 _VDBL_mthdcol(const method& __m) : _Base(), _C_m(__m) {}
00533
00534 _Self* new_copy() const { return new _Self(*this); }
00535
00540 virtual void setcontext(const context* _c, const _VDBL_row* _r)
00541 { _C_m.setcontext((real_context*)_c, (const row*) _r); }
00542
00543 void get(type& c) const
00545 { c = _C_m(); }
00546
00547 void get_ptr(type const *& c) const
00549 { c = NULL; }
00550
00551 void def(type& d) const
00553 { d = _C_m.def(); }
00554
00555 void get_copy(return_type*& c) const
00556 { c = new return_type(_C_m()); }
00557
00558 void def_copy(return_type*& d) const
00559 { d = new return_type(_C_m.def()); }
00560
00561 std::ostream& print_contents(std::ostream& o) const { return o << _C_m(); }
00562 };
00563
00565
00569 typedef _VDBL_col col;
00570
00572
00576 typedef _VDBL_stdcol<mixtype> standard_col;
00577
00579
00583 template <class _TR>
00584 class col_base : public _VDBL_colbase<_TR>
00585 {
00586 public:
00587 typedef _TR return_type;
00588 };
00589
00591
00596 template <class _TT>
00597 class typed_col : public _VDBL_stdcol<_TT>
00598 {
00599 private:
00600 typedef _VDBL_stdcol<_TT> _Base;
00601 typedef typed_col<_TT> _Self;
00602 public:
00603 typedef _TT type;
00604 typedef _TT return_type;
00605
00606 typed_col() : _Base() {}
00607 typed_col(const _TT& __t) : _Base(__t) {}
00608 typed_col(const _Self& __t) : _Base(__t) {}
00609
00610 virtual ~typed_col() {}
00611 };
00612
00614
00629 template <class _TM>
00630 class method_col : public _VDBL_mthdcol<typename _TM::context, _TM,
00631 typename _TM::return_type>
00632 {
00633 private:
00634 typedef _VDBL_mthdcol<typename _TM::context, _TM, typename _TM::return_type>
00635 _Base;
00636 typedef method_col<_TM> _Self;
00637
00638 public:
00639 typedef _TM method;
00640 typedef typename _TM::return_type return_type;
00641 typedef typename _TM::context context;
00642
00643 method_col() : _Base() {}
00644 method_col(const _Self& __m) : _Base(__m) {}
00645 method_col(const method& __m) : _Base(__m) {}
00646
00647 virtual ~method_col() {}
00648 };
00649
00650 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00651 #pragma reset woff 1209
00652 #endif
00653
00654 __VDBL_END_NAMESPACE
00655
00656 #endif
00657
00658
00659
00660