00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 2009, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_TABLE_UNITS_H 00024 #define O2SCL_TABLE_UNITS_H 00025 00026 #include <o2scl/table.h> 00027 #include <o2scl/convert_units.h> 00028 00029 #ifndef DOXYGENP 00030 namespace o2scl { 00031 #endif 00032 00033 /** 00034 \brief Data \table class with units 00035 00036 \todo Make table methods virtual? (not necessary yet 00037 since delete_column() isn't referred to internally) 00038 00039 acol commands which need editing for table_units 00040 - binary 00041 - html 00042 */ 00043 class table_units : public table { 00044 public: 00045 00046 /** \brief Create a new table_units with space for nlines<=cmaxlines. 00047 */ 00048 table_units(int cmaxlines=0); 00049 00050 virtual ~table_units(); 00051 00052 /// \name Copy constructors 00053 //@{ 00054 table_units(const table_units &t); 00055 table_units(const table &t); 00056 table_units &operator=(const table_units &t); 00057 table_units &operator=(const table &t); 00058 //@} 00059 00060 /// Get the unit for column \c scol 00061 std::string get_unit(std::string scol) const; 00062 00063 /// Remove the unit for column \c scol 00064 int remove_unit(std::string scol); 00065 00066 /// Set the unit for column \c scol to \c unit 00067 int set_unit(std::string scol, std::string unit); 00068 00069 /// Convert the units of column \c scol to \c unit 00070 int convert_to_unit(std::string scol, std::string unit, 00071 bool err_on_fail=true); 00072 00073 /// Get the conversion factor from \c old_unit to \c new_unit 00074 double get_conv(std::string old_unit, std::string new_unit); 00075 00076 /// The default object for unit conversions 00077 convert_units def_cu; 00078 00079 /// Delete column named \c scol 00080 virtual int delete_column(std::string scol); 00081 00082 /// Return the type, \c "table_units". 00083 virtual const char *type() { return "table_units"; } 00084 00085 /// Output a summary of the information stored 00086 virtual int summary(std::ostream *out, int ncol=79) const; 00087 00088 /// Set the convert units object 00089 int set_convert(convert_units &c) { 00090 cup=&c; 00091 return 0; 00092 } 00093 00094 /// Show the units 00095 int show_units() { 00096 cup->print_cache(); 00097 return 0; 00098 } 00099 00100 protected: 00101 00102 #ifndef DOXYGEN_INTERNAL 00103 00104 friend class io_tlate<table_units>; 00105 00106 /// The pointer to the convert units object 00107 convert_units *cup; 00108 00109 /// \name Unit map iterator types 00110 //@{ 00111 typedef std::map<std::string,std::string, 00112 string_comp>::iterator uiter; 00113 typedef std::map<std::string,std::string, 00114 string_comp>::const_iterator uciter; 00115 //@} 00116 00117 /// Unit map 00118 std::map<std::string,std::string,string_comp> utree; 00119 00120 #endif 00121 00122 }; 00123 00124 /// Input specialization 00125 template<> int io_tlate<table_units>::input 00126 (cinput *co, o2scl::in_file_format *ins, table_units *ta); 00127 /// Output specialization 00128 template<> int io_tlate<table_units>::output 00129 (coutput *co, o2scl::out_file_format *outs, 00130 table_units *at); 00131 /// \fn Type specialization 00132 template<> const char *io_tlate<table_units>::type(); 00133 00134 typedef io_tlate<table_units> table_units_io_type; 00135 00136 #ifndef DOXYGENP 00137 } 00138 #endif 00139 00140 #endif
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page