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

Intermediate.h

Go to the documentation of this file.
00001 
00005 /* Copyright (C) 2002 - 2004, 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 _Intermediate_h
00025 #define _Intermediate_h
00026 
00027 #include "Quantity/Variable.h"
00028 #include "Quantity/Generic.h"
00029 
00030 namespace Quantities {
00031 
00033 //
00034 //  the Intermediate classes
00035 //
00037 
00039 template<class GT, class ST = double>
00040   class IntermediateQuantity 
00041     : public Variable<Quantity<GenericClass<GT>, 
00042       Loki::Typelist<Units::NonPrefixable<GenericClass<GT>, 
00043         Units::GenericUnit, ST>, Loki::NullType>,
00044         Units::NonPrefixable<GenericClass<GT>, Units::GenericUnit, ST>,
00045           ST>, Units::NonPrefixable<GenericClass<GT>, 
00046                                                Units::GenericUnit, ST> >
00047   {
00048     private:
00049       IntermediateQuantity () {}
00050 
00051       typedef Variable<Quantity<GenericClass<GT>, 
00052         Loki::Typelist<Units::NonPrefixable<GenericClass<GT>, 
00053           Units::GenericUnit, ST>, Loki::NullType>,
00054             Units::NonPrefixable<GenericClass<GT>, Units::GenericUnit,
00055                                                                ST>, ST>,
00056               Units::NonPrefixable<GenericClass<GT>, Units::GenericUnit,
00057                                                                 ST> > V;
00058 
00059       class GeneralStore {};
00060 
00061       template <template<class, class> class Q1, class GT1, 
00062                           class Head1, class Tail1, class DU1, class U1>
00063         class Store : public GeneralStore
00064         {
00065           private:
00066             typedef 
00067               Q1<Quantity<GT1, Loki::Typelist<Head1, Tail1>, DU1, ST>, 
00068                                                                   U1> Q;
00069             Q stored;
00070 
00071             Store () {}
00072 
00073           public: 
00074             Store (const Q &source) : stored (source) {}
00075         };
00076 
00077       GeneralStore *store;
00078       
00079     public:
00080       IntermediateQuantity (IntermediateQuantity &intermediate) {}
00081 
00082     // conversion from any quantity into Intermediate
00083       template <template<class, class> class Q1, class GT1, 
00084                           class Head1, class Tail1, class DU1, class U1>
00085       IntermediateQuantity 
00086         (const 
00087           Q1<Quantity<GT1, Loki::Typelist<Head1, Tail1>, DU1, ST>, U1> 
00088                                                               &quantity)
00089           {
00090            store = new Store<Q1, GT1, Head1, Tail1, DU1, U1> (quantity);
00091           }
00092   };
00093 
00094 // doesn't work yet
00096 
00098 typedef IntermediateQuantity<double> Intermediate;
00100 
00102 typedef IntermediateQuantity<int> IntIntermediate;
00103 }
00104 
00105 #endif /* _Intermediate_h */

Generated on Sun Jan 15 13:57:59 2006 for Quantity by doxygen 1.3.6