00001 #ifndef __FIBER_GRID_CHART_HPP
00002 #define __FIBER_GRID_CHART_HPP "Created 27.02.2001 21:42:27 by werner"
00003
00004 #include "GridAPI.h"
00005
00006 #include "BaseSpace.hpp"
00007 #include "Transformation.hpp"
00008 #include "ChartID.hpp"
00009
00010 namespace Fiber
00011 {
00012 using MemCore::WeakPtr;
00013 using MemCore::NullPtr;
00014 using std::set;
00015 using std::list;
00016
00017 class GRID_API Chart;
00018
00039 class GRID_API ChartCreatorBase;
00040
00042 typedef WeakPtr<Chart, BaseSpace> ChartPtr;
00043
00044 class Tensortype
00045 {
00046 public:
00047 enum type
00048 {
00049 SCALAR,
00050 POSITIONS,
00051 TENSOR,
00052 CHRISTOFFELS,
00053 PSEUDOSCALAR
00054 };
00055 int upper, lower;
00056 };
00057
00058
00059 class GRID_API ChartCreatorBase : public ReferenceBase<ChartCreatorBase>
00060 {
00061 public: const int dims;
00062 const char*domain_name;
00063 const char**component_names;
00064
00065 ChartCreatorBase(int dims,
00066 const char*domain_name,
00067 const char**component_names,
00068 const type_info&);
00069
00070 ~ChartCreatorBase();
00071
00072 virtual RefPtr<Chart> create(const RefPtr<ChartID>&mID) = 0;
00073 };
00074
00075
00089 class GRID_API Chart : public BaseSpace
00090 {
00096 map<ChartPtr, RefPtr<Transformation> > Transformations;
00097
00099 RefPtr<ChartID> myID;
00100
00101 WeakPtr<ChartCreatorBase> myCreator;
00102
00103 public:
00104
00106 Chart(const WeakPtr<ChartCreatorBase>&MyCreator, const RefPtr<ChartID>&mID)
00107 : myID( mID )
00108 , myCreator( MyCreator )
00109 {}
00110
00112 ~Chart();
00113
00114 RefPtr<ChartID> ID() const
00115 {
00116 return myID;
00117 }
00118
00119 string Name() const
00120 {
00121 if (myID)
00122 return myID->Name();
00123
00124 return string();
00125 }
00126
00127 int dims() const
00128 {
00129 if (!myCreator) return 0;
00130 return myCreator->dims;
00131 }
00132
00133 override int Dims() const
00134 {
00135 return dims();
00136 }
00137
00138 const char*component_name(int i) const
00139 {
00140 if (i<0) return 0;
00141 if (i>=dims() ) return 0;
00142 if (!myCreator) return 0;
00143
00144 return myCreator->component_names[i];
00145 }
00146
00147 const char*domain_name() const
00148 {
00149 if (!myCreator) return 0;
00150 return myCreator->domain_name;
00151 }
00152
00153
00154 RefPtr<Chart> create(const RefPtr<ChartID>&mID)
00155 {
00156 return myCreator->create( mID );
00157 }
00158
00159 static RefPtr<Chart> create(const type_info&chart_type, const RefPtr<ChartID>&mID);
00160
00161 virtual RefPtr<Field> makeField(const type_info&base_type, const Tensortype&t) = 0;
00162 };
00163
00164
00165
00166 template <class ChartType>
00167 class ChartCreator : public ChartCreatorBase
00168 {
00169 public:
00170 ChartCreator(int dims,
00171 const char*domain_name,
00172 const char**component_names)
00173 : ChartCreatorBase(dims, domain_name, component_names, typeid(ChartType) )
00174 {}
00175
00176 override RefPtr<Chart> create(const RefPtr<ChartID>&ID)
00177 {
00178 return new ChartType( self(), ID );
00179 }
00180 };
00181
00182
00183 }
00184
00185 #endif
00186
00187