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

UniqueConstant.h

Go to the documentation of this file.
00001 
00005 /* Copyright (C) 2002 - 2006, Bernd Speiser */
00006 /* This file is part of Quantity.
00007 
00008 Quantity 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 Quantity 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 _UniqueConstant_h
00025 #define _UniqueConstant_h
00026 
00027 #include "Quantity/Quantity.h"
00028 #include "Quantity/QuantityError.h"
00029 #include "Quantity/Dedimensionalization.h"
00030 #include "Quantity/Variable.h"
00031 
00032 #include "Singleton.h"
00033 
00034 namespace quantity {
00035 
00037 //
00038 //  the UniqueConstant classes
00039 //
00041 
00043 
00048 template<class PQ, class SU = typename PQ::DefaultUnit::Unit,
00049   class DD = typename DefaultDedimensionalizer<PQ, SU>::F> class UniqueConstant;
00050 
00052 
00055 template<long RL_N, long RL_D, long RM_N, long RM_D,
00056   long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
00057     long RA_N, long RA_D, long RLU_N, long RLU_D,
00058       class BT, class UL, class DU, class SU, class ST, class R, 
00059                                                      class NH, class NT>
00060   class UniqueConstant<Quantity<dimension::Dimension<
00061     BSUtilities::Rational<RL_N, RL_D>,
00062       BSUtilities::Rational<RM_N, RM_D>,
00063         BSUtilities::Rational<RT_N, RT_D>,
00064           BSUtilities::Rational<RE_N, RE_D>,
00065             BSUtilities::Rational<RTE_N, RTE_D>,
00066               BSUtilities::Rational<RA_N, RA_D>,
00067                 BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>,
00068                   SU, Loki::Functor<R, Loki::Typelist<NH, NT> > > 
00069       : public
00070       Quantity<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
00071         BSUtilities::Rational<RM_N, RM_D>,
00072           BSUtilities::Rational<RT_N, RT_D>,
00073             BSUtilities::Rational<RE_N, RE_D>,
00074               BSUtilities::Rational<RTE_N, RTE_D>,
00075                 BSUtilities::Rational<RA_N, RA_D>,
00076                   BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>
00077 
00078     {
00079       public:
00081 
00083         typedef dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
00084             BSUtilities::Rational<RM_N, RM_D>,
00085               BSUtilities::Rational<RT_N, RT_D>,
00086                 BSUtilities::Rational<RE_N, RE_D>,
00087                   BSUtilities::Rational<RTE_N, RTE_D>,
00088                     BSUtilities::Rational<RA_N, RA_D>,
00089                               BSUtilities::Rational<RLU_N, RLU_D> > DIM;
00090 
00092         typedef typename Loki::Typelist<NH, NT> DDL; 
00093  
00095 
00101         typedef typename Loki::TL::TypeAt<DDL, 0>::Result DDP;
00102 
00104         typedef typename Loki::Functor<R, DDL> DD;
00105 
00107 
00110         typedef Quantity<DIM, BT, UL, DU, ST> ABQ; 
00111 
00113 
00115         typedef UniqueConstant<ABQ, SU, DD> UC;
00116 
00118 
00122         typedef ABQ PQ;
00123 
00125 
00128         friend class Loki::CreateUsingNew<UC>;
00129 
00131 
00136         typedef 
00137              typename unit::CheckUnit<unit::Unit<BT>, SU>::Check Unit;
00138 
00140         typedef typename BSUtilities::IF<BSUtilities::SameType
00141           <DD, typename DefaultDedimensionalizer<PQ, SU>::F>::sameType,
00142                                        DedimReturn<PQ, SU>, UC>::RET DDR;
00143 
00144       private:
00146 
00150         static DDR defaultDedimensionalizer (DDP) {return DDR(ST(1.));}
00151 
00153 
00155         static const DD _defaultDD;
00156 
00158 
00166         DD _dedimensionalizer;
00167 
00169 
00173         static const ST default_value_;
00174 
00176 
00179         ST constant_value;
00180 
00181       private:
00183 
00189         UniqueConstant (void) : ABQ (), _dedimensionalizer (_defaultDD),
00190                                       constant_value (default_value_) {}
00191 
00192       private:
00194 
00198         UniqueConstant (const UniqueConstant &new_constant)
00199           : ABQ (), _dedimensionalizer (new_constant._dedimensionalizer), 
00200                                          constant_value (default_value_)
00201             {ABQ::namestring = new_constant.name ();
00202              ABQ::symbolstring = new_constant.symbol ();
00203             }
00204 
00205       public:
00207 
00209         ST value (void) const {return constant_value;}
00210 
00212 
00215         ST standard_value (void) const 
00216                      {return Standardize<SU, ST>::VAL (constant_value);}
00217 
00219 
00224         template<class NU>
00225           ST value (const unit::NonPrefixable<BT, NU> &) const
00226             {return Reverse<typename CheckAgainstAllUnits<
00227               unit::NonPrefixable<BT, NU>, UL>::RET, ST>::VAL
00228                            (Standardize<SU, ST>::VAL (constant_value));}
00229 
00231 
00236         template<class NU, class P>
00237           ST value
00238             (const unit::Prefixed<unit::Prefixable<BT, NU>, P> &) const
00239             {return Reverse<typename CheckAgainstAllUnits<
00240               unit::Prefixed<unit::Prefixable<BT, NU>, P>, UL>::RET, 
00241                   ST>::VAL (Standardize<SU, ST>::VAL (constant_value));}
00242 
00244 
00249         template<class CUL, class EL>
00250           ST value
00251             (const unit::Composed<unit::ComposeBase<BT, CUL>, EL> &)
00252                                                                    const
00253             {return Reverse<typename CheckAgainstAllUnits<
00254               unit::Composed<unit::ComposeBase<BT, CUL>, EL>, UL>::RET,
00255                   ST>::VAL (Standardize<SU, ST>::VAL (constant_value));}
00256 
00258 
00265         ST value (const std::string &symbol)
00266           {
00267             ST value;
00268             ::unit::Unit<BT> *unitp = PQ::findBySymbol (symbol);
00269 
00270             value = dynamic_reverse<UL>::VAL
00271                     (Standardize<SU, ST>::VAL (constant_value), *unitp);
00272 
00273             delete (unitp);
00274 
00275             return value;
00276           }
00277 
00279 
00285         template<class NU>
00286           Variable<PQ, NU, DD> operator () (const NU &) const
00287             {return Variable<PQ, NU, DD> (constant_value, SU());}
00288 
00290 
00292         const std::string unitsymbol (void) const 
00293                                                  {return SU::Symbol ();}
00294 
00296 
00298         static std::string Unitsymbol (void) {return SU::Symbol ();}
00299 
00301 
00303         const std::string unitname (void) const {return SU::Name ();}
00304 
00306 
00308         static std::string Unitname (void) {return SU::Name ();}
00309 
00311 
00314         Variable<PQ, SU, DD> operator+ (void) const
00315            {Variable<PQ, SU, DD> new_constant (*this);
00316              return new_constant;
00317            }
00318 
00320 
00323         Variable<PQ, SU, DD> operator- (void) const
00324            {Variable<PQ, SU, DD> new_constant (*this);
00325              return new_constant *= -ST(1.0);
00326            }
00327 
00329 
00332         template <class Q>
00333           Variable<PQ, SU> operator+ (const Q &new_variable) const
00334             {Variable<PQ, SU> new_object = *this;
00335               return new_object += new_variable;
00336             }
00337 
00339 
00343         template <class Q>
00344           Variable<PQ, SU> operator- (const Q &new_variable) const
00345             {Variable<PQ, SU> new_object = *this;
00346               return new_object -= new_variable;
00347             }
00348 
00350 
00353         Variable<PQ, SU> operator* (const ST factor) const
00354           {Variable<PQ, SU> new_object = *this;
00355             return new_object *= factor;
00356           }
00357 
00359 
00362         Variable<PQ, SU> operator/ (const ST factor) const
00363           {Variable<PQ, SU> new_object = *this;
00364             return new_object /= factor;
00365           }
00366 
00368 
00372         bool operator== (const UniqueConstant &rhs_variable) const
00373                    {return constant_value == rhs_variable.value ();}
00374 
00376 
00382         template <template<class, class, class> class Q1, 
00383                                                     class SU1, class N1>
00384           bool operator== (const Q1<PQ, SU1, N1> &rhs_variable) const
00385             {return standard_value () == rhs_variable.standard_value ();
00386             }
00387 
00389 
00395         template <template<class, class, class> class Q1,
00396           class DIM1, class BT1, class UL1, class DU1, class SU1, 
00397                                                                class N1>
00398           bool operator==
00399             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00400                                                     &rhs_variable) const
00401             {
00402              return standard_value () == Standardize<typename
00403                CheckSecondDimension<Variable<PQ, SU>,
00404                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00405                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00406             }
00407 
00409 
00416         bool operator== (const Dynamic<ST> &dynamic) const
00417           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00418              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00419              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00420              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00421              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00422              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00423              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00424              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00425              && dynamic._rte_n
00426                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00427              && dynamic._rte_d
00428                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00429              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00430              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00431              && dynamic._rlu_n
00432                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00433              && dynamic._rlu_d
00434                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00435 
00436              return standard_value () == dynamic.value ();
00437 
00438             else
00439                {throw DimensionMismatch ();}
00440 
00441           }
00442 
00444 
00449         bool operator!= (const UniqueConstant &rhs_variable) const
00450                    {return constant_value != rhs_variable.value ();}
00451 
00453 
00459         template <template<class, class, class> class Q1, 
00460                                                     class SU1, class N1>
00461           bool operator!= (const Q1<PQ, SU1, N1> &rhs_variable) const
00462             {return standard_value () != rhs_variable.standard_value ();
00463             }
00464 
00466 
00472         template <template<class, class, class> class Q1,
00473           class DIM1, class BT1, class UL1, class DU1, class SU1,
00474                                                                class N1>
00475           bool operator!=
00476             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00477                                                     &rhs_variable) const
00478             {
00479              return standard_value () != Standardize<typename
00480                CheckSecondDimension<Variable<PQ, SU>,
00481                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00482                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00483             }
00484 
00486 
00493         bool operator!= (const Dynamic<ST> &dynamic) const
00494           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00495              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00496              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00497              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00498              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00499              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00500              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00501              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00502              && dynamic._rte_n
00503                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00504              && dynamic._rte_d
00505                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00506              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00507              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00508              && dynamic._rlu_n
00509                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00510              && dynamic._rlu_d
00511                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00512 
00513              return standard_value () != dynamic.value ();
00514 
00515             else
00516                {throw DimensionMismatch ();}
00517 
00518           }
00519 
00521 
00526         bool operator> (const UniqueConstant &rhs_variable) const
00527                    {return constant_value > rhs_variable.value ();}
00528 
00530 
00536         template <template<class, class, class> class Q1, 
00537                                                     class SU1, class N1>
00538           bool operator> (const Q1<PQ, SU1, N1> &rhs_variable) const
00539             {return standard_value () > rhs_variable.standard_value ();
00540             }
00541 
00543 
00549         template <template<class, class, class> class Q1,
00550           class DIM1, class BT1, class UL1, class DU1, class SU1, 
00551                                                                class N1>
00552           bool operator>
00553             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00554                                                     &rhs_variable) const
00555             {
00556              return standard_value () > Standardize<typename
00557                CheckSecondDimension<Variable<PQ, SU>,
00558                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00559                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00560             }
00561 
00563 
00570         bool operator> (const Dynamic<ST> &dynamic) const
00571           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00572              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00573              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00574              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00575              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00576              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00577              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00578              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00579              && dynamic._rte_n
00580                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00581              && dynamic._rte_d
00582                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00583              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00584              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00585              && dynamic._rlu_n
00586                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00587              && dynamic._rlu_d
00588                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00589 
00590              return standard_value () > dynamic.value ();
00591 
00592             else
00593                {throw DimensionMismatch ();}
00594 
00595           }
00596 
00598 
00603         bool operator< (const UniqueConstant &rhs_variable) const
00604                    {return constant_value < rhs_variable.value ();}
00605 
00607 
00613         template <template<class, class, class> class Q1, class SU1, 
00614                                                                class N1>
00615           bool operator< (const Q1<PQ, SU1, N1> &rhs_variable) const
00616             {return standard_value () < rhs_variable.standard_value ();
00617             }
00618 
00620 
00626         template <template<class, class, class> class Q1,
00627           class DIM1, class BT1, class UL1, class DU1, class SU1, 
00628                                                                class N1>
00629           bool operator<
00630             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00631                                                     &rhs_variable) const
00632             {
00633              return standard_value () < Standardize<typename
00634                CheckSecondDimension<Variable<PQ, SU>,
00635                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00636                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00637             }
00638 
00640 
00647         bool operator< (const Dynamic<ST> &dynamic) const
00648           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00649              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00650              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00651              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00652              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00653              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00654              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00655              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00656              && dynamic._rte_n
00657                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00658              && dynamic._rte_d
00659                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00660              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00661              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00662              && dynamic._rlu_n
00663                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00664              && dynamic._rlu_d
00665                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00666 
00667              return standard_value () < dynamic.value ();
00668 
00669             else
00670                {throw DimensionMismatch ();}
00671 
00672           }
00673 
00675 
00680         bool operator>= (const UniqueConstant &rhs_variable) const
00681                    {return constant_value >= rhs_variable.value ();}
00682 
00684 
00690         template <template<class, class, class> class Q1, 
00691                                                     class SU1, class N1>
00692           bool operator>= (const Q1<PQ, SU1, N1> &rhs_variable) const
00693             {return standard_value () >= rhs_variable.standard_value ();
00694             }
00695 
00697 
00703         template <template<class, class, class> class Q1,
00704           class DIM1, class BT1, class UL1, class DU1, class SU1, 
00705                                                                class N1>
00706           bool operator>=
00707             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00708                                                     &rhs_variable) const
00709             {
00710              return standard_value () >= Standardize<typename
00711                CheckSecondDimension<Variable<PQ, SU>,
00712                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00713                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00714             }
00715 
00717 
00724         bool operator>= (const Dynamic<ST> &dynamic) const
00725           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00726              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00727              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00728              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00729              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00730              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00731              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00732              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00733              && dynamic._rte_n
00734                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00735              && dynamic._rte_d
00736                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00737              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00738              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00739              && dynamic._rlu_n
00740                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00741              && dynamic._rlu_d
00742                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00743 
00744              return standard_value () >= dynamic.value ();
00745 
00746             else
00747                {throw DimensionMismatch ();}
00748 
00749           }
00750 
00752 
00757         bool operator<= (const UniqueConstant &rhs_variable) const
00758                    {return constant_value <= rhs_variable.value ();}
00759 
00761 
00767         template <template<class, class, class> class Q1, 
00768                                                     class SU1, class N1>
00769           bool operator<= (const Q1<PQ, SU1, N1> &rhs_variable) const
00770             {return standard_value () <= rhs_variable.standard_value ();
00771             }
00772 
00774 
00780         template <template<class, class, class> class Q1,
00781           class DIM1, class BT1, class UL1, class DU1, class SU1, 
00782                                                                class N1>
00783           bool operator<=
00784             (const Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00785                                                     &rhs_variable) const
00786             {
00787              return standard_value () <= Standardize<typename
00788                CheckSecondDimension<Variable<PQ, SU>,
00789                  Q1<Quantity<DIM1, BT1, UL1, DU1, ST>, SU1, N1>
00790                          >::RET::Unit, ST>::VAL (rhs_variable.value ());
00791             }
00792 
00794 
00801         bool operator<= (const Dynamic<ST> &dynamic) const
00802           {if (dynamic._rl_n == RL_N/BSUtilities::Gcd<RL_N, RL_D>::RET
00803              && dynamic._rl_d == RL_D/BSUtilities::Gcd<RL_N, RL_D>::RET
00804              && dynamic._rm_n == RM_N/BSUtilities::Gcd<RM_N, RM_D>::RET
00805              && dynamic._rm_d == RM_D/BSUtilities::Gcd<RM_N, RM_D>::RET
00806              && dynamic._rt_n == RT_N/BSUtilities::Gcd<RT_N, RT_D>::RET
00807              && dynamic._rt_d == RT_D/BSUtilities::Gcd<RT_N, RT_D>::RET
00808              && dynamic._re_n == RE_N/BSUtilities::Gcd<RE_N, RE_D>::RET
00809              && dynamic._re_d == RE_D/BSUtilities::Gcd<RE_N, RE_D>::RET
00810              && dynamic._rte_n
00811                             == RTE_N/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00812              && dynamic._rte_d
00813                             == RTE_D/BSUtilities::Gcd<RTE_N, RTE_D>::RET
00814              && dynamic._ra_n == RA_N/BSUtilities::Gcd<RA_N, RA_D>::RET
00815              && dynamic._ra_d == RA_D/BSUtilities::Gcd<RA_N, RA_D>::RET
00816              && dynamic._rlu_n
00817                             == RLU_N/BSUtilities::Gcd<RLU_N, RLU_D>::RET
00818              && dynamic._rlu_d
00819                            == RLU_D/BSUtilities::Gcd<RLU_N, RLU_D>::RET)
00820 
00821              return standard_value () <= dynamic.value ();
00822 
00823             else
00824                {throw DimensionMismatch ();}
00825 
00826           }
00827 
00829 
00834         template<class Q>
00835           typename GenerateVariable<UniqueConstant, Q>::Add operator*
00836                                                        (const Q &factor)
00837             {
00838               return typename 
00839                 GenerateVariable<UniqueConstant, Q>::Add
00840                          (standard_value () * factor.standard_value ());
00841             }
00842 
00844 
00849         template<class Q>
00850           typename GenerateVariable<UniqueConstant, Q>::Sub 
00851                                              operator/ (const Q &factor)
00852             {
00853               return typename 
00854                 GenerateVariable<UniqueConstant, Q>::Sub
00855                          (standard_value () / factor.standard_value ());
00856             }
00857 
00859 
00862         friend 
00863           typename GenerateVariable<UniqueConstant, Loki::NullType>::Inv
00864             operator/ (const ST numerator, const UniqueConstant &factor)
00865           {
00866             return typename 
00867               GenerateVariable<UniqueConstant, Loki::NullType>::Inv
00868                                  (numerator / factor.standard_value ());
00869           }
00870 
00872 
00878         template<long N, long D> 
00879           typename GenerateVariable<UniqueConstant,
00880                                      BSUtilities::Rational<N, D> >::Mult
00881                          pow (const BSUtilities::Rational<N, D> &) const
00882           {return std::pow (standard_value (), 
00883                         static_cast<double>(N)/static_cast<double>(D));}
00884 
00886 
00892         template<int I>
00893           typename GenerateVariable<UniqueConstant,
00894               BSUtilities::Rational<I, long(1)> >::Mult 
00895                             pow (const typename Loki::Int2Type<I>) const
00896           {return std::pow (standard_value (), I);}
00897 
00899 
00905     template<class T>
00906       Dynamic<ST> pow (const T &exp) const
00907                                 {return Dynamic<ST>::pow (*this, exp);}
00908 
00910 
00912         friend
00913           typename
00914             GenerateVariable<UniqueConstant, 
00915                                      BSUtilities::Rational<1, 2> >::Mult
00916                                    sqrt (const UniqueConstant &constant)
00917           {
00918             return typename
00919               GenerateVariable<UniqueConstant, 
00920                 BSUtilities::Rational<1, 2> >::Mult
00921                                 (std::sqrt(constant.standard_value ()));
00922           }
00923 
00925 
00927         typename
00928           GenerateVariable<UniqueConstant, 
00929                                      BSUtilities::Rational<1, 2> >::Mult
00930                                                              sqrt (void)
00931           {
00932             return typename
00933               GenerateVariable<UniqueConstant, 
00934                 BSUtilities::Rational<1, 2> >::Mult
00935                                          (std::sqrt(standard_value ()));
00936           }
00937 
00939 
00942      std::ostream & print_value (std::ostream &os) const
00943         {return os << constant_value << " " << SU::Symbol ();}
00944 
00946 
00948       void operator>> (std::string &str) const
00949         {str = BSUtilities::Conversion<UniqueConstant>::to_string 
00950                                                                (*this);}
00952 
00956       std::ostream & operator>> (std::ostream &os) const
00957                    {return this->print (os);}
00958 
00960 
00964     void save (BSUtilities::xmlw::XmlStream &os) const 
00965     {
00966       os << BSUtilities::xmlw::tag (Quantities::TAG)
00967          << BSUtilities::xmlw::attr (Quantities::MODETAG) << MODE 
00968 // to be added ...
00969       << BSUtilities::xmlw::endtag (Quantities::TAG);
00970     }
00971 
00973 
00976     void load (const TiXmlHandle node) const
00977     {
00978         TiXmlElement *element = node.Element();
00979 
00980         if (element
00981           && (element->ValueStr () == Quantities::TAG)
00982             && (element->Attribute (Quantities::MODETAG) == MODE))
00983         {
00984 // to be added ...
00985         }
00986         else
00987           throw LoadError
00988             ("error loading unique constant quantity: "
00989                                                    "incorrect element");
00990     }
00991 
00993 
00997 //    PQ (???) * create (void) {return new UniqueConstant;}
00998 // to be implemented
00999 
01000 
01002 
01004       static const std::string MODE;
01005 
01006     };
01007 
01009 template<long RL_N, long RL_D, long RM_N, long RM_D, 
01010   long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01011     long RA_N, long RA_D, long RLU_N, long RLU_D,  
01012       class BT, class UL, class DU, class SU, class ST, class R, 
01013                                                      class NH, class NT>
01014   const std::string UniqueConstant<Quantity<dimension::Dimension<
01015     BSUtilities::Rational<RL_N, RL_D>,
01016       BSUtilities::Rational<RM_N, RM_D>,
01017         BSUtilities::Rational<RT_N, RT_D>,
01018           BSUtilities::Rational<RE_N, RE_D>,
01019             BSUtilities::Rational<RTE_N, RTE_D>,
01020               BSUtilities::Rational<RA_N, RA_D>,
01021                 BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>,
01022                   SU, Loki::Functor<R, Loki::Typelist<NH, NT> > >::MODE
01023                                                      = "uniqueConstant";
01024 
01026 template<long RL_N, long RL_D, long RM_N, long RM_D, 
01027   long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
01028     long RA_N, long RA_D, long RLU_N, long RLU_D,  
01029       class BT, class UL, class DU, class SU, class ST, class R, 
01030                                                      class NH, class NT>
01031 const typename Loki::Functor<R, typename Loki::Typelist<NH, NT> >
01032   UniqueConstant<Quantity<dimension::Dimension<
01033     BSUtilities::Rational<RL_N, RL_D>,
01034       BSUtilities::Rational<RM_N, RM_D>,
01035         BSUtilities::Rational<RT_N, RT_D>,
01036           BSUtilities::Rational<RE_N, RE_D>,
01037             BSUtilities::Rational<RTE_N, RTE_D>,
01038               BSUtilities::Rational<RA_N, RA_D>,
01039                 BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>,
01040                   SU, Loki::Functor<R, Loki::Typelist<NH, NT> 
01041                                                         > >::_defaultDD =
01042     typename Loki::Functor<R, typename Loki::Typelist<NH, NT> >
01043                                              (defaultDedimensionalizer);
01044 
01045 }
01046 
01047 #endif /* _UniqueConstant_h */

Generated on Mon Feb 12 18:48:39 2007 for Quantity by doxygen 1.3.6