Volume.h

Go to the documentation of this file.
00001 
00007 /* Copyright (C) 2002 - 2009, Bernd Speiser */
00008 /* This file is part of Quantities.
00009 
00010 PhysicalQuantities is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 PhysicalQuantities is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019   
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00023 02111-1307, USA.
00024 */
00025 
00026 #ifndef volume_h
00027 #define volume_h
00028 
00029 // Quantity includes
00030 #include "Quantity/Variable.h"
00031 #include "Quantity/Constant.h"
00032 #include "PhysicalQuantities/Length.h"
00033 
00034 namespace quantity {
00035   namespace volume {
00036 
00038 class Class;
00039 
00041 class Unit;
00042 
00043 /* declaration of Volume units */
00044 class LitreUnit;
00045 class LambdaUnit;
00046 class BarrelUnit;
00047 class USGallonUnit;
00048 class UKGallonUnit;
00049 
00051 
00054 typedef LOKI_TYPELIST_3(length::Metre, length::CentiMetre,
00055                                         length::MilliMetre) LengthList;
00056 
00058 typedef 
00059   unit::ComposeElement<Unit, LengthList, 
00060                                BSUtilities::Rational<3> > LengthElement;
00061 
00062 typedef 
00063    unit::ComposeBase<Unit, LOKI_TYPELIST_1(LengthElement)> 
00064                                                      VolumeComposedUnit;
00065 
00066 typedef 
00067   unit::Composed<VolumeComposedUnit, LOKI_TYPELIST_1(length::Metre)> 
00068                                                              CubicMetre;
00069 
00070 typedef unit::Composed<VolumeComposedUnit, 
00071                    LOKI_TYPELIST_1(length::MilliMetre)> CubicMilliMetre;
00072 
00073 typedef unit::Composed<VolumeComposedUnit, 
00074                    LOKI_TYPELIST_1(length::CentiMetre)> CubicCentiMetre;
00075 
00077 typedef unit::Prefixable<Unit, LitreUnit> Litres;
00078 
00080 typedef unit::Prefixed<Litres> Litre;
00081 
00083 typedef unit::NonPrefixable<Unit, LambdaUnit> Lambda;
00084 
00086 typedef unit::NonPrefixable<Unit, BarrelUnit> Barrel;
00087 
00089 typedef unit::NonPrefixable<Unit, USGallonUnit> USGallon;
00090 
00091 
00093 typedef unit::NonPrefixable<Unit, UKGallonUnit> UKGallon;
00094 
00096 typedef LOKI_TYPELIST_8(CubicMetre, CubicCentiMetre, CubicMilliMetre,
00097                        Litres::Units, Lambda, Barrel, USGallon, UKGallon) Units;
00098 
00099 /* Volume quantity */
00100 
00101 typedef Quantity<Class> Quantity;
00102 
00103 class DerivedVolume;
00104 
00105   } // end namespace volume
00106 
00108 
00110   template<typename ST>
00111     struct Standard<volume::VolumeComposedUnit, ST>
00112     {
00113       static const ST ratio;
00114       static const bool exact;
00115     };
00116 
00118 template<typename ST> const ST Standard<volume::VolumeComposedUnit, ST>::ratio = 1.0;
00119 
00121 template<typename ST> const bool Standard<volume::VolumeComposedUnit, ST>::exact = true;
00122 
00124 
00126   template<typename ST>
00127     struct Standard<volume::Litres, ST>
00128     {
00129       static const ST ratio;
00130       static const bool exact;
00131     };
00132 
00134 template<typename ST> const ST Standard<volume::Litres, ST>::ratio = 1.0e-3;
00135 
00137 template<typename ST> const bool Standard<volume::Litres, ST>::exact = true;
00138 
00140 
00142   template<typename ST>
00143     struct Standard<volume::Lambda, ST>
00144     {
00145       static const ST ratio;
00146       static const bool exact;
00147     };
00148 
00150 template<typename ST> const ST Standard<volume::Lambda, ST>::ratio = 1.0e-6;
00151 
00153 template<typename ST> const bool Standard<volume::Lambda, ST>::exact = true;
00154 
00156 
00158   template<typename ST>
00159     struct Standard<volume::Barrel, ST>
00160     {
00161       static const ST ratio;
00162       static const bool exact;
00163     };
00164 
00166 template<typename ST> const ST Standard<volume::Barrel, ST>::ratio = 0.158987;
00167 
00169 template<typename ST> const bool Standard<volume::Barrel, ST>::exact = false;
00170 
00172 
00174   template<typename ST>
00175     struct Standard<volume::USGallon, ST>
00176     {
00177       static const ST ratio;
00178       static const bool exact;
00179     };
00180 
00182 template<typename ST> const ST Standard<volume::USGallon, ST>::ratio = 0.00378541;
00183 
00185 template<typename ST> const bool Standard<volume::USGallon, ST>::exact = true;
00186 
00188 
00190   template<typename ST>
00191     struct Standard<volume::UKGallon, ST>
00192     {
00193       static const ST ratio;
00194       static const bool exact;
00195     };
00196 
00198 template<typename ST> const ST Standard<volume::UKGallon, ST>::ratio = 0.00378541;
00199 
00201 template<typename ST> const bool Standard<volume::UKGallon, ST>::exact = true;
00202 
00204 template<>
00205   struct QuantityTraits<volume::Class>
00206   {
00207     typedef
00208       dimension::Dimension<BSUtilities::Rational<3>,
00209         BSUtilities::Rational<0>, BSUtilities::Rational<0>,
00210           BSUtilities::Rational<0>, BSUtilities::Rational<0>,
00211             BSUtilities::Rational<0>, BSUtilities::Rational<0> > Dimension;
00212     typedef volume::Unit UnitType;
00213     typedef volume::Units UnitList;
00214     typedef volume::CubicMetre DefaultUnit;
00215 
00216     typedef volume::DerivedVolume DefaultDerivedQuantityType;
00217 
00218     static const std::string NameString;
00219     static const std::string SymbolString;
00220   };
00221 
00222 // the derived quantity traits template for CubicMetre Volume
00223 template<>
00224   struct DerivedQuantityTraits<volume::Class, volume::DerivedVolume>
00225   {
00226     static const bool OverwriteName = false;
00227     static const bool OverwriteSymbol = false;
00228 
00229     static const std::string NameString;
00230     static const std::string SymbolString;
00231 
00232   };
00233 
00235 typedef Variable<volume::Quantity> Volume;
00236 
00238 typedef Constant<volume::Quantity> VolumeConstant;
00239 
00241 typedef QuantityVector<Variable, volume::Quantity> VolumeVector;
00242 
00243 }
00244 
00245 #endif /* volume_h */

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