AvogadroConstant.h

Go to the documentation of this file.
00001 
00008 /* Copyright (C) 2008 - 2009, Bernd Speiser */
00009 
00010 /* This file is part of PhysicalQuantities.
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 _AvogadroConstant_h
00029 #define _AvogadroConstant_h
00030 
00031 // Quantity includes
00032 #include "Quantity/UniqueConstant.h"
00033 #include "PhysicalQuantities/AmountOfSubstance.h"
00034 
00035 namespace quantity {
00036   namespace avogadroConstant {
00037 
00039 class Class;
00040 
00042 class Unit;
00043 
00044 /* the CoulombPerMole and prefixed variants */
00045 
00046 typedef LOKI_TYPELIST_2(amountOfSubstance::Mole, 
00047                    amountOfSubstance::MilliMole) AmountOfSubstanceList;
00048 
00050 typedef unit::ComposeElement<Unit, 
00051   AmountOfSubstanceList, BSUtilities::Rational<-1> > 
00052                                                AmountOfSubstanceElement;
00053 
00054 typedef 
00055   unit::ComposeBase<Unit, LOKI_TYPELIST_1(AmountOfSubstanceElement)>
00056                                             AvogadroConstantComposedUnit;
00057 
00058 typedef unit::Composed<AvogadroConstantComposedUnit, 
00059   LOKI_TYPELIST_1(amountOfSubstance::Mole)> OnePerMole;
00060 typedef unit::Composed<AvogadroConstantComposedUnit, 
00061   LOKI_TYPELIST_1(amountOfSubstance::MilliMole)> OnePerMilliMole;
00062 
00063 
00065 typedef LOKI_TYPELIST_2(OnePerMole, OnePerMilliMole) Units;
00066 
00067 /* AvogadroConstant quantity */
00068 
00069 typedef Quantity<Class> Quantity;
00070 
00071 class DerivedAvogadroConstant;
00072 
00073   } // end namespace avogadroConstant
00074 
00076 
00078   template<typename ST>
00079     struct Standard<avogadroConstant::AvogadroConstantComposedUnit, ST>
00080     {
00081       static const ST ratio;
00082       static const bool exact;
00083     };
00084 
00086 template<typename ST> const ST Standard<avogadroConstant::AvogadroConstantComposedUnit, ST>::ratio 
00087                                                                                          = 1.0;
00088 
00090 template<typename ST> const bool Standard<avogadroConstant::AvogadroConstantComposedUnit, ST>::exact 
00091                                                                                          = true;
00092 
00094 template<>
00095   struct QuantityTraits<avogadroConstant::Class>
00096   {
00097     typedef
00098       dimension::Dimension<BSUtilities::Rational<0>,
00099         BSUtilities::Rational<0>, BSUtilities::Rational<0>,
00100           BSUtilities::Rational<0>, BSUtilities::Rational<0>,
00101             BSUtilities::Rational<-1>, BSUtilities::Rational<0> > Dimension;
00102     typedef avogadroConstant::Unit UnitType;
00103     typedef avogadroConstant::Units UnitList;
00104     typedef avogadroConstant::OnePerMole DefaultUnit;
00105 
00106     typedef avogadroConstant::DerivedAvogadroConstant DefaultDerivedQuantityType;
00107 
00108     static const std::string NameString;
00109     static const std::string SymbolString;
00110 
00111   };
00112 
00113 // the derived quantity traits template for Avogadro constant
00114 template<>
00115   struct DerivedQuantityTraits<avogadroConstant::Class, avogadroConstant::DerivedAvogadroConstant>
00116   {
00117     static const bool OverwriteName = false;
00118     static const bool OverwriteSymbol = false;
00119 
00120     static const std::string NameString;
00121     static const std::string SymbolString;
00122 
00123   };
00124 
00126 typedef Loki::SingletonHolder<UniqueConstant
00127                          <avogadroConstant::Quantity> > AvogadroConstant;
00128 
00130 #define AVOGADROCONSTANT AvogadroConstant::Instance()
00131 
00132 } // end namespace quantity
00133 
00134 #endif /* _AvogadroConstant_h */

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