Time.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 _Time_h
00029 #define _Time_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 time {
00038 
00040 class Class;
00041 
00043 class Unit;
00044 
00045 /* declaration of Time units */
00046 class SecondUnits;
00047 class MinuteUnit;
00048 class HourUnit;
00049 class DayUnit;
00050 class YearUnit;
00051 class SvedbergUnit;
00052 class AtomicUnit;
00053 
00055 typedef unit::Prefixable<Unit, SecondUnits> Seconds;
00056 
00058 typedef unit::Prefixed<Seconds> Second; 
00059 typedef unit::Prefixed<Seconds, unit::Deci> DeciSecond;
00060 typedef unit::Prefixed<Seconds, unit::Milli> MilliSecond;
00061 typedef unit::Prefixed<Seconds, unit::Micro> MicroSecond;
00062 typedef unit::Prefixed<Seconds, unit::Nano> NanoSecond;
00063 typedef unit::Prefixed<Seconds, unit::Pico> PicoSecond;
00064 
00066 typedef unit::NonPrefixable<Unit, MinuteUnit> Minute; 
00067 
00069 typedef unit::NonPrefixable<Unit, HourUnit> Hour; 
00070 
00072 typedef unit::NonPrefixable<Unit, DayUnit> Day; 
00073 
00075 typedef unit::NonPrefixable<Unit, YearUnit> Year; 
00076 
00078 typedef unit::NonPrefixable<Unit, SvedbergUnit> Svedberg; 
00079 
00081 typedef unit::NonPrefixable<Unit, AtomicUnit> Atomic; 
00082 
00084 typedef Loki::TL::Append<Seconds::Units, 
00085   LOKI_TYPELIST_6(Minute, Hour, Day, Year, Svedberg, Atomic)>::Result 
00086                                                                   Units;
00087 
00088 /* declare some abbreviated time units */
00089 typedef Second s;
00090 typedef MilliSecond ms;
00091 typedef MicroSecond us;
00092 typedef Minute min;
00093 
00094 /* Time Quantity */
00095 
00096 typedef Quantity<Class> Quantity;
00097 typedef quantity::Quantity<Class, int> IntQuantity;
00098 typedef quantity::Quantity<Class, long> LongQuantity;
00099 
00100 class DerivedTime;
00101 
00102   } // end namespace time
00103 
00105 
00107   template<typename ST>
00108     struct Standard<time::Seconds, ST>
00109     {
00110       static const ST ratio;
00111       static const bool exact;
00112     };
00113 
00115 template<typename ST> const ST Standard<time::Seconds, ST>::ratio = 1.0;
00116 
00118 template<typename ST> const bool Standard<time::Seconds, ST>::exact = true;
00119 
00121 
00123   template<typename ST>
00124     struct Standard<time::Minute, ST>
00125     {
00126       static const ST ratio;
00127       static const bool exact;
00128     };
00129 
00131 template<typename ST> const ST Standard<time::Minute, ST>::ratio = 60.0;
00132 
00134 template<typename ST> const bool Standard<time::Minute, ST>::exact = true;
00135 
00137 
00139   template<typename ST>
00140     struct Standard<time::Hour, ST>
00141     {
00142       static const ST ratio;
00143       static const bool exact;
00144     };
00145 
00147 template<typename ST> const ST Standard<time::Hour, ST>::ratio = 3600.0;
00148 
00150 template<typename ST> const bool Standard<time::Hour, ST>::exact = true;
00151 
00153 
00155   template<typename ST>
00156     struct Standard<time::Day, ST>
00157     {
00158       static const ST ratio;
00159       static const bool exact;
00160     };
00161 
00163 template<typename ST> const ST Standard<time::Day, ST>::ratio = 86400.0;
00164 
00166 template<typename ST> const bool Standard<time::Day, ST>::exact = true;
00167 
00169 
00171   template<typename ST>
00172     struct Standard<time::Year, ST>
00173     {
00174       static const ST ratio;
00175       static const bool exact;
00176     };
00177 
00179 template<typename ST> const ST Standard<time::Year, ST>::ratio = 31556952.0;
00180 
00182 template<typename ST> const bool Standard<time::Year, ST>::exact = false;
00183 
00185 
00187   template<typename ST>
00188     struct Standard<time::Svedberg, ST>
00189     {
00190       static const ST ratio;
00191       static const bool exact;
00192     };
00193 
00195 template<typename ST> const ST Standard<time::Svedberg, ST>::ratio = 1.0e-13;
00196 
00198 template<typename ST> const bool Standard<time::Svedberg, ST>::exact = true;
00199 
00201 
00203   template<typename ST>
00204     struct Standard<time::Atomic, ST>
00205     {
00206       static const ST ratio;
00207       static const bool exact;
00208     };
00209 
00211 template<typename ST> const ST Standard<time::Atomic, ST>::ratio = 2.4188e-17;
00212 
00214 template<typename ST> const bool Standard<time::Atomic, ST>::exact = false;
00215 
00217 template<>
00218   struct QuantityTraits<time::Class>
00219   {
00220     typedef
00221       dimension::Dimension<BSUtilities::Rational<0>, 
00222         BSUtilities::Rational<0>, BSUtilities::Rational<1>,
00223           BSUtilities::Rational<0>, BSUtilities::Rational<0>, 
00224             BSUtilities::Rational<0>, BSUtilities::Rational<0> > Dimension;
00225     typedef time::Unit UnitType;
00226     typedef time::Units UnitList;
00227     typedef time::Second DefaultUnit;
00228 
00229     typedef time::DerivedTime DefaultDerivedQuantityType;
00230 
00231     static const std::string NameString;
00232     static const std::string SymbolString;
00233 
00234   };
00235 
00236 // the derived quantity traits template for derived Times
00237 template<>
00238   struct DerivedQuantityTraits<time::Class, time::DerivedTime>
00239   {
00240     static const bool OverwriteName = false;
00241     static const bool OverwriteSymbol = false;
00242 
00243     static const std::string NameString;
00244     static const std::string SymbolString;
00245 
00246   };
00247 
00249 typedef Variable<time::Quantity> Time;
00250 
00252 typedef Variable<time::IntQuantity> IntTime;
00253 
00255 typedef Variable<time::LongQuantity> LongTime;
00256 
00258 typedef Variable<time::Quantity, DerivedQuantity<time::Class, time::Minute> > MinuteTime;
00259 
00261 typedef Constant<time::Quantity> TimeConstant;
00262 
00264 typedef QuantityVector<Variable, time::Quantity> TimeVector;
00265 
00266 } // end namespace quantity
00267 
00268 #endif /* _Time_h */

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