HDF5Field.hpp

00001 
00002 //
00003 // $Id: HDF5Field.hpp,v 1.4 2007/09/17 21:48:54 werner Exp $
00004 //
00006 #ifndef __FIBER_HDF5FIELD_HPP
00007 #define __FIBER_HDF5FIELD_HPP "Created 27.02.2001 21:42:27 by werner"
00008 
00009 #include "HDF5Bundle.hpp"
00010 #include "HDF5MemArrayStorage.hpp"
00011 
00012 #include <F5/F5private.h>
00013 
00014 #include <vecal/CartesianCoordinates.hpp>
00015 #include <vecal/CartesianChart.hpp>
00016 #include <vecal/ipol/ViewMultiArray.hpp>
00017 #include <vecal/ipol/STLMultiArray.hpp>
00018 #include <field/ArrayList.hpp>
00019 
00020 namespace Fiber
00021 {
00022         using VecAl::ViewPtr;
00023 
00024 
00025 /*
00026 template <class T>
00027         void HDF5print(const T&);
00028 
00029 template <>
00030 inline  void HDF5print(const double&d)
00031 {
00032         printf("%lg", d);
00033 }
00034 
00035 template <>
00036 inline  void HDF5print(const float&d)
00037 {
00038         printf("%g", d);
00039 }
00040 
00041 template <int N, class Value>
00042 inline  void HDF5print(const FixedArray<N, Value>&FA)
00043 {
00044         for(int i=0; i<N; i++)
00045         {
00046                 HDF5print( FA[i] );
00047                 printf(" ");
00048         }
00049 }
00050 
00051 template <int N, class Value>
00052 inline  void HDF5print(const Vector<N, Value>&V)
00053 {
00054         HDF5print( V.fixed_array() );
00055 }
00056 
00057 template <int N, class Value>
00058 inline  void HDF5print(const VVector<N, Value>&V)
00059 {
00060         HDF5print( V.vec() );
00061 }
00062 
00063 template <int C, class value>
00064 inline  void HDF5print(const Row<C, value>&R)
00065 {
00066         HDF5print(R.vvec());
00067 }
00068 
00069 
00070 template <class ChartType, class TensorType>
00071 inline  void HDF5print(const Tensor<ChartType, TensorType>&d)
00072 {
00073         HDF5print(d.base() );
00074 }
00075 
00076 template <class ChartType, class ScalarType>
00077 inline  void HDF5print(const Point<ChartType, ScalarType>&d)
00078 {
00079         HDF5print(d.vec() );
00080 }
00081 */
00082 
00083 
00084 template <int N, class T, class Storage>
00085 class   HDF5BUNDLE_API HDF5SaverCreator<MemArrayStorage<N, T, Storage> > : public SaveInterfaceCreator<MemArrayStorage<N, T, Storage> >
00086 {
00087         override bool addSaveInterface(MemArrayStorage<N, T, Storage>*M)
00088         {
00089                 M->addInterface( new HDF5Saver<MemArrayStorage<N, T, Storage> >(M) );
00090                 return false;
00091         }
00092 };
00093 
00094 template <class MemArrayStorageType>
00095         struct HDF5FieldSaverInit
00096 {
00097 static  int init()
00098         {
00099                 SaveRegistry<MemArrayStorageType>::getCreator( typeid(HDF5) ) = new HDF5SaverCreator<MemArrayStorageType>();
00100                 return 1;
00101         }
00102 };
00103 
00104 template <int Dims, class Type>
00105         struct HDF5FieldSaverStorageIterator
00106 {
00107 static  int init()
00108         {
00109                 return  HDF5FieldSaverInit<MemArrayStorage<Dims, Type, Type*> >::init()
00110                 +       HDF5FieldSaverInit<MemArrayStorage<Dims, Type, ViewPtr<Type> > >::init()
00111                 +       HDF5FieldSaverInit<MemArrayStorage<Dims, Type, const Type*> >::init()
00112                 +       HDF5FieldSaverInit<MemArrayStorage<Dims, Type, vector<Type> > >::init()
00113                 +       HDF5FieldSaverInit<MemArrayStorage<Dims, Type, vector<Type*> > >::init()
00114                 +       HDF5FieldSaverInit<MemArrayStorage<Dims, Type, vector<const Type*> > >::init();
00115         }
00116 };
00117 
00118 
00119 template <class Type, int Dims>
00120 struct HDF5DimensionalFieldSaverStorageIterator;
00121 
00122 template <class Type>
00123 struct  HDF5DimensionalFieldSaverStorageIterator<Type, 1>
00124 {
00125 static  int init()
00126         {
00127                 return  HDF5FieldSaverStorageIterator<1, Type>::init();
00128         }
00129 };
00130 
00131 template <class Type, int Dims=4>
00132 struct  HDF5DimensionalFieldSaverStorageIterator
00133 {
00134 static  int init()
00135         {
00136                 return  HDF5FieldSaverStorageIterator<Dims, Type>::init()
00137                         +
00138                         HDF5FieldSaverStorageIterator<Dims-1, Type>::init();
00139         }
00140 };
00141 
00142 
00143 
00144 } /* namespace Fiber */ 
00145 
00146 #endif // __FIBER_HDF5FIELD_HPP
00147