00001 // -*- C++ -*- 00002 /*************************************************************************** 00003 * 00004 * The IPPL Framework 00005 * 00006 * 00007 * Visit http://people.web.psi.ch/adelmann/ for more details 00008 * 00009 ***************************************************************************/ 00010 00011 #ifndef PAWS_PAWS_TYPE_H 00012 #define PAWS_PAWS_TYPE_H 00013 00014 /*************************************************************************** 00015 * 00016 * PawsType is a simple templated class with partial specializations to 00017 * handle the basic types of data that Paws can transport. It is used 00018 * to convert from structures such as Vektor, Tenzor, etc. to arrays of 00019 * simple types like float, double, etc. 00020 * 00021 ***************************************************************************/ 00022 00023 // include files 00024 #include "AppTypes/Vektor.h" 00025 #include "AppTypes/Tenzor.h" 00026 #include "AppTypes/SymTenzor.h" 00027 #include "AppTypes/AntiSymTenzor.h" 00028 00029 00030 // the base version of PawsType, that makes things look like they are the 00031 // same type 00032 template<class T> 00033 struct PawsType 00034 { 00035 typedef T Type_t; 00036 enum { Size = 1 }; 00037 }; 00038 00039 00040 // make unsigned types look like the signed types 00041 #define PAWS_TYPE_UNSIGNED(TYPENAME) \ 00042 template<> \ 00043 struct PawsType<unsigned TYPENAME> \ 00044 { \ 00045 typedef PawsType<TYPENAME>::Type_t Type_t; \ 00046 enum { Size = PawsType<TYPENAME>::Size }; \ 00047 }; 00048 00049 PAWS_TYPE_UNSIGNED(char) 00050 PAWS_TYPE_UNSIGNED(short) 00051 PAWS_TYPE_UNSIGNED(int) 00052 PAWS_TYPE_UNSIGNED(long) 00053 00054 00055 // specializations to classes templated on a T and Dim. We could do this 00056 // without a macro if we had templated templates. 00057 #define PAWS_TYPE_T_DIM(CLASSNAME) \ 00058 template<class T, unsigned Dim> \ 00059 struct PawsType< CLASSNAME<T, Dim> > \ 00060 { \ 00061 typedef typename PawsType<T>::Type_t Type_t; \ 00062 enum { Size = CLASSNAME<T,Dim>::Size * PawsType<T>::Size }; \ 00063 }; 00064 00065 00066 // use the macro to handle the IPPL built-in types 00067 PAWS_TYPE_T_DIM(Vektor) 00068 PAWS_TYPE_T_DIM(Tenzor) 00069 PAWS_TYPE_T_DIM(SymTenzor) 00070 PAWS_TYPE_T_DIM(AntiSymTenzor) 00071 00072 #endif 00073 00074 /*************************************************************************** 00075 * $RCSfile: PawsType.h,v $ 00076 * $Revision: 1.1.1.1 $ 00077 * IPPL_VERSION_ID: $Id: PawsType.h,v 1.1.1.1 2003/01/23 07:40:32 adelmann Exp $ 00078 ***************************************************************************/