rdbxx  1.0.10
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 
35 template <class Tmplt0, class Tmplt1, class Tmplt2>
36 class RDBColumnTmplt : public RDBColumn {
37  public:
39 
40  RDBColumnTmplt( const std::string& name="", const std::string& def="" );
45  ~RDBColumnTmplt( void );
46 
50  virtual RDBColumn& operator=( const Tmplt0& data );
52  virtual RDBColumn& operator=( const Tmplt1& data );
54  virtual RDBColumn& operator=( const Tmplt2& data );
56 
58 
59  virtual void advanceIdx( void );
62  virtual void rewind( void );
64 
66 
67  virtual void setGroup( bool group );
69  virtual void setGroupValue( void );
71  virtual int newGroup( void );
73 
75 
76  virtual bool setData( const Tmplt0& data );
79  virtual bool setData( const Tmplt1& data );
81  virtual bool setData( const Tmplt2& data );
83 
85 
86  virtual void mapData( Tmplt0 data[], const size_t nelems );
89 
90 
92 
93  void* getData( void );
96  virtual bool getData( Tmplt0& data );
98  virtual bool getData( Tmplt1& data );
100  virtual bool getData( Tmplt2& data );
102  virtual double getDataDouble( void );
104  virtual long getDataLong( void );
106  virtual std::string getDataString( void );
108 
109  protected:
111  virtual std::istream& read( std::istream& is );
113  virtual std::ostream& write( std::ostream& os ) const;
115  void cleanup( void );
116 
118  Tmplt0* _data;
120  size_t _idx;
122  size_t _nelems;
124  bool _mine;
125 
127  Tmplt0 _groupvalue;
128 
129 };
130 
131 #ifndef RDBColumnTmplt_cc
132 #include <rdbxx/RDBColumnTmplt.cc>
133 #endif
134 
135 
142 
143 #endif
Tmplt0 * _data
Pointer to the data managed by object.
virtual void mapData(Tmplt0 data[], const size_t nelems)
Maps data to user-supplied memory.
virtual void rewind(void)
Rewinds index to the RDBColumn's data elements.
virtual bool setData(const Tmplt0 &data)
Sets the data value, converting as necessary.
void cleanup(void)
Deletes resources allocated by RDBColumnTmplt object.
bool _mine
Indicates that RDBColumnTmplt is responsible for deallocating the data.
void * getData(void)
Returns a pointer to the current data element.
virtual std::ostream & write(std::ostream &os) const
Called by the stream extraction operator.
virtual std::istream & read(std::istream &is)
Called by the stream insertion operator.
size_t _idx
Index into the data.
~RDBColumnTmplt(void)
Deletes resources allocated by RDBColumnTmplt object.
RDBColumnTmplt(const std::string &name="", const std::string &def="")
Assigns name and definition.
virtual long getDataLong(void)
Returns the value of the current data element, converting if necessary.
virtual double getDataDouble(void)
Returns the value of the current data element, converting if necessary.
RDBColumn & operator=(const RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 > &rdbcolumntmplt)
Copies RDBColumnTmplt object.
Tmplt0 _groupvalue
Current group value.
virtual void setGroup(bool group)
size_t _nelems
Number of elements of data.
virtual std::string getDataString(void)
Returns the value of the current data element, converting if necessary.
virtual void advanceIdx(void)
Increments index to the RDBColumn's data elements.
virtual int newGroup(void)
Returns the group status of this column object.
virtual void setGroupValue(void)
Sets the group value to the current data value.
Parameterizes RDBColumn interface for many data types.
Provides interface for general column related methods.
Definition: RDBColumn.h:41