Workspace 6.21.5
Public Types | Public Member Functions | List of all members
ArrayNdSliceTyped< T > Class Template Reference

Type-specific implementation of the ArrayNdSlice interface. Also implements a ArrayNdTyped object of the same type.

#include <DataAnalysis/DataStructures/arrayndslice.h>

Inheritance diagram for ArrayNdSliceTyped< T >:
[legend]

Public Types

typedef ArrayNd::size_type size_type
 
- Public Types inherited from ArrayNd
typedef NamedDimensionRange::size_type size_type
 

Public Member Functions

 ArrayNdSliceTyped ()
 
 ArrayNdSliceTyped (ArrayNdSliceTyped &&other)
 
 ArrayNdSliceTyped (const ArrayNdSliceTyped &other)
 
 ~ArrayNdSliceTyped () override
 
bool arrayAccessHint (const NamedDimensionRangeList &range) override
 
ArrayNdSliceTypedclone () const override
 
ArrayNdgetAsArrayNd () override
 
const DataCollectiongetAttributes () const override
 
bool getData (const NamedDimensionRangeList &range, T *data) const override
 
const DataExecution::DataFactorygetDataFactory () const override
 
int getDimensionIndex (const QString &name) const override
 
ArrayNdDimensionLabels getDimensionLabels (const QString &dimName) const override
 
QString getDimensionName (int index) const override
 
size_type getDimensionSize (const QString &name) const override
 
size_type getDimensionSize (int index) const override
 
double getFillValue () const override
 
QVariant getFillValueAsVariant () const override
 
bool hasFillValue () const override
 
bool isDimensionUnlimited (int index) const override
 
int numDimensions () const override
 
ArrayNdSliceTypedoperator= (ArrayNdSliceTyped other)
 
bool setBaseData (ArrayNd &data, const NamedDimensionRangeList &includedRange, bool ownsData=false) override
 
bool setDimensions (const NamedDimensionRangeList &dimensions) override
 
bool setFillValue (const T &value) override
 
void setHasFillValue (bool b) override
 
valueAt (const DimensionIndexList &indices) const override
 
valueAt (size_type dim0, size_type dim1=0, size_type dim2=0, size_type dim3=0, size_type dim4=0) const override
 
bool writeData (const NamedDimensionRangeList &range, const T *const data) override
 
- Public Member Functions inherited from ArrayNdSlice
virtual ~ArrayNdSlice ()=default
 
virtual ArrayNdgetAsArrayNd ()=0
 
virtual bool setBaseData (ArrayNd &data, const NamedDimensionRangeList &includedRange, bool ownsData=false)=0
 
- Public Member Functions inherited from ArrayNdTyped< T >
bool arrayAccessHint (const NamedDimensionRangeList &range) override=0
 
ArrayNdTypedclone () const override=0
 
virtual bool getData (const NamedDimensionRangeList &range, T *data) const =0
 
double getFillValue () const override=0
 
QVariant getFillValueAsVariant () const override=0
 
QVariant getValue (const DimensionIndexList &dimIndices) const override
 
QVariant getValue (size_type dim0, size_type dim1=0, size_type dim2=0, size_type dim3=0, size_type dim4=0) const override
 
bool hasFillValue () const override=0
 
double operator() (const DimensionIndexList &dimIndices) const override
 
double operator() (size_type dim0, size_type dim1=0, size_type dim2=0, size_type dim3=0, size_type dim4=0) const override
 
ArrayNdTypedoperator= (const ArrayNdTyped &other)=default
 
virtual bool setFillValue (const T &value)=0
 
void setHasFillValue (bool b) override=0
 
virtual T valueAt (const DimensionIndexList &indices) const =0
 
virtual T valueAt (size_type dim0, size_type dim1=0, size_type dim2=0, size_type dim3=0, size_type dim4=0) const =0
 
virtual bool writeData (const NamedDimensionRangeList &range, const T *const data)=0
 
- Public Member Functions inherited from ArrayNd
 ArrayNd ()
 
 ~ArrayNd () override
 
virtual bool arrayAccessHint (const NamedDimensionRangeList &range)=0
 
const_iterator begin () const
 
ArrayNdclone () const override=0
 
const_iterator end () const
 
NamedDimensionRangeList getAllDimensions () const
 
virtual const DataCollectiongetAttributes () const =0
 
template<typename T >
bool getData (const NamedDimensionRangeList &range, T *data) const
 
virtual const DataExecution::DataFactorygetDataFactory () const =0
 
NamedDimensionRange getDimension (const QString &name) const
 
virtual int getDimensionIndex (const QString &name) const =0
 
virtual ArrayNdDimensionLabels getDimensionLabels (const QString &dimensionName) const =0
 
virtual QString getDimensionName (int index) const =0
 
virtual size_type getDimensionSize (const QString &name) const =0
 
virtual size_type getDimensionSize (int index) const =0
 
virtual double getFillValue () const =0
 
virtual QVariant getFillValueAsVariant () const =0
 
template<typename T >
ArrayNdTyped< T > * getTypedInterface ()
 
template<typename T >
const ArrayNdTyped< T > * getTypedInterface () const
 
virtual QVariant getValue (const DimensionIndexList &dimIndices) const =0
 
virtual QVariant getValue (size_type dim0, size_type dim1=0, size_type dim2=0, size_type dim3=0, size_type dim4=0) const =0
 
virtual bool hasFillValue () const =0
 
virtual bool isDimensionUnlimited (int index) const =0
 
virtual int numDimensions () const =0
 
virtual double operator() (const DimensionIndexList &dimIndices) const =0
 
virtual double operator() (size_type dim0, size_type dim1=0, size_type dim2=0, size_type dim3=0, size_type dim4=0) const =0
 
const_iterator_range range (const NamedDimensionRangeList &range) const
 
virtual bool setDimensions (const NamedDimensionRangeList &dimensions)=0
 
template<typename T >
bool setFillValue (const T &value)
 
virtual void setHasFillValue (bool b)=0
 
template<typename T >
bool writeData (const NamedDimensionRangeList &range, const T *data)
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()=default
 
virtual Clonableclone () const =0
 

Additional Inherited Members

- Protected Member Functions inherited from ArrayNd
 ArrayNd (ArrayNd &&other)
 
 ArrayNd (const ArrayNd &other)
 
ArrayNdoperator= (const ArrayNd &other)=default
 

Member Typedef Documentation

◆ size_type

Constructor & Destructor Documentation

◆ ArrayNdSliceTyped() [1/3]

Creates an empty ArrayNdTypedSlice. It contains no data until setData() is called.

◆ ArrayNdSliceTyped() [2/3]

ArrayNdSliceTyped ( const ArrayNdSliceTyped< T > &  other)

◆ ArrayNdSliceTyped() [3/3]

◆ ~ArrayNdSliceTyped()

~ArrayNdSliceTyped
override

Member Function Documentation

◆ arrayAccessHint()

bool arrayAccessHint ( const NamedDimensionRangeList range)
overridevirtual
Parameters
rangeThe range we are expecting to read from when using the getValue or operator() functions.
Returns
true if the hint is valid, false if the dimensions or ranges were out of range.

The range we are hinting that we're about to access repeatedly through individual indexed reads (i.e. using the operator() function).

See also
operator()

Implements ArrayNdTyped< T >.

◆ clone()

ArrayNdSliceTyped< T > * clone
overridevirtual
Returns

Implements ArrayNdTyped< T >.

◆ getAsArrayNd()

ArrayNd * getAsArrayNd ( )
overridevirtual

Returns the slice safely cast to an ArrayNd type.

Implements ArrayNdSlice.

◆ getAttributes()

const DataCollection & getAttributes ( ) const
overridevirtual
Returns
Returns a data collection containing top-level attribute data attached to the ArrayNd. These attributes may include elements such as "units", "cell dimensions", "description" etc.

Implements ArrayNd.

◆ getData()

bool getData ( const NamedDimensionRangeList range,
T *  data 
) const
overridevirtual
Parameters
rangeThe bounded range from which we are reading data. These dimensions must be specified in terms of the sliced dimensions, not the dimensions of the underlying base dataset.
dataThe data store into which we will write the data that we are reading from the dataset.
Returns
true if the data was successfully retrieved from the dataset, false otherwise.

Implements ArrayNdTyped< T >.

◆ getDataFactory()

const DataExecution::DataFactory * getDataFactory
overridevirtual
Returns
The data factory associated with the data slice. All items contained within the slice will be of this type.

Implements ArrayNd.

◆ getDimensionIndex()

int getDimensionIndex ( const QString &  name) const
overridevirtual
Parameters
nameThe name of the dimension we are getting the index of.
Returns
the index of the named dimension. -1 is returned if the named dimension does not exist in the dataset.

Implements ArrayNd.

◆ getDimensionLabels()

ArrayNdDimensionLabels getDimensionLabels ( const QString &  dimensionName) const
overridevirtual
Parameters
dimensionNameThe name of the dimension for which we wish to retrieve its labels.
Returns
The list of labels associated with the specified dimension.

Implements ArrayNd.

◆ getDimensionName()

QString getDimensionName ( int  index) const
overridevirtual
Parameters
indexthe index of the dimension we wish to retrieve the name of.
Returns
the name of the dimension with the specified index.

Implements ArrayNd.

◆ getDimensionSize() [1/2]

ArrayNd::size_type getDimensionSize ( const QString &  name) const
overridevirtual
Parameters
namethe name of the dimension we wish to retrieve the size of.
Returns
the size of the specified dimension (i.e. the number of elements in that dimension). If the dimension does not exist, -1 is returned.

Implements ArrayNd.

◆ getDimensionSize() [2/2]

ArrayNd::size_type getDimensionSize ( int  index) const
overridevirtual
Parameters
indexthe index of the dimension we wish to retrieve the size of.
Returns
the size of the specified dimension (i.e. the number of elements in that dimension). -1 is returned if the index is out of range.

Implements ArrayNd.

◆ getFillValue()

double getFillValue ( ) const
overridevirtual
Returns
The fill value used by the dataset.

The Fill Value of the dataset is used to indicate an 'empty' cell. Cells that do not contain any valid data, or data outside the known / valid range, will contain the fill value.

See also
hasFillValue
setHasFillValue
getFillValueAsVariant

Implements ArrayNdTyped< T >.

◆ getFillValueAsVariant()

QVariant getFillValueAsVariant ( ) const
overridevirtual
Returns
The fill value used by the dataset contained within a QVariant.

The Fill Value of the dataset is used to indicate an 'empty' cell. Cells that do not contain any valid data, or data outside the known / valid range, will contain the fill value.

See also
hasFillValue
setHasFillValue
getFillValueAsVariant

Implements ArrayNdTyped< T >.

◆ hasFillValue()

bool hasFillValue ( ) const
overridevirtual
Returns
True if the dataset has a fill value defined, false otherwise.

The Fill Value of the dataset is used to indicate an 'empty' cell. Cells that do not contain any valid data, or data outside the known / valid range, will contain the fill value. This function returns a value indicating whether or not a fill value is being used.

See also
setHasFillValue
getFillValue
getFillValueAsVariant.

Implements ArrayNdTyped< T >.

◆ isDimensionUnlimited()

bool isDimensionUnlimited ( int  index) const
overridevirtual
Parameters
indexThe index of the dimension we are inspecting.
Returns
true if the dimension is unlimited, false otherwise. An unlimited dimension is one that can by dynamically expanded "on write". For example, a time dimension where we do not know (up front) how many times there are going to be in the dataset, so we can create an "unlimited" dimension, and then repeatedly add to it.
Note
Not all ArrayNd implementations support unlimited dimensions, so in the majority of cases, this function will return false.

Implements ArrayNd.

◆ numDimensions()

int numDimensions
overridevirtual
Returns
the number of dimensions in the data slice.

Implements ArrayNd.

◆ operator=()

ArrayNdSliceTyped< T > & operator= ( ArrayNdSliceTyped< T >  other)

◆ setBaseData()

bool setBaseData ( ArrayNd data,
const NamedDimensionRangeList includedRange,
bool  ownsData = false 
)
overridevirtual
Parameters
dataThe N-dimensional dataset which we are slicing.
includedRangeThe dimensions that make up the slice. The lowest index in each dimension will become index 0 in the slice.
ownsDataWhether or not this structure is to take ownership of the supplied data, and therefore whether or not it should be responsible for cleaning it up.
Returns
true if the base data was set successfully. Will return false if the number of dimensions in includedRange does not exactly match the number of dimensions in data, or if the data factory of data does not match the type of this data structure.

Sets the underlying data that we are slicing into. Must be called before any of the other functions on the slice will work correctly.

Implements ArrayNdSlice.

◆ setDimensions()

bool setDimensions ( const NamedDimensionRangeList dimensions)
overridevirtual
Parameters
dimensionsThe complete list of dimensions we want the dataset to have.
Returns
True if the dimensions of the dataset were successfully set.

Sets the dimensions of the dataset. This will result in the allocation of the underlying data storage. If the dataset previously contained data, this will result in a resize of the dataset, which may require the copying of data, the cost of which will vary greatly depending upon the implementation. For newly created cells in the dataset, a fill-value will be used (by default, this will be a default constructed object).

To avoid expensive copying, it is recommended to only invoke this function on an empty (i.e. uninitialized) dataset.

Note
Not all implementations may support this operation at all times. For example, some implementations may allow users to read from read-only datasets on disk.
See also
writeData
getData
setFillValue

Implements ArrayNd.

◆ setFillValue()

bool setFillValue ( const T &  value)
overridevirtual
Parameters
valueThe fill value that we are setting.
Returns
True if the fill-value was successfully set, otherwise.

When the dimensions of a dataset are set (setDimensions), a fill-value is specified which will be used to populate the newly created cells. This function allows the fill-value to be overridden.

Implements ArrayNdTyped< T >.

◆ setHasFillValue()

void setHasFillValue ( bool  b)
overridevirtual
Parameters
bWhether or not to use a fill value for this dataset. By default, the fill value will be the default constructed type of the underlying stored data.

The Fill Value of the dataset is used to indicate an 'empty' cell. Cells that do not contain any valid data, or data outside the known / valid range, will contain the fill value. This function allows the caller to indicate that a fill value is in use in the dataset.

See also
hasFillValue
getFillValue
getFillValueAsVariant

Implements ArrayNdTyped< T >.

◆ valueAt() [1/2]

T valueAt ( const DimensionIndexList indices) const
overridevirtual
Parameters
indicesThe specific indices of the dimensions we wish to access. By default, the indices in the list are assumed to be in the same order that they are in the dataset (e.g. indices[0] will index into getDimension(0)).
Returns
The specific data value that exists at the coordinates contained in indices.

Retrieve a single value from the datset using syntax similar to array subscript notation. This particular overload allows the caller to retrieve a value from a dataset with any number of dimensions.

Note
The indices.size() must match numDimensions().

Implements ArrayNdTyped< T >.

◆ valueAt() [2/2]

T valueAt ( size_type  dim0,
size_type  dim1 = 0,
size_type  dim2 = 0,
size_type  dim3 = 0,
size_type  dim4 = 0 
) const
overridevirtual
Parameters
dim0The index of the first dimension in the dataset.
dim1The index of the second dimension in the dataset.
dim2The index of the third dimension in the dataset.
dim3The index of the fourth dimension in the dataset.
dim4The index of the fifth dimension in the dataset.
Returns
The specific data value that exists at the coordinates contained in indices.

Retrieve a single value from the datset using syntax similar to array subscript notation. This particular overload allows the caller to retrieve a value from a dataset with 5 dimensions. Dimensions at indexes 5 and above (assuming they exist) will be be retrieved using index 0 for these dimensions.

Note
The indices.size() must match numDimensions().

Implements ArrayNdTyped< T >.

◆ writeData()

bool writeData ( const NamedDimensionRangeList range,
const T *const  data 
)
overridevirtual
Parameters
rangeThe bounded range to which we are writing the data. These dimensions must be specified in terms of the sliced dimensions, not the dimensions of the underlying base dataset.
dataThe data which we are going to write into the dataset.
Returns
true if the data was added to the dataset successfully, false otherwise.

Implements ArrayNdTyped< T >.