00001 #ifndef __FIBER_GRID_REPRESENTATION_HPP
00002 #define __FIBER_GRID_REPRESENTATION_HPP "Created 27.02.2001 21:42:27 by werner"
00003
00004 #include "GridAPI.h"
00005 #include <field/Field.hpp>
00006 #include "FieldID.hpp"
00007 #include <memcore/TypeInfo.hpp>
00008 #include <set>
00009 #include <list>
00010 #include "FiberSpace.hpp"
00011 #include "BaseSpace.hpp"
00012 #include "RepresentationMap.hpp"
00013
00014 namespace Fiber
00015 {
00016 using MemCore::WeakPtr;
00017 using MemCore::NullPtr;
00018 using std::set;
00019 using std::list;
00020
00021 #define FIBER_POSITIONS "Positions"
00022
00033 class GRID_API Representation : public FiberSpace<RefPtr<FieldID> >, public RepresentationMap
00034 {
00035 public: typedef FiberSpace<RefPtr<FieldID> > Base_t;
00036 using FiberSpace<RefPtr<FieldID> >::operator[];
00037 using FiberSpace<RefPtr<FieldID> >::operator();
00038
00039 using RepresentationMap::operator[];
00040 using RepresentationMap::makeRepresentation;
00041 using RepresentationMap::operator();
00042
00053 RefPtr<FieldID> createFieldID(const string&name);
00054
00062 RefPtr<FieldID> findFieldID(const string&name) const;
00063
00064
00071 RefPtr<FieldID> insertSharedFieldID(const Representation&R, const string&name);
00072
00082 RefPtr<FieldID> createSharedFieldID(Representation&Carrier, const string&name);
00083
00084
00088 RefPtr<Field> &getField(const RefPtr<FieldID>&f);
00089
00093 RefPtr<Field> findField(const RefPtr<FieldID>&f) const;
00094
00095 RefPtr<Field> &makeField(const WeakPtr<FieldID>&f);
00096 Field &makeField(const FieldID&f);
00097
00104 Field &operator[](const FieldID&f)
00105 {
00106 return makeField(f);
00107 }
00108
00113 RefPtr<Field>&operator[](const RefPtr<FieldID>&f)
00114 {
00115 return makeField(f);
00116 }
00117
00122 RefPtr<Field>&operator[](const string&name)
00123 {
00124 return makeField( createFieldID(name) );
00125 }
00126
00127 Representation&operator[](const BaseSpace&D);
00128
00134 RefPtr<Field> findField(const string&name) const
00135 {
00136 RefPtr<FieldID> fid = findFieldID(name);
00137 if (!fid)
00138 return NullPtr();
00139
00140 return (*this)( fid );
00141 }
00142
00150 RefPtr<Field> operator()(const string&name) const
00151 {
00152 assert(this);
00153 return findField( name );
00154 }
00155
00157 RefPtr<Field> operator()(const RefPtr<FieldID>&f) const;
00158
00163 RefPtr<MemBase> operator()(const string&name, const RefPtr<FragmentID>&f)
00164 {
00165 RefPtr<Field> F = findField(name);
00166 if (!F)
00167 return NullPtr();
00168
00169 return F->getData(f);
00170 }
00171
00173 RefPtr<Field> Positions() const
00174 {
00175 RefPtr<FieldID> PositionsName = findFieldID( FIBER_POSITIONS );
00176 if (!PositionsName)
00177 return NullPtr();
00178
00179 return findField( PositionsName );
00180 }
00181
00183 RefPtr<Field> getPositions() const
00184 {
00185 return Positions();
00186 }
00187
00188
00198 RefPtr<SizeInterface> getSize() const
00199 {
00200 RefPtr<Field> Pos = getPositions();
00201 if (!Pos)
00202 return MemCore::NullPtr();
00203
00204 return Pos->getSize();
00205 }
00206
00219 RefPtr<Field>&setPositions(const RefPtr<Field>&P);
00220
00222 int iterate(FieldIterator&FI) const;
00223
00230 int rank() const;
00231
00235 int getMemoryUsage(memsize_t&UsedMemory, memsize_t&WantedMemory) const;
00236
00237
00241 void Speak(int indent=0, int maxindent=-1) const;
00242 };
00243
00244 }
00245
00246 #endif