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

Dedimensionalization.h

Go to the documentation of this file.
00001 
00005 /* Copyright (C) 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 _Dedimensionalization_h
00025 #define _Dedimensionalization_h
00026 
00027 #include "Quantity/Quantity.h"
00028 #include "Quantity/QuantityError.h"
00029 
00030 #include "Functor.h"
00031 #include "HierarchyGenerators.h"
00032 
00033 namespace quantity {
00034 
00036 //
00037 //  the DedimReturn class
00038 //
00040 
00042 
00048 template<class PQ, class SU = typename PQ::DefaultUnit::Unit> 
00049                                          class DefaultDedimensionalizer;
00050 
00052 
00054 template<class PQ, class SU = typename PQ::DefaultUnit::Unit> 
00055                                                       class DedimReturn;
00056 
00058 
00062 template<long RL_N, long RL_D, long RM_N, long RM_D, 
00063   long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
00064     long RA_N, long RA_D, long RLU_N, long RLU_D, 
00065                        class BT, class UL, class DU, class SU, class ST>
00066   class DedimReturn<Quantity<dimension::Dimension<
00067     BSUtilities::Rational<RL_N, RL_D>,
00068       BSUtilities::Rational<RM_N, RM_D>,  
00069         BSUtilities::Rational<RT_N, RT_D>,
00070           BSUtilities::Rational<RE_N, RE_D>,
00071             BSUtilities::Rational<RTE_N, RTE_D>, 
00072               BSUtilities::Rational<RA_N, RA_D>,
00073                 BSUtilities::Rational<RLU_N, RLU_D> >, 
00074                                                     BT, UL, DU, ST>, SU>
00075       : public
00076       Quantity<dimension::Dimension<BSUtilities::Rational<RL_N, RL_D>,
00077         BSUtilities::Rational<RM_N, RM_D>,  
00078           BSUtilities::Rational<RT_N, RT_D>,
00079             BSUtilities::Rational<RE_N, RE_D>,
00080               BSUtilities::Rational<RTE_N, RTE_D>, 
00081                 BSUtilities::Rational<RA_N, RA_D>,
00082                   BSUtilities::Rational<RLU_N, RLU_D> >, BT, UL, DU, ST>
00083   {
00084     private:
00086 
00089         ST _value;
00090 
00091     public:
00093       DedimReturn (void) : _value (ST(0)) {}
00094 
00096       DedimReturn (const ST &value) : _value (value) {}
00097 
00099 
00101         const std::string unitsymbol (void) const
00102                                                  {return SU::Symbol ();}
00103 
00105 
00107         const std::string unitname (void) const {return SU::Name ();}
00108 
00110 
00112         ST value (void) const {return _value;}
00113 
00115 
00118         ST standard_value (void) const
00119                              {return Standardize<SU, ST>::VAL (_value);}
00120 
00122 
00125       std::ostream & print_value (std::ostream &os) const
00126                           {return os << _value << " " << SU::Symbol ();}
00127 
00129 
00131       void operator>> (std::string &str) const
00132         {str 
00133              = BSUtilities::Conversion<DedimReturn>::to_string (*this);}
00134 
00136 
00140       std::ostream & operator>> (std::ostream &os) const
00141                                               {return this->print (os);}
00142 
00144 
00148     void save (BSUtilities::xmlw::XmlStream &os) const 
00149     {
00150       os << BSUtilities::xmlw::tag (Quantities::TAG)
00151          << BSUtilities::xmlw::attr (Quantities::MODETAG) << MODE 
00152 // to be added ...
00153       << BSUtilities::xmlw::endtag (Quantities::TAG);
00154     }
00155 
00157 
00160     void load (const TiXmlHandle node) const
00161     {
00162         TiXmlElement *element = node.Element();
00163 
00164         if (element
00165           && (element->ValueStr () == Quantities::TAG)
00166             && (element->Attribute (Quantities::MODETAG) == MODE))
00167         {
00168 // to be added ...
00169         }
00170         else
00171           throw LoadError
00172               ("error loading DedimReturn quantity: incorrect element");
00173     }
00174 
00176 
00180 //    PQ (???) * create (void) {return new DedimReturn;}
00181 // to be implemented
00182 
00184 
00186       static const std::string MODE;
00187 
00188   };
00189 
00190 template<long RL_N, long RL_D, long RM_N, long RM_D, 
00191   long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
00192     long RA_N, long RA_D, long RLU_N, long RLU_D, 
00193                        class BT, class UL, class DU, class SU, class ST>
00194   const std::string DedimReturn<Quantity<dimension::Dimension<
00195     BSUtilities::Rational<RL_N, RL_D>,
00196       BSUtilities::Rational<RM_N, RM_D>,  
00197         BSUtilities::Rational<RT_N, RT_D>,
00198           BSUtilities::Rational<RE_N, RE_D>,
00199             BSUtilities::Rational<RTE_N, RTE_D>, 
00200               BSUtilities::Rational<RA_N, RA_D>,
00201                 BSUtilities::Rational<RLU_N, RLU_D> >, 
00202                              BT, UL, DU, ST>, SU>::MODE = "DedimReturn";
00203 
00205 
00215 template<long RL_N, long RL_D, long RM_N, long RM_D, 
00216   long RT_N, long RT_D, long RE_N, long RE_D, long RTE_N, long RTE_D,
00217     long RA_N, long RA_D, long RLU_N, long RLU_D,  
00218                        class BT, class UL, class DU, class SU, class ST>
00219   class DefaultDedimensionalizer<Quantity<dimension::Dimension<
00220     BSUtilities::Rational<RL_N, RL_D>,
00221       BSUtilities::Rational<RM_N, RM_D>,  
00222         BSUtilities::Rational<RT_N, RT_D>,
00223           BSUtilities::Rational<RE_N, RE_D>,
00224             BSUtilities::Rational<RTE_N, RTE_D>, 
00225               BSUtilities::Rational<RA_N, RA_D>,
00226                 BSUtilities::Rational<RLU_N, RLU_D> >, 
00227                                                     BT, UL, DU, ST>, SU>
00228     {
00229       private:
00230         typedef Quantity<dimension::Dimension<
00231           BSUtilities::Rational<RL_N, RL_D>,
00232             BSUtilities::Rational<RM_N, RM_D>,  
00233               BSUtilities::Rational<RT_N, RT_D>,
00234                 BSUtilities::Rational<RE_N, RE_D>,
00235                   BSUtilities::Rational<RTE_N, RTE_D>, 
00236                     BSUtilities::Rational<RA_N, RA_D>,
00237                       BSUtilities::Rational<RLU_N, RLU_D> >, 
00238                                                      BT, UL, DU, ST> PQ;
00239 
00240 
00241       public: 
00242         typedef Loki::Functor<DedimReturn<PQ, SU>,  
00243           LOKI_TYPELIST_1(Loki::Tuple<LOKI_TYPELIST_1
00244                                                  (Loki::EmptyType)>)> F;
00245     };
00246 
00247 }
00248 
00249 #endif /* _Dedimensionalization_h */

Generated on Mon Feb 12 18:43:57 2007 for Quantity by doxygen 1.3.6