Fraction.h

Go to the documentation of this file.
00001 
00007 /* Copyright (C) 2002 - 2009, Bernd Speiser */
00008 
00009 /* This file is part of Quantities.
00010 
00011 PhysicalQuantities is free software; you can redistribute it and/or
00012 modify it under the terms of the GNU General Public License
00013 as published by the Free Software Foundation; either version 2
00014 of the License, or (at your option) any later version.
00015 
00016 PhysicalQuantities is distributed in the hope that it will be useful,
00017 but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 GNU General Public License for more details.
00020   
00021 You should have received a copy of the GNU General Public License
00022 along with this program; if not, write to the Free Software
00023 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00024 02111-1307, USA.
00025 */
00026 
00027 #ifndef _Fraction_h
00028 #define _Fraction_h
00029 
00030 // Quantity includes
00031 #include "Quantity/Variable.h"
00032 #include "Quantity/Constant.h"
00033 #include "Quantity/QuantityCluster.h"
00034 
00035 namespace quantity {
00036   namespace fraction {
00037 
00039 class Class;
00040 
00042 class Unit;
00043 
00044 /* declaration of Fraction units */
00045 class UnityUnit;
00046 class PercentUnit;
00047 class PermilleUnit;
00048 class PpmUnit;
00049 
00051 typedef unit::NonPrefixable<Unit, UnityUnit> Unity;
00052 
00054 typedef unit::NonPrefixable<Unit, PercentUnit> Percent;
00055 
00057 typedef unit::NonPrefixable<Unit, PermilleUnit> Permille;
00058 
00060 typedef unit::NonPrefixable<Unit, PpmUnit> Ppm;
00061 
00063 typedef LOKI_TYPELIST_4(Unity, Percent, Permille, Ppm) Units;
00064 
00065 /* Fraction quantity */
00066 
00067 typedef Quantity<Class> Quantity;
00068 
00069 class DerivedFraction;
00070 
00071   } // end namespace fraction
00072 
00074 
00076   template<typename ST>
00077     struct Standard<fraction::Unity, ST>
00078     {
00079       static const ST ratio;
00080       static const bool exact;
00081     };
00082 
00084 template<typename ST> const ST Standard<fraction::Unity, ST>::ratio = 1.0;
00085 
00087 template<typename ST> const bool Standard<fraction::Unity, ST>::exact = true;
00088 
00090 
00092   template<typename ST>
00093     struct Standard<fraction::Percent, ST>
00094     {
00095       static const ST ratio;
00096       static const bool exact;
00097     };
00098 
00100 template<typename ST> const ST Standard<fraction::Percent, ST>::ratio = 0.01;
00101 
00103 template<typename ST> const bool Standard<fraction::Percent, ST>::exact = true;
00104 
00106 
00108   template<typename ST>
00109     struct Standard<fraction::Ppm, ST>
00110     {
00111       static const ST ratio;
00112       static const bool exact;
00113     };
00114 
00116 template<typename ST> const ST Standard<fraction::Ppm, ST>::ratio = 1.0e-6;
00117 
00119 template<typename ST> const bool Standard<fraction::Ppm, ST>::exact = true;
00120 
00122 template<>
00123   struct QuantityTraits<fraction::Class>
00124   {
00125     typedef
00126       dimension::Dimension<BSUtilities::Rational<0>,
00127         BSUtilities::Rational<0>, BSUtilities::Rational<0>,
00128           BSUtilities::Rational<0>, BSUtilities::Rational<0>,
00129             BSUtilities::Rational<0>, BSUtilities::Rational<0> > Dimension;
00130     typedef fraction::Unit UnitType;
00131     typedef fraction::Units UnitList;
00132     typedef fraction::Unity DefaultUnit;
00133 
00134     typedef fraction::DerivedFraction DefaultDerivedQuantityType;
00135 
00136     static const std::string NameString;
00137     static const std::string SymbolString;
00138 
00139   };
00140 
00141 // the derived quantity traits template for derived Fraction
00142 template<>
00143   struct DerivedQuantityTraits<fraction::Class, fraction::DerivedFraction>
00144   {
00145     static const bool OverwriteName = false;
00146     static const bool OverwriteSymbol = false;
00147 
00148     static const std::string NameString;
00149     static const std::string SymbolString;
00150 
00151   };
00152 
00154 typedef Variable<fraction::Quantity> Fraction;
00155 
00157 typedef Constant<fraction::Quantity> FractionConstant;
00158 
00160 typedef QuantityVector<Variable, fraction::Quantity> FractionVector;
00161 
00162 } // end namespace quantity
00163 
00164 #endif /* _Fraction_h */

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