oa2DLookupTbl Class Template Reference


Public Methods

 oa2DLookupTbl ()
 oa2DLookupTbl (const oa2DLookupTbl< T, U, V > &tbl)
 oa2DLookupTbl (oaUInt4 numRowsIn, oaUInt4 numColsIn, const oaString &rowNameIn, const oaString &colNameIn, V defaultValue, oaInterpolateType iRowTypeIn=oacSnapDownInterpolateType, oaInterpolateType iColTypeIn=oacSnapDownInterpolateType, oaExtrapolateType eRowLowerTypeIn=oacSnapUpExtrapolateType, oaExtrapolateType eRowUpperTypeIn=oacSnapDownExtrapolateType, oaExtrapolateType eColLowerTypeIn=oacSnapUpExtrapolateType, oaExtrapolateType eColUpperTypeIn=oacSnapDownExtrapolateType)
 ~oa2DLookupTbl ()
oa2DLookupTbl< T, U, V > & operator= (const oa2DLookupTbl< T, U, V > &tbl)
oaUInt4 getNumRows () const
oaUInt4 getNumCols () const
void getRowName (oaString &name) const
void getColName (oaString &name) const
const oaStringgetRowName () const
const oaStringgetColName () const
oaInterpolateType getRowInterpolateType () const
oaInterpolateType getColInterpolateType () const
oaExtrapolateType getRowLowerExtrapolateType () const
oaExtrapolateType getRowUpperExtrapolateType () const
oaExtrapolateType getColLowerExtrapolateType () const
oaExtrapolateType getColUpperExtrapolateType () const
getDefaultValue () const
getRowHeader (oaUInt4 index) const
getColHeader (oaUInt4 index) const
getValue (oaUInt4 rowIndex, oaUInt4 colIndex) const
find (T rowKey, U colKey) const
void setNumRows (oaUInt4 numRowsIn)
void setNumCols (oaUInt4 numColsIn)
void setRowName (const oaString &name)
void setColName (const oaString &name)
void setRowInterpolateType (oaInterpolateType type)
void setColInterpolateType (oaInterpolateType type)
void setRowLowerExtrapolateType (oaExtrapolateType type)
void setRowUpperExtrapolateType (oaExtrapolateType type)
void setColLowerExtrapolateType (oaExtrapolateType type)
void setColUpperExtrapolateType (oaExtrapolateType type)
void setDefaultValue (V value)
void setRowHeader (oaUInt4 index, T value)
void setColHeader (oaUInt4 index, U value)
void setValue (oaUInt4 rowIndex, oaUInt4 colIndex, V value)
oaBoolean operator== (const oa2DLookupTbl< T, U, V > &name) const
oaBoolean operator!= (const oa2DLookupTbl< T, U, V > &name) const
oaUInt8 calcVMSize () const

Detailed Description

template<class T, class U, class V>
class oa2DLookupTbl< T, U, V >

The oa2DLookupTbl class is a template for a two-dimensional lookup table. The table has both header entries and return value entries. When a lookup is performed the key is compared with the header entries to find its location in that set. The lookup will then return the corresponding return value entry, or a value based on the nearest return value entries.

The class is templatized for the type of both the row and column headers and the return value entries. At the time that a lookup is performed, the header entries are assumed to be in strictly ascending order. They may be out of order while the table is being created or modified.

The handling of keys that are not exact header entries is determined by the interpolation and extrapolation types set in the table. Interpolation applies to keys that are within the range of the header entries, and extrapolation applies to keys that are outside of the values in the header. Row values and column values are always treated the same. See the classes oaExtrapolateType and oaInterpolateType for more details.

The lookup classes (oa1DLookupTbl and oa2DLookupTbl) are used by OpenAccess to represent values passed to oaValue subclasses -- see oaInt2DTblValue, oaFlt2DTblValue, and oaViaDef2DTblValue for examples of oaValue subclasses that use oa2DLookupTbls. The oaValue subclasses, in turn, are used to associate different values with constraints -- see oaValue() and its subclasses for more information. The oa2DLookupTbl utility class can be used by applications for other purposes as well.

Here is an example of an oa2DLookupTbl<oaUInt4, oaUInt4, oaFloat>:

Indexes _ 0 1 2
_ Headers 20 40 60
0 100 2.2 3.3 4.4
1 200 12.2 13.3 14.4

In this example, looking up with keys of 150 and 30 will return:

        2.2     if InterpolateType is set to oacSnapDownInterpolateType
        7.75    if InterpolateType is set to oacLinearInterpolateType
        13.3    if InterpolateType is set to oacSnapUpInterpolateType


Constructor & Destructor Documentation

template<class T, class U, class V>
oa2DLookupTbl< T, U, V >::oa2DLookupTbl  
 

This function constructs an empty oa2DLookupTbl instance to provide a two-dimensional lookup table. The table has a 0 allocated size at this point. oa2DLookupTbl::setNumCols and oa2DLookupTbl::setNumRows must be called before it can be used.

template<class T, class U, class V>
oa2DLookupTbl< T, U, V >::oa2DLookupTbl const oa2DLookupTbl< T, U, V > &    tbl
 

This function constructs an oa2DLookupTbl instance and initializes the table to the same values that are in the given oa2DLookupTbl tbl.

Parameters:
tbl The oa2DLookupTbl to copy

template<class T, class U, class V>
oa2DLookupTbl< T, U, V >::oa2DLookupTbl oaUInt4    numRowsIn,
oaUInt4    numColsIn,
const oaString &    rowNameIn,
const oaString &    colNameIn,
V    defaultValue,
oaInterpolateType    iRowTypeIn = oacSnapDownInterpolateType,
oaInterpolateType    iColTypeIn = oacSnapDownInterpolateType,
oaExtrapolateType    eRowLowerTypeIn = oacSnapUpExtrapolateType,
oaExtrapolateType    eRowUpperTypeIn = oacSnapDownExtrapolateType,
oaExtrapolateType    eColLowerTypeIn = oacSnapUpExtrapolateType,
oaExtrapolateType    eColUpperTypeIn = oacSnapDownExtrapolateType
 

This function constructs an oa2DLookupTbl instance using the specified number of rows and columns to create a two-dimensional lookup table.

Parameters:
numRowsIn The number of rows to allocate in the table
numColsIn The number of columns to allocate in the table
rowNameIn The name of the row header
colNameIn The name of the column header
defaultValue The default value
iRowTypeIn The interpolation to apply for keys that are between the row header values
iColTypeIn The interpolation to apply for keys that are between the column header values
eRowLowerTypeIn The extrapolation to apply for keys that are below all row header values
eRowUpperTypeIn The extrapolation to apply for keys that are above all row header values
eColLowerTypeIn The extrapolation to apply for keys that are below all column header values
eColUpperTypeIn The extrapolation to apply for keys that are above all column header values

template<class T, class U, class V>
oa2DLookupTbl< T, U, V >::~oa2DLookupTbl  
 

This function destroys this oa2DLookupTbl instance and all data associated with the table.


Member Function Documentation

template<class T, class U, class V>
oaUInt8 oa2DLookupTbl< T, U, V >::calcVMSize   const
 

This function returns the number of bytes this object uses in virtual memory.

template<class T, class U, class V>
V oa2DLookupTbl< T, U, V >::find T    rowKey,
U    colKey
const
 

This function returns a value based on the specified row and column keys. If the specified keys are not present in the table, the value is interpolated or extrapolated.

Parameters:
rowKey The row value to find
colKey The column value to find

template<class T, class U, class V>
U oa2DLookupTbl< T, U, V >::getColHeader oaUInt4    index const [inline]
 

This function returns a value from the column header for this table.

Parameters:
index The index location in the column header. This index must be a legal index for the columns in this table.

template<class T, class U, class V>
oaInterpolateType oa2DLookupTbl< T, U, V >::getColInterpolateType   const [inline]
 

This function returns the interpolation type which is applied to keys that are between the column header values.

template<class T, class U, class V>
oaExtrapolateType oa2DLookupTbl< T, U, V >::getColLowerExtrapolateType   const [inline]
 

This function returns the extrapolation type which is applied to keys that are below to the column header values.

template<class T, class U, class V>
const oaString & oa2DLookupTbl< T, U, V >::getColName   const [inline]
 

This function returns the name of the column header of this table.

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::getColName oaString &    name const [inline]
 

This function returns the name of the column header of this table.

Parameters:
name The returned column header name

template<class T, class U, class V>
oaExtrapolateType oa2DLookupTbl< T, U, V >::getColUpperExtrapolateType   const [inline]
 

This function returns the extrapolation type which is applied to keys that are above to the column header values.

template<class T, class U, class V>
V oa2DLookupTbl< T, U, V >::getDefaultValue   const [inline]
 

This function returns the default value of this table.

template<class T, class U, class V>
oaUInt4 oa2DLookupTbl< T, U, V >::getNumCols   const [inline]
 

This function returns the number of allocated columns in this table.

template<class T, class U, class V>
oaUInt4 oa2DLookupTbl< T, U, V >::getNumRows   const [inline]
 

This function returns the number of allocated rows in this table.

template<class T, class U, class V>
T oa2DLookupTbl< T, U, V >::getRowHeader oaUInt4    index const [inline]
 

This function returns a value from the row header for this table. The index must be a legal value for the rows of this table.

Parameters:
index The index location in the row header array

template<class T, class U, class V>
oaInterpolateType oa2DLookupTbl< T, U, V >::getRowInterpolateType   const [inline]
 

This function returns the interpolation type which is applied to keys that are between the row header values.

template<class T, class U, class V>
oaExtrapolateType oa2DLookupTbl< T, U, V >::getRowLowerExtrapolateType   const [inline]
 

This function returns the extrapolation type which is applied to keys that are below to the row header values.

template<class T, class U, class V>
const oaString & oa2DLookupTbl< T, U, V >::getRowName   const [inline]
 

This function returns the name of the row header of this table.

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::getRowName oaString &    name const [inline]
 

This function returns the name of the row header of this table.

Parameters:
name The returned row header name

template<class T, class U, class V>
oaExtrapolateType oa2DLookupTbl< T, U, V >::getRowUpperExtrapolateType   const [inline]
 

This function returns the extrapolation type which is applied to keys that are above to the row header values.

template<class T, class U, class V>
V oa2DLookupTbl< T, U, V >::getValue oaUInt4    rowIndex,
oaUInt4    colIndex
const [inline]
 

This function gets a return value contained in this table. The row and column indexes must be legal for the size of this table.

Parameters:
rowIndex The row index location in this table
colIndex The column index location in this table

template<class T, class U, class V>
oaBoolean oa2DLookupTbl< T, U, V >::operator!= const oa2DLookupTbl< T, U, V > &    name const
 

This function compares this oa2DLookupTbl lookup table with the specified oa2DLookupTbl table. If they are not equal, true is returned; otherwise, false.

Parameters:
name the name of the oa2DLookupTbl lookup table to compare this table to.

template<class T, class U, class V>
oa2DLookupTbl< T, U, V > & oa2DLookupTbl< T, U, V >::operator= const oa2DLookupTbl< T, U, V > &    tbl
 

This is the deep assignment operator for the oa2DLookupTbl. Table attributes and values are copied from the specified oa2DLookupTbl to this table.

Parameters:
tbl the oa2DLookupTbl to copy to this table.

template<class T, class U, class V>
oaBoolean oa2DLookupTbl< T, U, V >::operator== const oa2DLookupTbl< T, U, V > &    name const
 

This function compares this oa2DLookupTbl lookup table with the specified oa2DLookupTbl table. If they are equal, true is returned; otherwise, false.

Parameters:
name the name of the oa2DLookupTbl lookup table to compare this table to.

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setColHeader oaUInt4    index,
U    value
 

This function sets a value in the column header for this table.

Parameters:
index The index location in the column header array. This must be valid for the current number of columns in the table.
value The header value for this column

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setColInterpolateType oaInterpolateType    type
 

This function sets the interpolation type for the column header of this table.

Parameters:
type The interpolate type

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setColLowerExtrapolateType oaExtrapolateType    type
 

This function sets the extrapolation type for the keys that are below all column header values.

Parameters:
type The extrapolate type

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setColName const oaString &    name
 

This function sets the name of the column header of this table

Parameters:
name The column header name

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setColUpperExtrapolateType oaExtrapolateType    type
 

This function sets the extrapolation type for the keys that are above all column header values.

Parameters:
type The extrapolate type

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setDefaultValue V    value
 

This function sets the default value of this table to the specified value.

Parameters:
value The default value

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setNumCols oaUInt4    numColsIn
 

This function sets the allocated number of columns in this table. The data in the table is retained where it fits within the new number of columns.

Parameters:
numColsIn The number of columns to allocate for this table

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setNumRows oaUInt4    numRowsIn
 

This function sets the allocated number of rows in this table. The data in the table is retained where it fits within the new number of rows.

Parameters:
numRowsIn The possible number of rows this table can contain

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setRowHeader oaUInt4    index,
T    value
 

This function sets a value in the row header for this table.

Parameters:
index The index location in the row header array. This must be valid for the current number of rows in the table.
value The lookup key value to set

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setRowInterpolateType oaInterpolateType    type
 

This function sets the interpolation type for the row header of this table.

Parameters:
type The interpolate type

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setRowLowerExtrapolateType oaExtrapolateType    type
 

This function sets the extrapolation type for the keys that are below all row header values.

Parameters:
type The extrapolate type

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setRowName const oaString &    name
 

This function sets the name of the row header of this table.

Parameters:
name The row header name

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setRowUpperExtrapolateType oaExtrapolateType    type
 

This function sets the extrapolation type for the keys that are above all row header values.

Parameters:
type The extrapolate type

template<class T, class U, class V>
void oa2DLookupTbl< T, U, V >::setValue oaUInt4    rowIndex,
oaUInt4    colIndex,
V    value
 

This function sets a return value in this table.

Parameters:
rowIndex The row index location in this table. This index must be legal for this table.
colIndex The column index location in this table. This index must be legal for this table.
value The lookup value


The documentation for this class was generated from the following files:

Return to top of page