MemArrayBase.hpp

00001 #ifndef __FIBER_MEMARRAYBASE_HPP
00002 #define __FIBER_MEMARRAYBASE_HPP "Created 4.07.2004 14:31:21 by bzfbenge"
00003 
00004 #include "FieldAPI.h"
00005 
00006 #include <typeinfo>
00007 #include "FiberType.hpp"
00008 #include "DynamicSize.hpp"
00009 #include "MemBase.hpp"
00010 #include "ArrayInterpolator.hpp"
00011 
00012 namespace Fiber
00013 {
00014         using std::type_info;
00015 
00016         using MemCore::RefPtr;
00017         using MemCore::ReferenceBase;
00018         using MemCore::Chunk;
00019         using MemCore::WeakPtr;
00020 
00033 template <int N>
00034 class   MemArrayBase : virtual public MemBase
00035 {
00036 public:
00037         enum { Dims = N };
00038 
00039         typedef MultiIndex<N>         MIndex_t;
00040 
00041         MemArrayBase(const WeakPtr<CreativeArrayBase>&theCreator)
00042         : MemBase(theCreator)
00043         {}
00044 
00046         override int rank() const
00047         {
00048                 return N;
00049         }
00050 
00051         virtual MultiIndex<N> Size() const = 0;
00052 
00053         virtual RefPtr<MemBase> createMemArray(const MultiIndex<N>&NewSize, const MemBase::Creator_t&C) const = 0;
00054 
00055         virtual RefPtr<MemBase> createSubMemArray(const MultiIndex<N>&Offset, const MultiIndex<N>&CopySize, const MemBase::Creator_t&C) const = 0;
00056 
00057         override RefPtr<MemBase> createSubArray(const DynamicSize&Offset, const DynamicSize&CopySize, const MemBase::Creator_t&C) const
00058         {
00059         MultiIndex<N> O, S; 
00060                 if (Offset.get(O) && CopySize.get(S) )
00061                 {
00062                         return createSubMemArray(O,S,C);
00063                 }
00064                 return MemCore::NullPtr();
00065         }
00066 
00067         override RefPtr<MemBase> newMemArray(const DynamicSize&newSize, const MemBase::Creator_t&C) const
00068         {
00069         MultiIndex<N> S; 
00070                 if (newSize.get(S) )
00071                 {
00072                         return createMemArray(S,C);
00073                 }
00074                 return MemCore::NullPtr();
00075         }
00076 
00077 
00078         override DynamicSize getSize() const
00079         {
00080                 return DynamicSize( Size() );
00081         }
00082 
00083         override RefPtr<MemBase> newMemArray(const MemBase::Creator_t&C) const
00084         {
00085                 return createMemArray( Size(), C);
00086         }
00087 
00088         RefPtr<ArrayInterpolator> getInterpolator() const
00089         {
00090                 return findInterface( typeid(ArrayInterpolator) );
00091         }
00092 
00098         virtual RefPtr<MemBase> getSlice(index_t n, const MemBase::Creator_t&C) const = 0;
00099 };
00100 
00101 
00102 } /* namespace Fiber */ 
00103 
00104 #endif /* __FIBER_MEMARRAYBASE_HPP */
00105