Version: 5.1.6

MEDMEM.MEDARRAY< T > Class Template Reference

#include <MEDMEM_Array.hxx>

Inheritance diagram for MEDMEM.MEDARRAY< T >:
Inheritance graph

Public Member Functions

 MEDARRAY ()
 ~MEDARRAY ()
 MEDARRAY (const int ld_values, const int length_values, const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE)
 MEDARRAY (T *values, const int ld_values, const int length_values, const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE, bool shallowCopy=false, bool ownershipOfValues=false)
 MEDARRAY (MEDARRAY const &m)
 MEDARRAY (MEDARRAY const &m, bool copyOther)
MEDARRAYoperator= (const MEDARRAY &m)
MEDARRAYshallowCopy (const MEDARRAY &m)
int getLeadingValue () const
int getLengthValue () const
const T * get (const MED_EN::medModeSwitch mode)
const T * getRow (const int i)
const T * getColumn (const int j)
const T getIJ (const int i, const int j) const
MED_EN::medModeSwitch getMode () const
void set (const MED_EN::medModeSwitch mode, const T *value)
void setI (const int i, const T *value)
void setJ (const int j, const T *value)
void setIJ (const int i, const int j, const T value)
void calculateOther ()
bool isOtherCalculated () const
void clearOtherMode ()

Data Fields

int _ldValues
int _lengthValues
MED_EN::medModeSwitch _mode
PointerOf< T > _valuesFull
PointerOf< T > _valuesNo
PointerOf< T > _valuesDefault
PointerOf< T > _valuesOther

template<class T>
class MEDMEM::MEDARRAY< T >


Constructor & Destructor Documentation

template<class T >
MEDMEM.MEDARRAY< T >::MEDARRAY (  ) 
template<class T >
MEDMEM.MEDARRAY< T >::~MEDARRAY (  ) 
template<class T >
MEDMEM.MEDARRAY< T >::MEDARRAY ( const int  ld_values,
const int  length_values,
const MED_EN::medModeSwitch  mode = MED_EN::MED_FULL_INTERLACE 
)

This constructor does allocation and does not set values :
. It allocates a "T" array of length_values*ld_values length.
You don't have to know the T values when calling this construtor but you have to call "set" method to initialize them later. You also can get the pointer to the memory zone (with "get" method), and work with it.
The desallocation of T array is not your responsability.

Throws MEDEXCEPTION if T array length is < 1

References MEDMEM.MEDARRAY< T >._mode, MEDMEM.MEDARRAY< T >._valuesDefault, MEDMEM.MEDARRAY< T >._valuesFull, MEDMEM.MEDARRAY< T >._valuesNo, ASSERT_MED, LOCALIZED, MED_EN.MED_FULL_INTERLACE, MED_EN.MED_NO_INTERLACE, and NULL.

template<class T>
MEDMEM.MEDARRAY< T >::MEDARRAY ( T *  values,
const int  ld_values,
const int  length_values,
const MED_EN::medModeSwitch  mode = MED_EN::MED_FULL_INTERLACE,
bool  shallowCopy = false,
bool  ownershipOfValues = false 
)
template<class T>
MEDMEM.MEDARRAY< T >::MEDARRAY ( MEDARRAY< T > const &  m  ) 

This constructor allocates a new medarray and does a copy of pointers
It DOES NOT copy the memory . The two objects will share the same data.
(for copying data, use constructor MEDARRAY(MEDARRAY<T> const & m,bool copyOther).

References MEDMEM.MEDARRAY< T >._valuesDefault, ASSERT_MED, and NULL.

template<class T>
MEDMEM.MEDARRAY< T >::MEDARRAY ( MEDARRAY< T > const &  m,
bool  copyOther 
)

This constructor allocates a new array and does a copy of values included in the m arrays.
If the boolean is setted to true, both representations (in full mode and no interlace mode) will be copied.
Otherwise, only _valuesDefault will be copied.
Desallocation of the arrays is not your reponsability.

Throws MEDEXCEPTION if _valuesOther is null and copyOther equals true

References MEDMEM.MEDARRAY< T >._ldValues, MEDMEM.MEDARRAY< T >._lengthValues, MEDMEM.MEDARRAY< T >._mode, MEDMEM.MEDARRAY< T >._valuesDefault, MEDMEM.MEDARRAY< T >._valuesFull, MEDMEM.MEDARRAY< T >._valuesNo, MEDMEM.MEDARRAY< T >._valuesOther, ASSERT_MED, MED_EN.MED_FULL_INTERLACE, MED_EN.MED_NO_INTERLACE, and NULL.


Member Function Documentation

template<class T >
MEDARRAY< T > & MEDMEM.MEDARRAY< T >::operator= ( const MEDARRAY< T > &  m  ) 
template<class T >
MEDARRAY< T > & MEDMEM.MEDARRAY< T >::shallowCopy ( const MEDARRAY< T > &  m  ) 

Idem operator= but performs only shallow copy (just copy of pointers) of arrays contains in _valuesFull and _valuesNo
WARNING the MEDARRAY returned HAS THE OWNERSHIP OF THE ARRAY !!!!

References MEDMEM.MEDARRAY< T >._ldValues, MEDMEM.MEDARRAY< T >._lengthValues, MEDMEM.MEDARRAY< T >._mode, MEDMEM.MEDARRAY< T >._valuesDefault, MEDMEM.MEDARRAY< T >._valuesFull, MEDMEM.MEDARRAY< T >._valuesNo, MEDMEM.MEDARRAY< T >._valuesOther, MED_EN.MED_FULL_INTERLACE, and NULL.

template<class T >
int MEDMEM.MEDARRAY< T >::getLeadingValue (  )  const

returns _ldValues. (for example, space dimension for coordinates array)

References MEDMEM.MEDARRAY< T >._ldValues.

template<class T >
int MEDMEM.MEDARRAY< T >::getLengthValue (  )  const

returns _ldValues. (for example, number of nodes for coordinates array)

References MEDMEM.MEDARRAY< T >._lengthValues.

template<class T >
const T * MEDMEM.MEDARRAY< T >::get ( const MED_EN::medModeSwitch  mode  ) 

returns a pointer to _valuesDefault or _valuesOther, depending on mode value : if mode is the same as _mode, _valuesDefault is returned. else, if _valuesOther is calculated (if necessary) and then returned. The pointer can be used to set values

References MEDMEM.MEDARRAY< T >._mode, MEDMEM.MEDARRAY< T >._valuesDefault, MEDMEM.MEDARRAY< T >._valuesOther, MEDMEM.MEDARRAY< T >.calculateOther(), and NULL.

template<class T >
const T * MEDMEM.MEDARRAY< T >::getRow ( const int  i  ) 

returns a pointer to ith element of the array. (ith line in a MED_FULL_INTERLACE representation )
Be aware : if _mode is MED_NO_INTERLACE, the entire array will be recalculate in MED_FULL_INTERLACE representation.

References MEDMEM.MEDARRAY< T >._ldValues, MEDMEM.MEDARRAY< T >._lengthValues, MEDMEM.MEDARRAY< T >._valuesDefault, MEDMEM.MEDARRAY< T >._valuesFull, ASSERT_MED, MEDMEM.MEDARRAY< T >.calculateOther(), and NULL.

template<class T >
const T * MEDMEM.MEDARRAY< T >::getColumn ( const int  j  ) 

this method is similar to getRow method.
It returns a pointer to jth line of the array in a MED_NO-INTERLACE representation (for example, 2nd coordinates).
Be aware : if _mode is MED_FULL_INTERLACE, the entire array will be recalculate in MED_NO_INTERLACE representation.

References MEDMEM.MEDARRAY< T >._ldValues, MEDMEM.MEDARRAY< T >._lengthValues, MEDMEM.MEDARRAY< T >._valuesDefault, MEDMEM.MEDARRAY< T >._valuesFull, MEDMEM.MEDARRAY< T >._valuesNo, ASSERT_MED, MEDMEM.MEDARRAY< T >.calculateOther(), and NULL.

template<class T >
const T MEDMEM.MEDARRAY< T >::getIJ ( const int  i,
const int  j 
) const

returns Jth value of Ith element .
don't forget first element is element 1 (and not element 0).

References MEDMEM.MEDARRAY< T >._ldValues, MEDMEM.MEDARRAY< T >._lengthValues, MEDMEM.MEDARRAY< T >._mode, MEDMEM.MEDARRAY< T >._valuesDefault, MED_EN.MED_FULL_INTERLACE, and NULL.

template<class T >
MED_EN::medModeSwitch MEDMEM.MEDARRAY< T >::getMode (  )  const

returns the default mode (_mode)
(internal use : needed by write method)

References MEDMEM.MEDARRAY< T >._mode.

template<class T>
void MEDMEM.MEDARRAY< T >::set ( const MED_EN::medModeSwitch  mode,
const T *  value 
)

sets T pointer of _valuesDefault (cf class PointerOf) on value.
no copy of value is done.
the other representation mode is not recalculate. the corresponding pointers are setted to null

References MEDMEM.MEDARRAY< T >._ldValues, MEDMEM.MEDARRAY< T >._lengthValues, MEDMEM.MEDARRAY< T >._mode, MEDMEM.MEDARRAY< T >._valuesDefault, MEDMEM.MEDARRAY< T >._valuesFull, MEDMEM.MEDARRAY< T >._valuesNo, MEDMEM.MEDARRAY< T >._valuesOther, ASSERT_MED, MED_EN.MED_FULL_INTERLACE, and MED_EN.MED_NO_INTERLACE.

template<class T>
void MEDMEM.MEDARRAY< T >::setI ( const int  i,
const T *  value 
)

Sets ith element to T* values
if they both exist, both _valuesFull and _valuesNo arrays will be updated.
Throws exception if i < 1 or i > _lengthValues

References MEDMEM.MEDARRAY< T >._ldValues, MEDMEM.MEDARRAY< T >._lengthValues, MEDMEM.MEDARRAY< T >._valuesDefault, MEDMEM.MEDARRAY< T >._valuesFull, MEDMEM.MEDARRAY< T >._valuesNo, and NULL.

template<class T>
void MEDMEM.MEDARRAY< T >::setJ ( const int  j,
const T *  value 
)

Sets ith element to T* values
if they both exist, both _valuesFull and _valuesNo arrays will be updated.
Throws exception if i < 1 or i > _lengthValues

References MEDMEM.MEDARRAY< T >._ldValues, MEDMEM.MEDARRAY< T >._lengthValues, MEDMEM.MEDARRAY< T >._valuesDefault, MEDMEM.MEDARRAY< T >._valuesFull, MEDMEM.MEDARRAY< T >._valuesNo, and NULL.

template<class T>
void MEDMEM.MEDARRAY< T >::setIJ ( const int  i,
const int  j,
const T  value 
)

Sets value of Jth coordinate of Ith element to T value.
Maintains coherency.
Throws exception if we don't have 1<=i<=_lengthValues and 1<=j<=_ldValues

References MEDMEM.MEDARRAY< T >._ldValues, MEDMEM.MEDARRAY< T >._lengthValues, MEDMEM.MEDARRAY< T >._valuesDefault, MEDMEM.MEDARRAY< T >._valuesFull, MEDMEM.MEDARRAY< T >._valuesNo, and NULL.

template<class T >
void MEDMEM.MEDARRAY< T >::calculateOther (  ) 

Calculates the other mode of representation : MED_FULL_INTERLACE if __mode = MED_NO_INTERLACE and vice versa.
Throws exception if no value are setted

References MEDMEM.MEDARRAY< T >._ldValues, MEDMEM.MEDARRAY< T >._lengthValues, MEDMEM.MEDARRAY< T >._mode, MEDMEM.MEDARRAY< T >._valuesDefault, MEDMEM.MEDARRAY< T >._valuesFull, MEDMEM.MEDARRAY< T >._valuesNo, MEDMEM.MEDARRAY< T >._valuesOther, ASSERT_MED, MED_EN.MED_FULL_INTERLACE, MED_EN.MED_NO_INTERLACE, and NULL.

template<class T>
bool MEDMEM.MEDARRAY< T >.isOtherCalculated (  )  const
template<class T >
void MEDMEM.MEDARRAY< T >::clearOtherMode (  ) 

This function clears the other mode of representation if it exists It is usefull for people who needs for optimisation reasons to work directly on the inside array without using set-functions

References MEDMEM.MEDARRAY< T >._mode, MEDMEM.MEDARRAY< T >._valuesFull, MEDMEM.MEDARRAY< T >._valuesNo, MEDMEM.MEDARRAY< T >._valuesOther, MEDMEM.MEDARRAY< T >.isOtherCalculated(), and MED_EN.MED_FULL_INTERLACE.


Field Documentation

template<class T>
int MEDMEM.MEDARRAY< T >._ldValues

leading dimension of value (example : space dimension for coordinates)

template<class T>
int MEDMEM.MEDARRAY< T >._lengthValues

length of values (example : number of nodes for coordinates)

data access mode. possible values are :

  • MED_FULL_INTERLACE (default mode)
  • MED_NO_INTERLACE
template<class T>
PointerOf<T> MEDMEM.MEDARRAY< T >._valuesFull

Pointer to representation in mode MED_FULL_INTERLACE

template<class T>
PointerOf<T> MEDMEM.MEDARRAY< T >._valuesNo

Pointer to representation in mode MED_NO_INTERLACE

template<class T>
PointerOf<T> MEDMEM.MEDARRAY< T >._valuesDefault

Pointer to representation in mode _mode

template<class T>
PointerOf<T> MEDMEM.MEDARRAY< T >._valuesOther

Pointer to representation in the other mode (!=_mode)