simpleRDBTable.h

00001 #ifndef simpleRDBTable_H
00002 #define simpleRDBTable_H
00003 
00004 /* --8<--8<--8<--8<--
00005  *
00006  * Copyright (C) 2006 Smithsonian Astrophysical Observatory
00007  *
00008  * This file is part of RDB
00009  *
00010  * RDB is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU General Public License
00012  * as published by the Free Software Foundation; either version 2
00013  * of the License, or (at your option) any later version.
00014  *
00015  * RDB is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the 
00022  *       Free Software Foundation, Inc. 
00023  *       51 Franklin Street, Fifth Floor
00024  *       Boston, MA  02110-1301, USA
00025  *
00026  * -->8-->8-->8-->8-- */
00027 
00028 #include <iostream>
00029 
00030 using namespace std;
00031 
00032 #include <suplibxx/str.h>
00033 #include <Exception/Exception.h>
00034 
00035 #include <rdbxx/RDBColumn.h>
00036 #include <rdbxx/RDB.h>
00037 
00047 template< class Type >
00048 class simpleRDBTable : public RDB {
00049 
00050   friend ostream& operator << ( ostream& os, simpleRDBTable< Type >& a ) {
00051     a.print( os );
00052     return os;
00053   }
00054 
00055   friend ostream& operator << ( ostream& os, simpleRDBTable< Type >* a ) {
00056     a->print( os );
00057     return os;
00058   }
00059 
00060 public:
00061 
00062   ~simpleRDBTable( );
00063 
00064   simpleRDBTable( const string& fname, const int mode,
00065                   const char* header[] )
00066     throw( Exception );
00067 
00069   static void getData( RDBColumn* rdbcol, string& val ) throw ( Exception );
00070 
00072   static void getData( RDBColumn* rdbcol, int& val ) throw ( Exception );
00073 
00075   static void getData( RDBColumn* rdbcol, long& val ) throw ( Exception );
00076 
00078   static void getData( RDBColumn* rdbcol, double& val ) throw ( Exception );
00079 
00080   void print( ostream& os ) const;
00081 
00083   Type* readRow( ) throw( Exception );
00084 
00085 protected:
00086 
00087   const char** rdb_header;
00088 
00089   RDBColumn** rdb_column;
00090 
00091 private:
00092 
00094   simpleRDBTable( ) : rdb_header( NULL ), rdb_column( NULL ) { }
00095 
00096   // Declare but (purposedly) not define
00097   simpleRDBTable< Type >( const simpleRDBTable< Type >& c );
00098 
00099   // Declare but (purposedly) not define
00100   simpleRDBTable< Type >& operator = ( const simpleRDBTable< Type >& rhs );
00101 
00102   size_t count_num_args( const char* str[] );
00103 
00104 };
00105 
00106 #ifndef simpleRDBTable_cc
00107 #include <rdbxx/simpleRDBTable.cc>
00108 #endif
00109 
00110 #endif

Generated on Tue Sep 15 11:07:16 2009 for rdbxx by  doxygen 1.5.6