Mass.h

Go to the documentation of this file.
00001 
00008 /* Copyright (C) 2002 - 2009, Bernd Speiser */
00009 
00010 /* This file is part of Quantities.
00011 
00012 PhysicalQuantities is free software; you can redistribute it and/or
00013 modify it under the terms of the GNU General Public License
00014 as published by the Free Software Foundation; either version 2
00015 of the License, or (at your option) any later version.
00016 
00017 PhysicalQuantities is distributed in the hope that it will be useful,
00018 but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 GNU General Public License for more details.
00021   
00022 You should have received a copy of the GNU General Public License
00023 along with this program; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00025 02111-1307, USA.
00026 */
00027 
00028 #ifndef _Mass_h
00029 #define _Mass_h
00030 
00031 // Quantity includes
00032 #include "Quantity/Variable.h"
00033 #include "Quantity/Constant.h"
00034 #include "Quantity/QuantityCluster.h"
00035 
00036 namespace quantity {
00037   namespace mass {
00038 
00040 class Class;
00041 
00043 class Unit;
00044 
00045 /* declaration of Mass units */
00046 class GramUnits;
00047 class ElectronMassUnit;
00048 class DaltonUnit;
00049 class UUnit;
00050 class GammaUnit;
00051 class TonneUnits;
00052 class PoundUnit;
00053 class OunceUnit;
00054 class TroyOunceUnit;
00055 class GrainUnit;
00056 
00058 typedef unit::Prefixable<Unit, GramUnits> Grams;
00059 
00061 typedef unit::Prefixed<Grams> Gram;
00062 typedef unit::Prefixed<Grams, unit::Milli> MilliGram;
00063 typedef unit::Prefixed<Grams, unit::Micro> MicroGram;
00064 typedef unit::Prefixed<Grams, unit::Nano> NanoGram;
00065 typedef unit::Prefixed<Grams, unit::Pico> PicoGram;
00066 typedef unit::Prefixed<Grams, unit::Kilo> KiloGram;
00067 
00069 typedef unit::NonPrefixable<Unit, ElectronMassUnit> ElectronMass;
00070 
00072 typedef unit::NonPrefixable<Unit, DaltonUnit> Dalton;
00073 
00075 typedef unit::NonPrefixable<Unit, UUnit> U;
00076 
00078 typedef unit::NonPrefixable<Unit, GammaUnit> Gamma;
00079 
00081 typedef unit::Prefixable<Unit, TonneUnits> Tonnes;
00082 
00084 typedef unit::Prefixed<Tonnes> Tonne;
00085 typedef unit::Prefixed<Tonnes, unit::Kilo> KiloTonne;
00086 typedef unit::Prefixed<Tonnes, unit::Mega> MegaTonne;
00087 
00089 
00090 typedef unit::NonPrefixable<Unit, PoundUnit> Pound;
00091 
00093 typedef unit::NonPrefixable<Unit, OunceUnit> Ounce;
00094 
00096 typedef unit::NonPrefixable<Unit, TroyOunceUnit> TroyOunce;
00097 
00099 typedef unit::NonPrefixable<Unit, GrainUnit> Grain;
00100 
00102 typedef 
00103   Loki::TL::Append<Loki::TL::Append<Grams::Units, Tonne::Units>::Result,
00104     LOKI_TYPELIST_8(ElectronMass, Dalton, U, Gamma, Pound, Ounce, TroyOunce, 
00105                                                   Grain)>::Result Units;
00106 
00107 /* declare some abbreviated time units */
00108 typedef Gram g;
00109 typedef KiloGram kg;
00110 
00111 /* Mass quantity */
00112 typedef Quantity<Class> Quantity;
00113 
00114 class DerivedMass;
00115 
00116   } // end namespace mass
00117 
00119 
00121   template<typename ST>
00122     struct Standard<mass::Grams, ST>
00123     {
00124       static const ST ratio;
00125       static const bool exact;
00126     };
00127 
00129 template<typename ST> const ST Standard<mass::Grams, ST>::ratio = 0.001;
00130 
00132 template<typename ST> const bool Standard<mass::Grams, ST>::exact = true;
00133 
00135 
00137   template<typename ST>
00138     struct Standard<mass::ElectronMass, ST>
00139     {
00140       static const ST ratio;
00141       static const bool exact;
00142     };
00143 
00145 template<typename ST> const ST Standard<mass::ElectronMass, ST>::ratio = 9.10939e-31;
00146 
00148 template<typename ST> const bool Standard<mass::ElectronMass, ST>::exact = false;
00149 
00151 
00153   template<typename ST>
00154     struct Standard<mass::Dalton, ST>
00155     {
00156       static const ST ratio;
00157       static const bool exact;
00158     };
00159 
00161 template<typename ST> const ST Standard<mass::Dalton, ST>::ratio = 1.660540e-27;
00162 
00164 template<typename ST> const bool Standard<mass::Dalton, ST>::exact = false;
00165 
00167 
00169   template<typename ST>
00170     struct Standard<mass::U, ST>
00171     {
00172       static const ST ratio;
00173       static const bool exact;
00174     };
00175 
00177 template<typename ST> const ST Standard<mass::U, ST>::ratio = 1.660540e-27;
00178 
00180 template<typename ST> const bool Standard<mass::U, ST>::exact = false;
00181 
00183 
00185   template<typename ST>
00186     struct Standard<mass::Gamma, ST>
00187     {
00188       static const ST ratio;
00189       static const bool exact;
00190     };
00191 
00193 template<typename ST> const ST Standard<mass::Gamma, ST>::ratio = 1.0e-9;
00194 
00196 template<typename ST> const bool Standard<mass::Gamma, ST>::exact = true;
00197 
00199 
00201   template<typename ST>
00202     struct Standard<mass::Tonnes, ST>
00203     {
00204       static const ST ratio;
00205       static const bool exact;
00206     };
00207 
00209 template<typename ST> const ST Standard<mass::Tonnes, ST>::ratio = 1000.;
00210 
00212 template<typename ST> const bool Standard<mass::Tonnes, ST>::exact = true;
00213 
00215 
00217   template<typename ST>
00218     struct Standard<mass::Pound, ST>
00219     {
00220       static const ST ratio;
00221       static const bool exact;
00222     };
00223 
00225 template<typename ST> const ST Standard<mass::Pound, ST>::ratio = 0.45359237;
00226 
00228 template<typename ST> const bool Standard<mass::Pound, ST>::exact = true;
00229 
00231 
00233   template<typename ST>
00234     struct Standard<mass::Ounce, ST>
00235     {
00236       static const ST ratio;
00237       static const bool exact;
00238     };
00239 
00241 template<typename ST> const ST Standard<mass::Ounce, ST>::ratio = 0.0283495;
00242 
00244 template<typename ST> const bool Standard<mass::Ounce, ST>::exact = false;
00245 
00247 
00249   template<typename ST>
00250     struct Standard<mass::TroyOunce, ST>
00251     {
00252       static const ST ratio;
00253       static const bool exact;
00254     };
00255 
00257 template<typename ST> const ST Standard<mass::TroyOunce, ST>::ratio = 0.0311035;
00258 
00260 template<typename ST> const bool Standard<mass::TroyOunce, ST>::exact = false;
00261 
00263 
00265   template<typename ST>
00266     struct Standard<mass::Grain, ST>
00267     {
00268       static const ST ratio;
00269       static const bool exact;
00270     };
00271 
00273 template<typename ST> const ST Standard<mass::Grain, ST>::ratio = 6.479891e-5;
00274 
00276 template<typename ST> const bool Standard<mass::Grain, ST>::exact = true;
00277 
00279 template<>
00280   struct QuantityTraits<mass::Class>
00281   {
00282     typedef
00283       dimension::Dimension<BSUtilities::Rational<0>,
00284         BSUtilities::Rational<1>, BSUtilities::Rational<0>,
00285           BSUtilities::Rational<0>, BSUtilities::Rational<0>,
00286             BSUtilities::Rational<0>, BSUtilities::Rational<0> > Dimension;
00287     typedef mass::Unit UnitType;
00288     typedef mass::Units UnitList;
00289     typedef mass::KiloGram DefaultUnit;
00290 
00291     typedef mass::DerivedMass DefaultDerivedQuantityType;
00292 
00293     static const std::string NameString;
00294     static const std::string SymbolString;
00295 
00296   };
00297 
00298 // the derived quantity traits template for KiloGram Mass
00299 template<>
00300   struct DerivedQuantityTraits<mass::Class, mass::DerivedMass>
00301   {
00302     static const bool OverwriteName = false;
00303     static const bool OverwriteSymbol = false;
00304 
00305     static const std::string NameString;
00306     static const std::string SymbolString;
00307 
00308   };
00309 
00311 typedef Variable<mass::Quantity> Mass;
00312 
00314 typedef Constant<mass::Quantity> MassConstant;
00315 
00317 typedef QuantityVector<Variable, mass::Quantity> MassVector;
00318 
00319 }
00320 
00321 #endif /* _Mass_h */

Generated on Mon Jul 27 15:55:45 2009 for Quantities by  doxygen 1.5.3