Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members

Digital.h

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2002 - 2006, Bernd Speiser */
00005 
00006 /* This file is part of Quantities.
00007 
00008 PhysicalQuantities is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 PhysicalQuantities is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License for more details.
00017   
00018 You should have received a copy of the GNU General Public License
00019 along with this program; if not, write to the Free Software
00020 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00021 02111-1307, USA.
00022 */
00023 
00024 #ifndef _Digital_h
00025 #define _Digital_h
00026 
00027 #include "Quantity/Variable.h"
00028 #include "Quantity/Constant.h"
00029 
00030 namespace quantity {
00032   namespace digital {
00033 
00034 /* Digital dimension */
00035 typedef BSUtilities::Rational<0> LE;
00036 typedef BSUtilities::Rational<0> M;
00037 typedef BSUtilities::Rational<0> TI;
00038 typedef BSUtilities::Rational<0> E;
00039 typedef BSUtilities::Rational<0> TE;
00040 typedef BSUtilities::Rational<0> A;
00041 typedef BSUtilities::Rational<0> LU;
00042 
00043 typedef dimension::Dimension<LE, M, TI, E, TE, A, LU> Dimension;
00044 
00046 class Unit;
00047 
00048 /* declaration of Digital units */
00049 class DigitalUnit;
00050 
00051 /* the digital unity unit */
00052 
00053 typedef unit::NonPrefixable<Unit, DigitalUnit> Unity;
00054 
00055 typedef LOKI_TYPELIST_1(Unity) Units;
00056 
00057 /* Digital quantity */
00058 
00059 typedef quantity::Quantity<Dimension, Unit, Units, Unity, bool> 
00060                                                                Quantity;
00061 
00062 }
00063 
00065 //
00066 // specializations of functionality; some application programs may
00067 // need specific requirements for Digital. Such requirements can be
00068 // added here.
00069 //
00071 
00073 //
00074 // GenerateVariable Add and Sub functions for two Quantities, 
00075 // the first of which has storage type bool 
00076 //
00078 
00080 
00085 template<template<class, class> class Q1, class BT1,
00086   long RL1_N, long RL1_D, long RM1_N, long RM1_D,
00087     long RT1_N, long RT1_D, long RE1_N, long RE1_D,
00088       long RTE1_N, long RTE1_D, long RA1_N, long RA1_D,
00089         long RLU1_N, long RLU1_D, class UL1, class DU1, class SU1,
00090          template<class, class> class Q2, class BT2,
00091           long RL2_N, long RL2_D, long RM2_N, long RM2_D,
00092              long RT2_N, long RT2_D, long RE2_N, long RE2_D,
00093                long RTE2_N, long RTE2_D, long RA2_N, long RA2_D,
00094                  long RLU2_N, long RLU2_D,
00095                               class UL2, class DU2, class SU2, class ST>
00096   struct GenerateVariable
00097     <Q1<Quantity<
00098       dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
00099         BSUtilities::Rational<RM1_N, RM1_D>,
00100           BSUtilities::Rational<RT1_N, RT1_D>,
00101             BSUtilities::Rational<RE1_N, RE1_D>,
00102               BSUtilities::Rational<RTE1_N, RTE1_D>,
00103                 BSUtilities::Rational<RA1_N, RA1_D>,
00104                   BSUtilities::Rational<RLU1_N, RLU1_D> >,
00105                                              BT1, UL1, DU1, bool>, SU1>,
00106      Q2<Quantity<
00107       dimension::Dimension<BSUtilities::Rational<RL2_N, RL2_D>,
00108         BSUtilities::Rational<RM2_N, RM2_D>,
00109           BSUtilities::Rational<RT2_N, RT2_D>,
00110             BSUtilities::Rational<RE2_N, RE2_D>,
00111               BSUtilities::Rational<RTE2_N, RTE2_D>,
00112                 BSUtilities::Rational<RA2_N, RA2_D>,
00113                   BSUtilities::Rational<RLU2_N, RLU2_D> >,
00114                                               BT2, UL2, DU2, ST>, SU2> >
00115   {
00116      private:
00118        typedef typename
00119          dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
00120            BSUtilities::Rational<RM1_N, RM1_D>,
00121              BSUtilities::Rational<RT1_N, RT1_D>,
00122                BSUtilities::Rational<RE1_N, RE1_D>,
00123                  BSUtilities::Rational<RTE1_N, RTE1_D>,
00124                    BSUtilities::Rational<RA1_N, RA1_D>,
00125                      BSUtilities::Rational<RLU1_N, RLU1_D> >
00126          ::template Add<dimension::Dimension<
00127            BSUtilities::Rational<RL2_N, RL2_D>,
00128              BSUtilities::Rational<RM2_N, RM2_D>,
00129                BSUtilities::Rational<RT2_N, RT2_D>,
00130                  BSUtilities::Rational<RE2_N, RE2_D>,
00131                    BSUtilities::Rational<RTE2_N, RTE2_D>,
00132                      BSUtilities::Rational<RA2_N, RA2_D>,
00133                          BSUtilities::Rational<RLU2_N, RLU2_D> > > AddT;
00134 
00135        typedef unit::NonPrefixable<GenericClass<typename AddT::Res>,
00136                                                unit::GenericUnit> AddU;
00137        typedef Loki::Typelist<AddU, Loki::NullType> AddUnits;
00138        typedef Quantity<typename AddT::Res,
00139           GenericClass<typename AddT::Res>, AddUnits, AddU, ST> AddNewQ;
00140 
00142        typedef typename
00143          dimension::Dimension<BSUtilities::Rational<RL1_N, RL1_D>,
00144            BSUtilities::Rational<RM1_N, RM1_D>,
00145              BSUtilities::Rational<RT1_N, RT1_D>,
00146                BSUtilities::Rational<RE1_N, RE1_D>,
00147                  BSUtilities::Rational<RTE1_N, RTE1_D>,
00148                    BSUtilities::Rational<RA1_N, RA1_D>,
00149                      BSUtilities::Rational<RLU1_N, RLU1_D> >
00150          ::template Sub<dimension::Dimension<
00151            BSUtilities::Rational<RL2_N, RL2_D>,
00152              BSUtilities::Rational<RM2_N, RM2_D>,
00153                BSUtilities::Rational<RT2_N, RT2_D>,
00154                  BSUtilities::Rational<RE2_N, RE2_D>,
00155                    BSUtilities::Rational<RTE2_N, RTE2_D>,
00156                      BSUtilities::Rational<RA2_N, RA2_D>,
00157                          BSUtilities::Rational<RLU2_N, RLU2_D> > > SubT;
00158 
00159        typedef unit::NonPrefixable<GenericClass<typename SubT::Res>,
00160                                                unit::GenericUnit> SubU;
00161        typedef Loki::Typelist<SubU, Loki::NullType> SubUnits;
00162        typedef Quantity<typename SubT::Res,
00163           GenericClass<typename SubT::Res>, SubUnits, SubU, ST> SubNewQ;
00164 
00165      public:
00166        typedef Variable<AddNewQ, AddU> Add;
00167        typedef Variable<SubNewQ, SubU> Sub;
00168   };
00169 
00171 typedef Variable<digital::Quantity> Digital;
00172 
00174 typedef Constant<digital::Quantity> DigitalConstant;
00175 
00176 namespace digital{
00178     extern const quantity::DigitalConstant On;
00180     extern const quantity::DigitalConstant Off;
00181                 }
00182 
00183   }
00184 
00185 #endif /* _Digital_h */

Generated on Sun Jan 15 14:05:27 2006 for GeneralQuantities by doxygen 1.3.6