rdbxx  1.0.7_02
RDBColumnTmplt.h
1 #ifndef RDBColumnTmplt_h
2 #define RDBColumnTmplt_h
3 
4 /* --8<--8<--8<--8<--
5  *
6  * Copyright (C) 2006 Smithsonian Astrophysical Observatory
7  *
8  * This file is part of RDB
9  *
10  * RDB is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * RDB is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the
22  * Free Software Foundation, Inc.
23  * 51 Franklin Street, Fifth Floor
24  * Boston, MA 02110-1301, USA
25  *
26  * -->8-->8-->8-->8-- */
27 
28 #include <sstream>
29 #include <string>
30 #include <utility>
31 
32 #include <rdbxx/RDBColumn.h>
33 
34 using namespace std;
35 
37 template <class Tmplt0, class Tmplt1, class Tmplt2>
38 class RDBColumnTmplt : public RDBColumn {
39  public:
41 
42  RDBColumnTmplt( const string& name="", const string& def="" );
47  ~RDBColumnTmplt( void );
48 
50  RDBColumn& operator=( const RDBColumnTmplt<Tmplt0,Tmplt1,Tmplt2>& rdbcolumntmplt );
52  virtual RDBColumn& operator=( const Tmplt0& data );
54  virtual RDBColumn& operator=( const Tmplt1& data );
56  virtual RDBColumn& operator=( const Tmplt2& data );
58 
60 
61  virtual void advanceIdx( void );
64  virtual void rewind( void );
66 
68 
69  virtual void setGroup( bool group );
71  virtual void setGroupValue( void );
73  virtual int newGroup( void );
75 
77 
78  virtual bool setData( const Tmplt0& data );
81  virtual bool setData( const Tmplt1& data );
83  virtual bool setData( const Tmplt2& data );
85 
87 
88  virtual void mapData( Tmplt0 data[], const size_t nelems );
91 
92 
94 
95  void* getData( void );
98  virtual bool getData( Tmplt0& data );
100  virtual bool getData( Tmplt1& data );
102  virtual bool getData( Tmplt2& data );
104  virtual double getDataDouble( void );
106  virtual long getDataLong( void );
108  virtual string getDataString( void );
110 
111  protected:
113  virtual istream& read( istream& is );
115  virtual ostream& write( ostream& os ) const;
117  void cleanup( void );
118 
120  Tmplt0* _data;
122  size_t _idx;
124  size_t _nelems;
126  bool _mine;
127 
129  Tmplt0 _groupvalue;
130 
131 };
132 
133 #ifndef RDBColumnTmplt_cc
134 #include <rdbxx/RDBColumnTmplt.cc>
135 #endif
136 
137 
144 
145 #endif
Tmplt0 * _data
Pointer to the data managed by object.
bool _mine
Indicates that RDBColumnTmplt is responsible for deallocating the data.
size_t _idx
Index into the data.
Tmplt0 _groupvalue
Current group value.
size_t _nelems
Number of elements of data.
Parameterizes RDBColumn interface for many data types.
Provides interface for general column related methods.
Definition: RDBColumn.h:43