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

Generic.h

Go to the documentation of this file.
00001 
00005 /* Copyright (C) 2002 - 2005, 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 _Generic_h
00025 #define _Generic_h
00026 
00027 #include "Quantity/Unit.h"
00028 #include "Quantity/Quantity.h"
00029 
00030 namespace quantity {
00031 
00032 /* the Generic quantity */
00033 
00035 
00040 template<class DIM> struct GenericClass {};
00041 
00042 }
00043 
00044 namespace unit {
00045 
00047 class GenericUnit;
00048 
00050 //
00051 //  the Generic Unit
00052 //
00054 
00056 
00062 template<class DIM> 
00063   class NonPrefixable<quantity::GenericClass<DIM>, GenericUnit> 
00064                            : public Unit<quantity::GenericClass<DIM> >
00065   {
00066     private:
00067       static const bool SI;
00068 
00069    public:
00070       static const bool IsSI (void) {return SI;}
00071 
00072       const bool isSI (void) const {return IsSI ();}
00073 
00074       static const std::string Namestring;
00075 
00076       static std::string Name (void) {return Namestring;}
00077 
00078       const std::string name (void) const {return Name ();}
00079 
00080       static const std::string Symbolstring;
00081 
00082       static std::string Symbol (void) {return Symbolstring;}
00083 
00084       const std::string symbol (void) const {return Symbol ();}
00085 
00086       void save (BSUtilities::xmlw::XmlStream &os) const
00087       {
00088         os << BSUtilities::xmlw::tag (Units::TAG)
00089            << BSUtilities::xmlw::attr (Units::TYPETAG) << TYPE
00090 // to be added ...
00091         << BSUtilities::xmlw::endtag (Units::TAG);
00092       }
00093 
00095 
00097       static const std::string TYPE;
00098 
00099   };
00100 
00101 template<class DIM> const bool 
00102   NonPrefixable<quantity::GenericClass<DIM>, GenericUnit>::SI = false;
00103 
00104 template<class DIM> const 
00105   std::string 
00106     NonPrefixable<quantity::GenericClass<DIM>, GenericUnit>
00107                                                       ::Namestring = "";
00108 
00109 template<class DIM> const 
00110   std::string 
00111     NonPrefixable<quantity::GenericClass<DIM>, GenericUnit>
00112                                       ::Symbolstring = "(unknown unit)";
00113 
00115 template<class DIM>
00116   const std::string NonPrefixable<quantity::GenericClass<DIM>, 
00117                                          GenericUnit>::TYPE = "generic";
00118 
00119 }
00120 
00121 namespace quantity {
00122 
00124 //
00125 //  the Generic Quantity
00126 //
00128 
00130 template<class DIM, class UL, class DU, class ST>
00131               struct Name<Quantity<DIM, GenericClass<DIM>, UL, DU, ST> >
00132   {
00134     static const std::string String;
00135   };
00136 
00137 template<class DIM, class UL, class DU, class ST>
00138   const std::string 
00139        Name<Quantity<DIM, GenericClass<DIM>, UL, DU, ST> >::String = "";
00140 
00142 template<class DIM, class UL, class DU, class ST>
00143             struct Symbol<Quantity<DIM, GenericClass<DIM>, UL, DU, ST> >
00144   {
00146     static const std::string String;
00147   };
00148 
00150 template<class DIM, class UL, class DU, class ST>
00151   const std::string 
00152      Symbol<Quantity<DIM, GenericClass<DIM>, UL, DU, ST> >::String = "";
00153 
00155 template<class DIM, class ST>
00156   struct Standard<unit::NonPrefixable<GenericClass<DIM>, 
00157                                                  unit::GenericUnit>, ST>
00158   {
00159     static const ST ratio;
00160     static const bool exact;
00161   };
00162 
00164 template<class DIM, class ST>
00165   const ST
00166     Standard<unit::NonPrefixable<GenericClass<DIM>, 
00167                                unit::GenericUnit>, ST>::ratio = ST(1.0);
00168 
00170 template<class DIM, class ST>
00171   const bool
00172     Standard<unit::NonPrefixable<GenericClass<DIM>, 
00173                                   unit::GenericUnit>, ST>::exact = true;
00174 
00175 }
00176 
00177 #endif /* _Generic_h */

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