SelectedCols.h

00001 #ifndef SelectedCols_H
00002 #define SelectedCols_H
00003 
00004 /* --8<--8<--8<--8<--
00005  *
00006  * Copyright (C) 2006 Smithsonian Astrophysical Observatory
00007  *
00008  * This file is part of rdbstats
00009  *
00010  * rdbstats 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  * rdbstats 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 <vector>
00029 
00030 #include <suplibxx/str.h>
00031 #include <Exception/Exception.h>
00032 #include <rdbxx/RDB.h>
00033 
00034 #include "Options.h"
00035 
00047 using namespace std;
00048 
00049 class SelectedCols {
00050 
00051   friend ostream& operator << ( ostream& os, SelectedCols& a ) {
00052     a.print( os );
00053     return os;
00054   }
00055 
00056   friend ostream& operator << ( ostream& os, SelectedCols* a ) {
00057     a->print( os );
00058     return os;
00059   }
00060 
00061 public:
00062 
00064   SelectedCols( const vector< string >& cols, RDB& rdbtable,
00065                 clo::parser& clo ) throw( Exception );
00066 
00068   SelectedCols( RDB& rdbtable, clo::parser& clo ) throw( Exception );
00069 
00070   const vector< string >& get_selected_cols( ) const { return selected_cols; }
00071 
00072   void print( ostream& os ) const;
00073 
00074 protected:
00075 
00076   // Contains the names of the columns to calculate the statistics.
00077   vector< string > selected_cols;
00078 
00079 private:
00080 
00082   bool is_column_numeric( const string& colname, RDB& rdbtable )
00083     throw( Exception );
00084 
00086   bool is_column_numeric( const string& colname, RDB& rdbtable,
00087                           const clo::options& options ) throw ( Exception );
00088 
00089   bool is_groupie( const string& name, const vector<string>& groupies );
00090 
00091   void toggle_column_definition( const string& colname, RDB& rdbtable )
00092     const throw ( Exception );
00093 
00094 };
00095 
00096 #endif