rdbstats  2.0.7
SelectedCols.h
1 #ifndef SelectedCols_H
2 #define SelectedCols_H
3 
4 /* --8<--8<--8<--8<--
5  *
6  * Copyright (C) 2006 Smithsonian Astrophysical Observatory
7  *
8  * This file is part of rdbstats
9  *
10  * rdbstats 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  * rdbstats 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 <vector>
29 
30 #include <suplibxx/str.h>
31 #include <Exception/Exception.h>
32 #include <rdbxx/RDB.h>
33 
34 #include "Options.h"
35 
48 class SelectedCols {
49 
50  friend std::ostream& operator << ( std::ostream& os, SelectedCols& a ) {
51  a.print( os );
52  return os;
53  }
54 
55  friend std::ostream& operator << ( std::ostream& os, SelectedCols* a ) {
56  a->print( os );
57  return os;
58  }
59 
60 public:
61 
62  SelectedCols( RDB& rdbtable,
63  const std::vector<std::string>& columns,
64  const std::vector<std::string>& group,
65  const std::vector<std::string>& override
66  );
67 
68  const std::vector< std::string >& get_selected_cols( ) const { return selected_cols; }
69 
70  void print( std::ostream& os ) const;
71 
72 protected:
73 
74  // Contains the names of the columns to calculate the statistics.
75  std::vector< std::string > selected_cols;
76 
77 private:
78 
80  bool is_column_numeric( const std::string& colname, RDB& rdbtable );
81 
82 
84  bool is_column_numeric( const std::string& colname, RDB& rdbtable,
85  const std::vector<std::string>& override );
86 
87  bool is_groupie( const std::string& name, const std::vector<std::string>& groupies );
88 
89  void toggle_column_definition( const std::string& colname, RDB& rdbtable ) const;
90 
91 };
92 
93 #endif
A class to figure out the name of the columns for which the statistics are to be calculated.
Definition: SelectedCols.h:48