7 #ifndef _MULTIARRAY_CLASS_HEADER_
8 #define _MULTIARRAY_CLASS_HEADER_
228 return ERR_INVALID_STATE;
237 return ERR_INVALID_STATE;
242 return ERR_INVALID_ARG;
248 m_oData = std::vector<T>(nTotal);
262 if (!m_oDimensions.
IsValid() ||
277 tUInt nThisValue = 0;
283 if (nValue >= nThisValue)
308 return ERR_INVALID_INDEX;
323 return ERR_INVALID_INDEX;
332 return ERR_INVALID_INDEX;
335 nIndex += (nProduct * nK);
338 nInternIndex = nIndex;
362 m_oDimensions(oDimensions), m_oData()
389 return m_oDimensions.
IsValid() && !m_oData.empty();
401 return m_oData.size();
414 return m_oDimensions;
428 if (!oIndex.
IsValid() || !ContainsIndex(oIndex))
430 return ERR_INVALID_INDEX;
433 tUInt nInternIndex = 0;
434 if (
IS_FAILED(CalculateInternIndex(oIndex, nInternIndex)))
436 return ERR_INVALID_INDEX;
439 m_oData[nInternIndex] = value;
455 if (!oIndex.
IsValid() || !ContainsIndex(oIndex))
457 return ERR_INVALID_INDEX;
460 tUInt nInternIndex = 0;
461 if (
IS_FAILED(CalculateInternIndex(oIndex, nInternIndex)))
463 return ERR_INVALID_INDEX;
466 value = m_oData[nInternIndex];
482 template <
typename T>
526 template <
typename T>
unsigned int tUInt
type definition for unsigned integer value (platform and compiler dependent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
size_t tSize
type definition for a array size values, map size values etc.
#define IS_FAILED(s)
Check if result is failed.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Multi dimensional array class template.
cMultiArray(const cMultiArrayDimensions &oDimensions)
Constructor that initializes the array to the dimensions specified in the parameter.
virtual ~cMultiArray()
Virtual destructor.
tBool IsValid() const
Check if the array is in a valid state and initialized correctly.
tResult CalculateInternIndex(const cMultiArrayIndex &oIndex, tUInt &nInternIndex) const
Calculate the internal flat index that matches the multi dimensional index specified.
const cMultiArrayDimensions & Dimensions() const
Get the dimensions of the array.
cMultiArrayDimensions m_oDimensions
Stores the arrays dimension object.
tResult InitializeDataStore()
Initializes the data vector to the correct size (specified by the dimensions of the array)
tSize NumElements() const
Get the total number of stored elements in the array across all dimensions.
std::vector< T > m_oData
Stores the arrays actual data (in a flat vector)
tBool ContainsIndex(const cMultiArrayIndex &oIndex) const
Check if an index is in bound of the arrays dimensions.
tResult Set(const cMultiArrayIndex &oIndex, T value)
Set the element at the specified array index.
cMultiArray()
Constructor that initializes the array to an invalid state (0 dimensions)
tResult Get(const cMultiArrayIndex &oIndex, T &value) const
Get the element at the specified array index.
Multi dimensional index class used to dynamically address elements in a multi array.
cMultiArrayIndex()
Constructor that initializes the index to an invalid state.
tSize NumDimensions() const
Get the number of dimensions.
cMultiArrayIndex(tUInt nX, tUInt nY, tUInt nZ, tUInt nT)
Constructor that initializes the index to 4 dimension values.
cMultiArrayIndex(tUInt nX, tUInt nY, tUInt nZ)
Constructor that initializes the index to 3 dimension values.
tBool IsValid() const
Check if the index is valid.
tResult GetDimensionValue(tUInt nDimensionIndex, tUInt &nValue) const
Get the value of the specified dimension.
cMultiArrayIndex(tUInt nX, tUInt nY)
Constructor that initializes the index to 2 dimension values.
tResult AddDimension(tUInt nDimensionValue)
Add a dimension value to the index.
std::vector< tUInt > m_oDimensionvalues
Stores the dimensional values.
cMultiArrayIndex(tUInt nX)
Constructor that initializes the index to a single dimension value.
tResult SetDimensionValue(tUInt nDimensionIndex, tUInt nValue)
Set the value of the specified dimension.
cMultiArrayIndex(tUInt nX, tUInt nY, tUInt nZ, tUInt nT, tUInt nR)
Constructor that initializes the index to 4 dimension values.
A common result class usable as return value throughout.
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
tResult ParseMultiArrayFromString< tFloat32 >(const cString &strRepr, cMultiArray< tFloat32 > &arrDest)
tFloat32 specialization for the ParseMultiArrayFromString function
tResult ParseMultiArrayFromString(const cString &strRepr, cMultiArray< T > &arrDest)
Base templated function to parse a cMultiArray from a string representation.
cString MultiArrayToString< tInt >(const cMultiArray< tInt > &oArray)
tInt specialization for the MultiArrayToString function
tBool operator==(const cMultiArrayIndex &o_A, const cMultiArrayIndex &o_B)
Comparison operator.
tResult ParseMultiArrayFromString< tFloat64 >(const cString &strRepr, cMultiArray< tFloat64 > &arrDest)
tFloat64 specialization for the ParseMultiArrayFromString function
tBool operator!=(const cMultiArrayIndex &o_A, const cMultiArrayIndex &o_B)
Comparison operator.
cMultiArrayIndex cMultiArrayDimensions
Type to specify array dimensions.
cString MultiArrayToString(const cMultiArray< T > &oArray)
Base templated function to serialize a cMultiArray into a string.
tResult ParseMultiArrayFromString< tInt >(const cString &strRepr, cMultiArray< tInt > &arrDest)
tInt specialization for the ParseMultiArrayFromString function
cString MultiArrayToString< tFloat32 >(const cMultiArray< tFloat32 > &oArray)
tFloat32 specialization for the MultiArrayToString function
cString MultiArrayToString< tFloat64 >(const cMultiArray< tFloat64 > &oArray)
tFloat64 specialization for the MultiArrayToString function