Fish - FiberLib for VISH 0.3
Fish - The Fiber Bundle API for the Vish Visualization Shell
Fiber::MemArray< N, T > Class Template Reference

Class for N-dimensional MultiArrays with MemCore memory management. More...

#include <MemArray.hpp>

Inheritance diagram for Fiber::MemArray< N, T >:
Fiber::ReferencingMemArray< N, T > Fiber::MemArrayBase< N > Fiber::MultiArray< N, T, class > Fiber::TypedArray< T > Fiber::MemBase Fiber::MemBase MemCore::Cacheable MemCore::Intercube MemCore::Cacheable MemCore::Intercube MemCore::ReferenceBase< Cacheable > MemCore::ReferenceBase< Cacheable >

Public Types

enum  { Dims = N }
typedef MetaInfo< T >::element_t element_t
typedef MemArray< N, element_t > ComponentArray_t
 The type of an array that refers to just a component, if the value type is a structure.
typedef T value_type
 Export the type that is operated on here.
typedef META::BaseClass< T >::result value_base_type
 The base class of the given type T.
typedef MemArray< N, value_base_type > MemArrayOfBaseValues_t
 A memory array consisting of types of the base classes for the value type T.
typedef MultiArray< N, T > MultiArray_t
 Export multiarray type.
typedef MemCore::NullPtr NullPtr
typedef MultiArray_t::component_t component_t
typedef MultiArray_t::ValueBase_t ValueBase_t
typedef MultiArray_t::MultiArrayBase_t MultiArrayBase_t
typedef MultiArray_t::MultiArrayComponent_t MultiArrayComponent_t
typedef MemArray< N, ValueBase_t > MemArrayBase_t
typedef MemArray< N, component_t > MemArrayComponent_t
Public Types inherited from Fiber::ReferencingMemArray< N, T >
typedef RefPtr< MemCore::Chunk< T > > MemChunk
typedef MultiArray< N, T > MultiArray_t
Public Types inherited from Fiber::MemArrayBase< N >
enum  Dims_t { Dims = N }
typedef MultiIndex< N > MIndex_t
Public Types inherited from Fiber::MemBase
typedef WeakPtrCreativeArrayBase_t Creator_t
Public Types inherited from MemCore::Cacheable
typedef unsigned long cachecounter_t
Public Types inherited from MemCore::ReferenceBase< Cacheable >
typedef Object reference_domain_t
typedef WeakPtr< Object, Object > SelfPtr_t
Public Types inherited from Fiber::TypedArray< T >
typedef T value_type

Public Member Functions

 MemArray (const Iterator< T > &data, const MultiIndex< N > &Sz, const RefPtr< MemCore::ChunkBase > &MemStorage, const MemBase::Creator_t &C)
 MemArray (const MultiIndex< N > &M, const MemBase::Creator_t &C=nullptr)
 Construct from size, allocate new memory during construction.
 MemArray (const MemCore::MemVector< T > &Data, const MultiIndex< N > &M, const MemBase::Creator_t &C=nullptr)
 Construct from size and a MemVector, for convenience, hoping that the memory sizes fit.
 MemArray (const RefPtr< MemCore::ChunkBase > &Data, const MultiIndex< N > &Sz, const MemBase::Creator_t &C=NullPtr())
 Construct from memory chunk and multidimensional index, hoping that the memory sizes fit.
 MemArray (const RefPtr< MemCore::ChunkBase > &Storage, const MultiArray< N, T > &M, const MemBase::Creator_t &C=NullPtr())
RefPtr< MemBase > getSlice (index_t i, const MemBase::Creator_t &C) const override
 For a multidimensional array retrieve the nth slice.
MultiIndex< N > Size () const override
 Return the number of dimensions.
RefPtr< MemBase > makeMemArray (const MemBase::Creator_t &) const override
 Make a memory array, in this case it's already one, so it's a do-nothing operation.
RefPtr< MemBase > newMemArraynD (const MultiIndex< N > &NewSize, const MemBase::Creator_t &C) const override
 Create a new memory array of the same type, initialized with default data values.
RefPtr< MemArray > createMemArray (const MemCore::MemVector< T > &Data, const MemBase::Creator_t &C) const
 Create a memory array of the same dimensions as the current array, but with data as provided by the MemVector.
RefPtr< MemArray > createMemArray (const RefPtr< MemCore::ChunkBase > &Data, const MemBase::Creator_t &C) const
 Create a memory array of the same dimensions as the current array, but with data as provided by the Storage.
RefPtr< MemBase > createEquallySizedMemArray (const RefPtr< MemCore::ChunkBase > &Storage, const MemBase::Creator_t &C) const override
 Create a memory array of the same dimensions as the current array, but with data as provided by the Storage.
RefPtr< MemBase > copy (const MemBase::Creator_t &C=nullptr) const override
 Create a copy of the current array, duplicating all data and allocating new memory for it.
RefPtr< MemBase > createSubMemArray (const MultiIndex< N > &Offset, const MultiIndex< N > &CopySize, const MemBase::Creator_t &C) const override
 Create a new MemArray from a subset of the current array's data.
RefPtr< MemBase > getComponentArray (int member, const MemBase::Creator_t &C) override
Public Member Functions inherited from Fiber::ReferencingMemArray< N, T >
 ReferencingMemArray (const Iterator< T > &data, const MultiIndex< N > &Sz, const RefPtr< MemCore::ChunkBase > &theStorage, const WeakPtr< CreativeArrayBase > &theCreator)
 Constructor.
 ReferencingMemArray (const RefPtr< Chunk< T > > &data, const MultiIndex< N > &Sz, const WeakPtr< CreativeArrayBase > &theCreator)
 Construct from memory chunk and multidimensional index.
 ReferencingMemArray (const RefPtr< MemCore::ChunkBase > &theStorage, const MultiArray< N, T > &M, const WeakPtr< CreativeArrayBase > &theCreator)
 Create referencing mem array from an existing multi array and some memory reference.
 ReferencingMemArray (const ReferencingMemArray &RMA)
 Copy constructor.
bool copyFrom (const RefPtr< MemCore::ChunkBase > &theChunk) override
RefPtr< MemCore::TypedChunk< T > > myChunk () const override
 Return storage type.
MemCore::memsize_t memsize () const override
 Note: memsize does not return the number of elements here, but the actual memory that is occupied.
index_t nElements () const override
 return the number of elements in this array
std::string getElementAsString (size_t index) const override
void DeferredConstructor () override
 Virtual deferred reference pointer construction pointer Don't overload if you don't know exactly what this function is supposed to do.
const type_info & getType () const override
 Return the element type of the certain array.
const type_info & getBaseType () const
 Return the element type of the certain array.
HyperslabParameters & getHyperslabParameters () override
void * getPtr () override
 Special Array Storage.
const void * OriginPtr () const override
 Get pointer to origin of linearly procedural array, if it is linear.
const void * DeltaPtr () const override
 Get pointer to delta of linearly procedural array, if it is linear.
T first () const override
 Retrieve the first element.
T last () const override
 Retrieve the last element.
CreativeIterator< T > * creativeIterator () override
const CreativeIterator< T > * creativeIterator () const override
const RefPtr< MemCore::TypedChunk< T > > & StoragePtr () const
const RefPtr< MemCore::TypedChunk< T > > & getStorage () const
const RefPtr< MemCore::TypedChunk< T > > & getTypedStorage () const
MultiIndex< N > Size () const override
 Return the number of dimensions.
Public Member Functions inherited from Fiber::MemArrayBase< N >
 MemArrayBase (const FiberTypeIndex &theFiberTypeIndex, const WeakPtr< CreativeArrayBase > &theCreator)
 MemArrayBase (const MemArrayBase< N > &)=delete
void operator= (const MemArrayBase< N > &)=delete
Fiber::Dims_t rank () const override
 Return the number of array dimensions.
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.
DynamicSize getSize () const override
 Return the size of this dataset.
RefPtr< ArrayInterpolator > getInterpolator () const
Public Member Functions inherited from Fiber::MemBase
 MemBase (const FiberTypeIndex &theFiberTypeIndex, const Creator_t &theCreator)
 Empty default constructor.
 ~MemBase ()
 Destructor.
 MemBase (const MemBase &)=delete
MemCore::WeakPtr< MemBase > membase () const
auto NumberOfElements () const
auto getNumberOfElements () const
MemCore::WeakPtr< FiberTypeBase > getFiberType () const
MemCore::memsize_t element_memsize () const
bool copyFrom (const RefPtr< MemBase > &Mb)
 Copy all data values from the given MemBase.
RefPtr< MemBase > create (const RefPtr< FiberTypeBase > &FT, const type_info &layout=typeid(void)) const
 Create a new mem array of the same dimensions but different type.
template<class T>
RefPtr< MemBase > create (const type_info &layout=typeid(void)) const
 Create a new mem array of the same dimensions but different type.
RefPtr< MemBase > create (const DynamicSize &DS, const type_info &layout=typeid(void)) const
 Create a new mem array of the same type but different dimensions.
RefPtr< MemBase > create (const type_info &layout=typeid(void)) const
 Create a new mem array of the same type and dimensions, but default values.
Public Member Functions inherited from MemCore::Cacheable
 Cacheable (const WeakPtr< Creature > &C)
bool isCached () const
bool isUncached () const
bool markAsUsed ()
WeakPtr< CacheBase > myCache () const
const WeakPtr< Creature > & myCreator () const
int NumberOfListEntries () const
void PreDestructor ()
void push_back (CacheQueue &Q)
void push_front (CacheQueue &Q)
void setCreator (const WeakPtr< Creature > &C)
Public Member Functions inherited from MemCore::ReferenceBase< Cacheable >
auto getObjectCountID () const noexcept
bool isIdentical (const WeakPtr< Object, Object > &PossibleSelf) const noexcept
void mkAutoDestructive ()
refcount_t refcount () const noexcept
 ReferenceBase (Object *that) noexcept
const auto & self () const
refcount_t wrefcount () const noexcept
Public Member Functions inherited from MemCore::Intercube
void addInterface (const RefPtr< InterfaceBase > &I) const
void addInterfaceData (const Data &D)
void addInterfaceData (const Data &D)
void clearInterfaces ()
bool const_iterateInterfaces (const RefPtr< InterfaceIterationParameter > &IIP) const
virtual RefPtr< InterfaceBase > createInterface (const type_info &) const
RefPtr< InterfaceBase > findInterface (const type_info &t) const
RefPtr< InterfaceBase > getInterface (const type_info &t)
std::string getInterfaceNames (const char delim=';') const
bool gotNewInterfaceData (const Data &D)
bool gotNewInterfaceData (mutex &M, const Data &D)
bool gotNewInterfaceData (mutex &M, const Data &D)
bool gotNewInterfaceData (mutex &M, const Data &D, const Selector &S)
bool gotNewInterfaceData (mutex &M, const Data &D, const Selector *S)
bool hasChangedInterfaceData (const Data &D) const
bool hasChangedInterfaceData (const Data &D) const
bool hasChangedInterfaceData (const Data &D, const Selector &) const
bool hasChangedInterfaceData (const Data &D, const Selector *) const
bool hasInterface (const type_info &t) const
bool iterateInterfaces (const RefPtr< InterfaceIterationParameter > &IIP)
void printInterfaces () const
void registerInterface (const type_info &t)
void removeInterface ()
void removeInterfaceBase (const type_info &InterfaceBaseID)
Public Member Functions inherited from Fiber::TypedArray< T >
 TypedArray (const MemBase::Creator_t &C)
 TypedArray (const TypedArray< T > &)=delete
void operator= (const TypedArray< T > &)=delete
RefPtr< MemCore::ChunkBase > getChunk () const override
 Implement the virtual getChunk() function.
const type_info & getType () const override
 Return the element type of the certain array.
template<class UnaryOperator>
RefPtr< MemBase > applyOperator (const UnaryOperator &theOperator, const MemBase::Creator_t &theCreator) const
 Apply an unary operator on the data contained here, and provide a new memory array of the same size and dimensionality.
template<class result_t>
RefPtr< MemBase > applyFunction (const std::function< result_t(const T &)> &theOperator) const
 Apply a functor, possibly yielding a different type.
RefPtr< MemBase > applyFunction (const std::function< T(const T &)> &theOperator) const
 Apply a functor yielding the same type.
template<class result_t>
RefPtr< MemBase > applyFunction (const std::function< result_t(const T &, index_t I)> &theOperator) const
 Apply a functor, possibly yielding a different type.
RefPtr< MemBase > applyFunction (const std::function< T(const T &, index_t I)> &theOperator) const
 Apply a functor yielding the same type.
template<class result_t, class SecondType>
RefPtr< MemBase > applyFunction (const TypedArray< SecondType > &R, const std::function< result_t(const T &, const SecondType &ST, index_t I)> &theOperator) const
 Apply a binary functor, possibly yielding a different type.
template<class BinaryOperator>
RefPtr< MemBase > applyOperator (const BinaryOperator &theOperator, const RefPtr< MemBase > &rightValue, const MemBase::Creator_t &theCreator) const
 Apply a binary operator on the data contained here, and provide a new memory array of the same size and dimensionality.
auto getComponent (int Component) -> decltype(getComponentArrayIterator(*this, Component))
auto operator() (int Component) -> decltype(getComponentArrayIterator(*this, Component))
ranged_for_iterator< T > begin ()
ranged_for_iterator< T > end ()
const_ranged_for_iterator< T > begin () const
const_ranged_for_iterator< T > end () const
RefPtr< MemBase > create (const RefPtr< FiberTypeBase > &FT, const type_info &layout=typeid(void)) const
 Create a new mem array of the same dimensions but different type.
template<class T>
RefPtr< MemBase > create (const type_info &layout=typeid(void)) const
 Create a new mem array of the same dimensions but different type.
RefPtr< MemBase > create (const DynamicSize &DS, const type_info &layout=typeid(void)) const
 Create a new mem array of the same type but different dimensions.

Static Public Member Functions

static bool reg ()
Static Public Member Functions inherited from Fiber::MemBase
static RefPtr< MemBase > create (const RefPtr< FiberTypeBase > &FT, const DynamicSize &DS, const type_info &layout=typeid(void))
 Given a description of a certain data type for each element on array, allocate a multidimensional array of the given type.
static bool registerCreator (const RefPtr< Allocator > &A, const RefPtr< FiberTypeBase > &FT)
Static Public Member Functions inherited from Fiber::TypedArray< T >
static MemCore::WeakPtr< FiberTypeBase > getFiberType ()
static RefPtr< MemBase > create (const RefPtr< MemBase > &SourceLayout, const type_info &layout=typeid(void))
static RefPtr< MemBase > create (const RefPtr< FiberTypeBase > &FT, const DynamicSize &DS, const type_info &layout=typeid(void))
 Given a description of a certain data type for each element on array, allocate a multidimensional array of the given type.

Friends

class MemArrayGetSlice< N >
class MemArrayGetSlice< N+1 >

Additional Inherited Members

Static Public Attributes inherited from Fiber::MemBase
static int RegisteredTypes = 0
Protected Member Functions inherited from Fiber::ReferencingMemArray< N, T >
 ~ReferencingMemArray ()
 Protected Destructor to avoid static creation.
Protected Member Functions inherited from MemCore::Cacheable
void adjustCacheableSize (memsize_t memDiff)
Protected Member Functions inherited from MemCore::ReferenceBase< Cacheable >
virtual void extremeUnction ()
ReferenceBase & operator= (const ReferenceBase &R)
void suicide ()
Protected Attributes inherited from Fiber::ReferencingMemArray< N, T >
RefPtr< MemCore::TypedChunk< T > > myStorage

Detailed Description

template<Dims_t N, class T>
class Fiber::MemArray< N, T >

Class for N-dimensional MultiArrays with MemCore memory management.

Author
Werner Benger
Examples
ColoredLines.cpp, trimesh.cpp, and uniform_scalar.cpp.

Member Typedef Documentation

◆ ComponentArray_t

template<Dims_t N, class T>
typedef MemArray<N, element_t> Fiber::MemArray< N, T >::ComponentArray_t

The type of an array that refers to just a component, if the value type is a structure.

Member Enumeration Documentation

◆ anonymous enum

template<Dims_t N, class T>
anonymous enum
Enumerator
Dims 

The dimensionality of this array.

Member Function Documentation

◆ copy()

template<Dims_t N, class T>
RefPtr< MemBase > Fiber::MemArray< N, T >::copy ( const MemBase::Creator_t & C = nullptr) const
inlineoverridevirtual

Create a copy of the current array, duplicating all data and allocating new memory for it.

Implements Fiber::MemBase.

◆ createEquallySizedMemArray()

template<Dims_t N, class T>
RefPtr< MemBase > Fiber::MemArray< N, T >::createEquallySizedMemArray ( const RefPtr< MemCore::ChunkBase > & Storage,
const MemBase::Creator_t & C ) const
inlineoverridevirtual

Create a memory array of the same dimensions as the current array, but with data as provided by the Storage.

Will return NullPtr if the sizes don't match. Calls createMemArray() .

Implements Fiber::MemBase.

◆ createMemArray() [1/2]

template<Dims_t N, class T>
RefPtr< MemArray > Fiber::MemArray< N, T >::createMemArray ( const MemCore::MemVector< T > & Data,
const MemBase::Creator_t & C ) const
inline

Create a memory array of the same dimensions as the current array, but with data as provided by the MemVector.

Will return NullPtr if the sizes don't match.

Referenced by Fiber::MemArray< 3, Eagle::tvector3 >::createEquallySizedMemArray().

◆ createMemArray() [2/2]

template<Dims_t N, class T>
RefPtr< MemArray > Fiber::MemArray< N, T >::createMemArray ( const RefPtr< MemCore::ChunkBase > & Data,
const MemBase::Creator_t & C ) const
inline

Create a memory array of the same dimensions as the current array, but with data as provided by the Storage.

Will return NullPtr if the sizes don't match.

◆ createSubMemArray()

template<Dims_t N, class T>
RefPtr< MemBase > Fiber::MemArray< N, T >::createSubMemArray ( const MultiIndex< N > & Offset,
const MultiIndex< N > & CopySize,
const MemBase::Creator_t & C ) const
inlineoverridevirtual

Create a new MemArray from a subset of the current array's data.

Implements Fiber::MemArrayBase< N >.

◆ getComponentArray()

template<Dims_t N, class T>
RefPtr< MemBase > Fiber::MemArray< N, T >::getComponentArray ( int member,
const MemBase::Creator_t & C )
inlineoverridevirtual

Implements Fiber::MemBase.

◆ getSlice()

template<Dims_t N, class T>
RefPtr< MemBase > Fiber::MemArray< N, T >::getSlice ( index_t n,
const MemBase::Creator_t & C ) const
inlineoverridevirtual

For a multidimensional array retrieve the nth slice.

The result will be of one dimension less. A Creator object must be given for Cache management.

Implements Fiber::MemArrayBase< N >.

◆ makeMemArray()

template<Dims_t N, class T>
RefPtr< MemBase > Fiber::MemArray< N, T >::makeMemArray ( const MemBase::Creator_t & ) const
inlineoverridevirtual

Make a memory array, in this case it's already one, so it's a do-nothing operation.

The specified Creator is not used.

Implements Fiber::MemBase.

◆ newMemArraynD()

template<Dims_t N, class T>
RefPtr< MemBase > Fiber::MemArray< N, T >::newMemArraynD ( const MultiIndex< N > & NewSize,
const MemBase::Creator_t & C ) const
inlineoverridevirtual

Create a new memory array of the same type, initialized with default data values.

Implements Fiber::MemArrayBase< N >.

◆ Size()