00001 // --------------------------------------------------------------------- 00002 // $Id: Params.h 229 2008-08-14 00:44:06Z daaugusto $ 00003 // 00004 // Params.h (created on Tue Aug 23 01:08:35 BRT 2005) 00005 // 00006 // Genetic Algorithm File Fitter (gaffitter) 00007 // 00008 // Copyright (C) 2005-2008 Douglas A. Augusto 00009 // 00010 // This file is part of gaffitter. 00011 // 00012 // gaffitter is free software; you can redistribute it and/or modify it 00013 // under the terms of the GNU General Public License as published by the 00014 // Free Software Foundation; either version 3 of the License, or (at 00015 // your option) any later version. 00016 // 00017 // gaffitter is distributed in the hope that it will be useful, but 00018 // WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 // General Public License for more details. 00021 // 00022 // You should have received a copy of the GNU General Public License 00023 // along with gaffitter; if not, see <http://www.gnu.org/licenses/>. 00024 // 00025 // --------------------------------------------------------------------- 00026 00027 #ifndef params_hh 00028 #define params_hh 00029 00030 #include <iostream> 00031 #include <string> 00032 #include <sstream> 00033 #include <list> 00034 #include <limits> 00035 00036 //---------------------------------------------------------------------- 00043 class Params { 00044 public: 00055 typedef double Size_t; 00056 typedef long double BigFloat; 00057 typedef long long BigInt; 00058 typedef unsigned long long UBigInt; 00061 public: 00065 Params(int& argc, char** argv): m_argc(argc), m_argv(argv), 00066 m_no_metric(false) {} 00070 void ShowVersion() const; 00074 void ShowUsage(const char*) const; 00078 bool Initialize(); 00088 std::string PrettySize(Size_t) const; 00089 00090 public: 00091 int& m_argc; 00092 char** m_argv; 00093 00098 std::list<const char*> m_cmdline_items; 00099 00100 public: 00101 00102 // General options. 00103 Size_t m_target; 00104 Size_t m_min_size, m_max_size; 00106 unsigned m_max_bins; 00109 int m_block_size; 00110 bool m_verbose; 00111 bool m_pipe; 00112 bool m_hide_items; 00113 bool m_hide_summary; 00114 bool m_show_size; 00115 bool m_show_bytes; 00116 bool m_direct_input; 00117 bool m_no_metric; 00119 // Sorting options 00120 bool m_sort_by_size; 00121 bool m_sort_reverse; 00122 bool m_no_case; 00124 bool m_null_data; 00125 char m_bins_separator; 00126 char m_enclose_chr; 00127 bool m_enclose; 00128 char m_delimit_chr; 00130 // Genetic Algorithm options. 00131 unsigned m_ga_pop_size; 00132 int m_ga_num_gens; 00133 long m_ga_seed; 00134 int m_ga_sel_pressure; 00135 float m_ga_cross_prob; 00136 float m_ga_mut_prob; 00138 bool m_theoretical; 00140 unsigned m_bins_theo; 00146 // Search options 00147 bool m_approximate; 00149 bool m_split; 00151 #if 0 00152 bool m_brute_force; 00154 #endif 00155 00156 private: 00158 char m_unit_symbol; 00160 float m_unit_power; 00161 00162 // constants 00163 double KB(double power) const { return power; } 00164 double KB() const { return KB(m_unit_power); } 00165 00166 double MB(double power) const { return power*power; } 00167 double MB() const { return MB(m_unit_power); } 00168 00169 /* 1024^3 = 2^30, but 'float' usually supports only 2^24 integer 00170 * numbers without loss (mantissa). However 'double' supports 2^53. */ 00171 double GB(double power) const { return power*power*power; } 00172 double GB() const { return GB(m_unit_power); } 00173 00174 double TB(double power) const { return power*power*power*power; } 00175 double TB() const { return TB(m_unit_power); } 00176 00177 public: 00181 static bool StringToDouble(Size_t& d, const std::string& s) 00182 { 00183 std::istringstream iss(s); return !(iss >> std::dec >> d).fail(); 00184 } 00185 00189 bool GetSize( const std::string&, Size_t& ) const; 00190 00191 double DI_Factor() const { return m_di_factor; } 00192 00193 private: 00194 double m_di_factor; 00196 }; 00197 00198 //---------------------------------------------------------------------- 00199 #endif