FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
MemArrayBase.hpp
1#ifndef __FIBER_MEMARRAYBASE_HPP
2#define __FIBER_MEMARRAYBASE_HPP "Created 4.07.2004 14:31:21 by bzfbenge"
3
4#include "FieldAPI.h"
5
6#include <typeinfo>
7#include "FiberType.hpp"
8#include "DynamicSize.hpp"
9#include "MemBase.hpp"
10#include "ArrayInterpolator.hpp"
11#include "CreativeArrayBase.hpp"
12
13
14namespace Fiber
15{
16 using std::type_info;
17
18 using MemCore::RefPtr;
20 using MemCore::Chunk;
21 using MemCore::WeakPtr;
22
35template <Dims_t N>
36class MemArrayBase : virtual public MemBase
37{
38protected:
39
41 {}
42
43public:
44 enum Dims_t { Dims = N };
45
46 typedef MultiIndex<N> MIndex_t;
47
49 : MemBase(theFiberTypeIndex, theCreator)
50 {}
51
52 MemArrayBase(const MemArrayBase<N>&) = delete;
53 void operator=(const MemArrayBase<N>&) = delete;
54
56 Fiber::Dims_t rank() const override
57 {
58 return N;
59 }
60
62 virtual MultiIndex<N> Size() const = 0;
63
71
72#if 0
74 RefPtr<MemBase> newMemArray(const DynamicSize&newSize, const MemBase::Creator_t&C) const override
75 {
77 if (newSize.get(S) )
78 {
79 return newMemArraynD(S,C);
80 }
81 return MemCore::NullPtr();
82 }
83#endif
84
89
92 {
94 if (Offset.get(O) && CopySize.get(S) )
95 {
96 return createSubMemArray(O,S,C);
97 }
98 return MemCore::NullPtr();
99 }
100
101 DynamicSize getSize() const override
102 {
103 return DynamicSize( Size() );
104 }
105
106 RefPtr<ArrayInterpolator> getInterpolator() const
107 {
108 return findInterface( typeid(ArrayInterpolator) );
109 }
110
116 virtual RefPtr<MemBase> getSlice(index_t n, const MemBase::Creator_t&C) const = 0;
117};
118
119template <Dims_t N>
121{
122static bool setSizeInterface(const RefPtr<CreativeArrayBase>&DC)
123 {
124 if (!DC)
125 return false;
126
127 RefPtr<MemBase> MemData = DC->create();
128 if (!MemData)
129 return false;
130
132 if (!MemDataN)
133 return false;
134
135 MultiIndex<N> Dims = MemDataN->Size();
136 ::Fiber::setSizeInterface( DC, Dims );
137
138 return true;
139 }
140};
141
153template <Dims_t N>
155{
156 if (!DC)
157 return false;
158
159RefPtr<MemBase> MemData = DC->create();
160 if (!MemData)
161 return false;
162
164 if (!MemDataN)
165 return false;
166
167 Dims = MemDataN->Size();
168 setSizeInterface( DC, Dims );
169
170 return true;
171}
172
185template <Dims_t N>
187{
188 if (!DC)
189 return false;
190
191 if (getDimensions(Dims, DC) )
192 //{
193 //printf("makeDimensions::getDimensions()\n");fflush(stdout);
194 return true;
195 //}
196 //printf("makeDimensions::makeSizeInterface()");fflush(stdout);
197 return makeSizeInterface(Dims, DC);
198}
199
200
201} /* namespace Fiber */
202
203#endif /* __FIBER_MEMARRAYBASE_HPP */
A field's interpolator is an interface for this specific field.
Definition ArrayInterpolator.hpp:29
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
A class describing an n-dimensional space at runtime.
Definition field/DynamicSize.hpp:29
Abstract class for N-dimensional MultiArrays with MemCore memory management.
Definition MemArrayBase.hpp:37
virtual RefPtr< MemBase > createSubMemArray(const MultiIndex< N > &Offset, const MultiIndex< N > &CopySize, const MemBase::Creator_t &C) const =0
Create a new MemArray from a subset of the current array's data.
virtual RefPtr< MemBase > getSlice(index_t n, const MemBase::Creator_t &C) const =0
For a multidimensional array retrieve the nth slice.
virtual RefPtr< MemBase > newMemArraynD(const MultiIndex< N > &NewSize, const MemBase::Creator_t &C) const =0
Create a new array of the same type as the current one, but using the specified dimensions.
virtual MultiIndex< N > Size() const =0
The multi-dimensional size of this array.
RefPtr< MemBase > createSubArray(const DynamicSize &Offset, const DynamicSize &CopySize, const MemBase::Creator_t &C) const override
Implement creation of new memory sub array using the DynamicSize class.
Definition MemArrayBase.hpp:91
Fiber::Dims_t rank() const override
Return the number of array dimensions.
Definition MemArrayBase.hpp:56
DynamicSize getSize() const override
Return the size of this dataset.
Definition MemArrayBase.hpp:101
Base class for multidimensional arrays with MemCore memory management.
Definition MemBase.hpp:70
RefPtr< InterfaceBase > findInterface(const type_info &t) const
bool makeDimensions(MultiIndex< N > &Dims, const RefPtr< CreativeArrayBase > &DC)
Given a data creator, retrieve the dimensionality information from the associated data,...
Definition MemArrayBase.hpp:186
bool makeSizeInterface(MultiIndex< N > &Dims, const RefPtr< CreativeArrayBase > &DC)
Set the size interface of a given data array Creator, based on the associated data (this function wil...
Definition MemArrayBase.hpp:154
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
IndexTypeConfig< sizeof(void *)>::index_t index_t
Define the index type as according to the size of a pointer, i.e.
Definition Index.hpp:22
std::nullptr_t NullPtr
Definition FiberTypeIndex.hpp:12
Definition MemArrayBase.hpp:121