oa1DLookupTbl Class Template Reference


Public Methods

 oa1DLookupTbl ()
 oa1DLookupTbl (const oa1DLookupTbl< T, U > &tbl)
 oa1DLookupTbl (oaUInt4 numItemsIn, const oaString &nameIn, U defaultValue, oaInterpolateType iTypeIn=oacSnapDownInterpolateType, oaExtrapolateType eLowerTypeIn=oacSnapUpExtrapolateType, oaExtrapolateType eUpperTypeIn=oacSnapDownExtrapolateType)
 ~oa1DLookupTbl ()
oa1DLookupTbl< T, U > & operator= (const oa1DLookupTbl< T, U > &tbl)
oaUInt4 getNumItems () const
void getName (oaString &nameOut) const
const oaStringgetName () const
oaInterpolateType getInterpolateType () const
oaExtrapolateType getLowerExtrapolateType () const
oaExtrapolateType getUpperExtrapolateType () const
getDefaultValue () const
getHeader (oaUInt4 index) const
getValue (oaUInt4 index) const
find (T key) const
void setNumItems (oaUInt4 numItemsIn)
void setName (const oaString &nameIn)
void setInterpolateType (oaInterpolateType type)
void setLowerExtrapolateType (oaExtrapolateType type)
void setUpperExtrapolateType (oaExtrapolateType type)
void setDefaultValue (U value)
void setHeader (oaUInt4 index, T value)
void setValue (oaUInt4 index, U value)
oaBoolean operator== (const oa1DLookupTbl< T, U > &name) const
oaBoolean operator!= (const oa1DLookupTbl< T, U > &name) const
oaUInt8 calcVMSize () const

Detailed Description

template<class T, class U>
class oa1DLookupTbl< T, U >

The oa1DLookupTbl class is a template for a one-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 both the type of the header and the return value entries. At the time that a lookup is performed, the header entries are assumed to be in strictly ascending order. The entries can 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 range of the header entries. (Note that the table has one extrapolation type set for values below the lowest header entry, and a different extrapolation type set for values above the highest header entry.)

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 oaInt1DTblValue, oaDualInt1DTblValue, oaFlt1DTblValue, oaIntFltTblValue, oaFltIntFltTblValue, and oaAntennaRatioValue for examples of oaValue subclasses that use oa1DLookupTbls. The oaValue subclasses, in turn, are used to associate different values with constraints -- see oaValue() and its subclasses for more information. The oa1DLookupTbl utility class can be used by applications for other purposes as well.

The following example shows an oa1DLookupTbl<oaUInt4, oaFloat> table and demonstrates how a look up key of 12 is interpolated.

The next example shows the same table and demonstrates how a look up key of 7 or 8 is interpolated using the oacInclusiveSnapDownInterpolateType enum.

Consider the look up of a key that is outside of the range of the table, such as a key of 20. The following example uses the same 1D look up table to demonstrate how values outside of the range are extrapolated.


Constructor & Destructor Documentation

template<class T, class U>
oa1DLookupTbl< T, U >::oa1DLookupTbl  
 

This function constructs an empty oa1DLookupTbl instance to provide a one-dimensional lookup table. The table has a 0 allocated size at this point. oa1DLookupTbl::setNumItems must be called before it can be used.

template<class T, class U>
oa1DLookupTbl< T, U >::oa1DLookupTbl< T, U > const oa1DLookupTbl< T, U > &    tbl
 

This function constructs an oa1DLookupTbl instance and initializes the table to the values in the argument oa1DLookupTbl tbl.

Parameters:
tbl The oa1DLookupTbl to copy

template<class T, class U>
oa1DLookupTbl< T, U >::oa1DLookupTbl oaUInt4    numItemsIn,
const oaString &    nameIn,
U    defaultValue,
oaInterpolateType    iTypeIn = oacSnapDownInterpolateType,
oaExtrapolateType    eLowerTypeIn = oacSnapUpExtrapolateType,
oaExtrapolateType    eUpperTypeIn = oacSnapDownExtrapolateType
 

This function constructs an oa1DLookupTbl instance using the specified values to provide a template for a one-dimensional lookup table.

Parameters:
numItemsIn The number of items to allocate for the table
nameIn The name of this table
defaultValue The default value for the table
iTypeIn The interpolation to apply for keys that are between header values
eLowerTypeIn The extrapolation to apply for keys that are below all header values.
eUpperTypeIn The extrapolation to apply for keys that are above all header values.

template<class T, class U>
oa1DLookupTbl< T, U >::~oa1DLookupTbl  
 

This function destroys this oa1DLookupTbl class and all data associated with the table.


Member Function Documentation

template<class T, class U>
oaUInt8 oa1DLookupTbl< T, U >::calcVMSize   const
 

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

template<class T, class U>
U oa1DLookupTbl< T, U >::find T    key const
 

This function returns a value based on the specified header key. If the key is not present in the table, the value is interpolated or extrapolated.

Parameters:
key The key value to lookup

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

This function returns the default value of this table.

template<class T, class U>
T oa1DLookupTbl< T, U >::getHeader oaUInt4    index const [inline]
 

This function returns a header value for this table. The index must be legal for this table.

Parameters:
index The index location in this table

template<class T, class U>
oaInterpolateType oa1DLookupTbl< T, U >::getInterpolateType   const [inline]
 

This function returns the interpolation type of the table.

template<class T, class U>
oaExtrapolateType oa1DLookupTbl< T, U >::getLowerExtrapolateType   const [inline]
 

This function returns the lower extrapolation type of the table.

template<class T, class U>
const oaString & oa1DLookupTbl< T, U >::getName   const [inline]
 

This function returns the name of this table.

template<class T, class U>
void oa1DLookupTbl< T, U >::getName oaString &    nameOut const [inline]
 

This function returns the name of this table.

Parameters:
nameOut The returned name.

template<class T, class U>
oaUInt4 oa1DLookupTbl< T, U >::getNumItems   const [inline]
 

This function returns the allocated size of this table.

template<class T, class U>
oaExtrapolateType oa1DLookupTbl< T, U >::getUpperExtrapolateType   const [inline]
 

This function returns the upperExtrapolation type of the table.

template<class T, class U>
U oa1DLookupTbl< T, U >::getValue oaUInt4    index const [inline]
 

This function gets a return value contained in this table. The index must be legal for this table.

Parameters:
index The index location in this table

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

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

Parameters:
name Name of the oa1DLookupTbl lookup table to compare this table to.

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

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

Parameters:
tbl the oa1DLookupTbl to copy to this table

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

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

Parameters:
name Name of the oa1DLookupTbl lookup table to compare this table to.

template<class T, class U>
void oa1DLookupTbl< T, U >::setDefaultValue U    value
 

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

Parameters:
value The default value

template<class T, class U>
void oa1DLookupTbl< T, U >::setHeader oaUInt4    index,
T    value
 

This function sets a header value in this table.

Parameters:
index The index location in this table. The index must be legal for this table.
value The header value

template<class T, class U>
void oa1DLookupTbl< T, U >::setInterpolateType oaInterpolateType    type
 

This function sets the interpolation type of this table.

template<class T, class U>
void oa1DLookupTbl< T, U >::setLowerExtrapolateType oaExtrapolateType    type
 

This function sets the extrapolation type of this table for keys that are below all the header values.

Parameters:
type The extrapolation type

template<class T, class U>
void oa1DLookupTbl< T, U >::setName const oaString &    nameIn
 

This function sets the name of this table to the specified name.

Parameters:
nameIn The name of this table.

template<class T, class U>
void oa1DLookupTbl< T, U >::setNumItems oaUInt4    numItemsIn
 

This function sets the allocated size of this table. The previous values will be maintained in the new table if there is room. If the new size is smaller than the previous size then some of the old values will be discarded. If the new size is larger than the previous size then the previous values will still be present in the same index locations.

Parameters:
numItemsIn The possible number of items this table can contain

template<class T, class U>
void oa1DLookupTbl< T, U >::setUpperExtrapolateType oaExtrapolateType    type
 

This function sets the extrapolation type of this table for keys that are above all the header values.

Parameters:
type The extrapolation type

template<class T, class U>
void oa1DLookupTbl< T, U >::setValue oaUInt4    index,
U    value
 

This function sets a return value in this table. The index must be legal for this table.

Parameters:
index The index location in this table
value The return value


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

Return to top of page