Area.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 _Area_h
00028 #define _Area_h
00029 
00030 // Quantity includes
00031 #include "Quantity/Variable.h"
00032 #include "Quantity/Constant.h"
00033 #include "Quantity/QuantityCluster.h"
00034 #include "PhysicalQuantities/Length.h"
00035 
00036 namespace quantity {
00037   namespace area {
00038 
00040 class Class;
00041 
00043 class Unit;
00044 
00045 /* declaration of Area units */
00046 class BarnUnit;
00047 class AcreUnit;
00048 class AreUnit;
00049 class HectareUnit;
00050 
00051 /* the SquareMetre and prefixed SquareMetres */
00052 
00053 typedef LOKI_TYPELIST_3(length::Metre, length::CentiMetre, 
00054                                         length::MilliMetre) LengthList;
00055 
00057 typedef unit::ComposeElement<Unit, LengthList, 
00058                                BSUtilities::Rational<2> > LengthElement;
00059 typedef LOKI_TYPELIST_1(LengthElement) AreaCompositeList;
00060 
00061 typedef unit::ComposeBase<Unit, AreaCompositeList> SquareMetreUnits;
00062 
00063 typedef 
00064   unit::Composed<SquareMetreUnits, LOKI_TYPELIST_1(length::Metre)> 
00065                                                             SquareMetre;
00066 
00067 typedef
00068   unit::Composed<SquareMetreUnits, LOKI_TYPELIST_1(length::CentiMetre)>
00069                                                        SquareCentiMetre;
00070 
00071 typedef unit::Composed<SquareMetreUnits, 
00072                   LOKI_TYPELIST_1(length::MilliMetre)> SquareMilliMetre;
00073 
00075 typedef unit::NonPrefixable<Unit, BarnUnit> Barn;
00076 
00078 typedef unit::NonPrefixable<Unit, AcreUnit> Acre;
00079 
00081 typedef unit::NonPrefixable<Unit, AreUnit> Are;
00082 
00084 typedef unit::NonPrefixable<Unit, HectareUnit> Hectare;
00085 
00087 typedef
00088   LOKI_TYPELIST_7(SquareMetre, SquareCentiMetre, SquareMilliMetre, Barn,
00089                                               Acre, Are, Hectare) Units;
00090 
00091 /* Area quantity */
00092 
00093 typedef Quantity<Class> Quantity;
00094 
00095 class DerivedArea;
00096 
00097   } // end namespace area
00098 
00100 
00102   template<typename ST>
00103     struct Standard<area::SquareMetreUnits, ST>
00104     {
00105       static const ST ratio;
00106       static const bool exact;
00107     };
00108 
00110 template<typename ST> const ST Standard<area::SquareMetreUnits, ST>::ratio = 1.0;
00111 
00113 template<typename ST> const bool Standard<area::SquareMetreUnits, ST>::exact = true;
00114 
00116 
00118   template<typename ST>
00119     struct Standard<area::Barn, ST>
00120     {
00121       static const ST ratio;
00122       static const bool exact;
00123     };
00124 
00126 template<typename ST> const ST Standard<area::Barn, ST>::ratio = 1.0e-28;
00127 
00129 template<typename ST> const bool Standard<area::Barn, ST>::exact = true;
00130 
00132 
00134   template<typename ST>
00135     struct Standard<area::Acre, ST>
00136     {
00137       static const ST ratio;
00138       static const bool exact;
00139     };
00140 
00142 template<typename ST> const ST Standard<area::Acre, ST>::ratio = 4046.856;
00143 
00145 template<typename ST> const bool Standard<area::Acre, ST>::exact = false;
00146 
00148 
00150   template<typename ST>
00151     struct Standard<area::Are, ST>
00152     {
00153       static const ST ratio;
00154       static const bool exact;
00155     };
00156 
00158 template<typename ST> const ST Standard<area::Are, ST>::ratio = 1.0e2;
00159 
00161 template<typename ST> const bool Standard<area::Are, ST>::exact = true;
00162 
00164 
00166   template<typename ST>
00167     struct Standard<area::Hectare, ST>
00168     {
00169       static const ST ratio;
00170       static const bool exact;
00171     };
00172 
00174 template<typename ST> const ST Standard<area::Hectare, ST>::ratio = 1.0e4;
00175 
00177 template<typename ST> const bool Standard<area::Hectare, ST>::exact = true;
00178 
00180 template<>
00181   struct QuantityTraits<area::Class>
00182   {
00183     typedef
00184       dimension::Dimension<BSUtilities::Rational<2>,
00185         BSUtilities::Rational<0>, BSUtilities::Rational<0>,
00186           BSUtilities::Rational<0>, BSUtilities::Rational<0>,
00187             BSUtilities::Rational<0>, BSUtilities::Rational<0> > Dimension;
00188     typedef area::Unit UnitType;
00189     typedef area::Units UnitList;
00190     typedef area::SquareMetre DefaultUnit;
00191 
00192     typedef area::DerivedArea DefaultDerivedQuantityType;
00193 
00194     static const std::string NameString;
00195     static const std::string SymbolString;
00196   };
00197 
00198 // the derived quantity traits template for derived Areas
00199 template<>
00200   struct DerivedQuantityTraits<area::Class, area::DerivedArea>
00201   {
00202     static const bool OverwriteName = false;
00203     static const bool OverwriteSymbol = false;
00204 
00205     static const std::string NameString;
00206     static const std::string SymbolString;
00207 
00208   };
00209 
00210 
00212 typedef Variable<area::Quantity> Area;
00213 
00215 typedef Constant<area::Quantity> AreaConstant;
00216 
00218 typedef QuantityVector<Variable, area::Quantity> AreaVector;
00219 
00220 } // end namespace quantity
00221 
00222 #endif /* _Area_h */

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