NumericType< T, typeOrdinal > Class Template Reference

Inheritance diagram for NumericType< T, typeOrdinal >:

StoredTypeDescriptor List of all members.

Public Types

typedef uint Ordinal
 Each type must have a unique positive integer ordinal associated with it.

Public Member Functions

template<>
void visitValue (DataVisitor &dataVisitor, void const *pData, TupleStorageByteLength cbData) const
 Visits a value of this type.
template<>
void visitValue (DataVisitor &dataVisitor, void const *pData, TupleStorageByteLength cbData) const
 Visits a value of this type.
template<>
uint getBitCount () const
 
Returns:
number of bits in marshalled representation, or 0 for a non-bit type; currently only 0 or 1 is supported


Private Member Functions

virtual Ordinal getOrdinal () const
 
Returns:
the ordinal representing this type.

virtual uint getBitCount () const
 
Returns:
number of bits in marshalled representation, or 0 for a non-bit type; currently only 0 or 1 is supported

virtual uint getFixedByteCount () const
 
Returns:
the width in bytes for a fixed-width non-bit type which admits no per-attribute precision, or 0 for types with per-attribute precision; for bit types, this yields the size of the unmarshalled representation

virtual uint getMinByteCount (uint cbMaxWidth) const
 Gets the number of bytes required to store the narrowest value with this type, given a particular max byte count.
virtual uint getAlignmentByteCount (uint cbWidth) const
 Gets the alignment size in bytes required for values of this type, given a particular max byte count.
virtual void visitValue (DataVisitor &dataVisitor, void const *pData, TupleStorageByteLength cbData) const
 Visits a value of this type.
virtual int compareValues (void const *pData1, TupleStorageByteLength cbData1, void const *pData2, TupleStorageByteLength cbData2) const
 Compares two values of this type.

Detailed Description

template<class T, StandardTypeDescriptorOrdinal typeOrdinal>
class NumericType< T, typeOrdinal >

Definition at line 43 of file StandardTypeDescriptor.cpp.


Member Typedef Documentation

typedef uint StoredTypeDescriptor::Ordinal [inherited]

Each type must have a unique positive integer ordinal associated with it.

This is used to reconstruct a StoredTypeDescriptor object from a stored attribute definition.

Definition at line 44 of file StoredTypeDescriptor.h.


Member Function Documentation

template<class T, StandardTypeDescriptorOrdinal typeOrdinal>
virtual Ordinal NumericType< T, typeOrdinal >::getOrdinal (  )  const [inline, private, virtual]

Returns:
the ordinal representing this type.

Implements StoredTypeDescriptor.

Definition at line 45 of file StandardTypeDescriptor.cpp.

00046     {
00047         return typeOrdinal;
00048     }

template<class T, StandardTypeDescriptorOrdinal typeOrdinal>
virtual uint NumericType< T, typeOrdinal >::getBitCount (  )  const [inline, private, virtual]

Returns:
number of bits in marshalled representation, or 0 for a non-bit type; currently only 0 or 1 is supported

Implements StoredTypeDescriptor.

Definition at line 50 of file StandardTypeDescriptor.cpp.

00051     {
00052         return 0;
00053     }

template<class T, StandardTypeDescriptorOrdinal typeOrdinal>
virtual uint NumericType< T, typeOrdinal >::getFixedByteCount (  )  const [inline, private, virtual]

Returns:
the width in bytes for a fixed-width non-bit type which admits no per-attribute precision, or 0 for types with per-attribute precision; for bit types, this yields the size of the unmarshalled representation

Implements StoredTypeDescriptor.

Definition at line 55 of file StandardTypeDescriptor.cpp.

00056     {
00057         return sizeof(T);
00058     }

template<class T, StandardTypeDescriptorOrdinal typeOrdinal>
virtual uint NumericType< T, typeOrdinal >::getMinByteCount ( uint  cbMaxWidth  )  const [inline, private, virtual]

Gets the number of bytes required to store the narrowest value with this type, given a particular max byte count.

For a fixed-width type, the return value is the same as the input.

Parameters:
cbMaxWidth maximum width for which to compute the minimum
Returns:
number of bytes

Implements StoredTypeDescriptor.

Definition at line 60 of file StandardTypeDescriptor.cpp.

00061     {
00062         assert(cbMaxWidth == sizeof(T));
00063         return cbMaxWidth;
00064     }

template<class T, StandardTypeDescriptorOrdinal typeOrdinal>
virtual uint NumericType< T, typeOrdinal >::getAlignmentByteCount ( uint  cbWidth  )  const [inline, private, virtual]

Gets the alignment size in bytes required for values of this type, given a particular max byte count.

This must be 1, 2, 4, or 8, and may not be greater than 2 for variable-width datatypes. For fixed-width datatypes, the width must be a multiple of the alignment size.

Parameters:
cbWidth width for which to compute the alignment
Returns:
number of bytes

Implements StoredTypeDescriptor.

Definition at line 66 of file StandardTypeDescriptor.cpp.

00067     {
00068         return sizeof(T);
00069     }

template<class T, StandardTypeDescriptorOrdinal typeOrdinal>
virtual void NumericType< T, typeOrdinal >::visitValue ( DataVisitor dataVisitor,
void const *  pData,
TupleStorageByteLength  cbData 
) const [inline, private, virtual]

Visits a value of this type.

Parameters:
dataVisitor the DataVisitor which should be called with the interpreted value
pData the address of the data value
cbData the number of bytes of data

Implements StoredTypeDescriptor.

Definition at line 71 of file StandardTypeDescriptor.cpp.

References DataVisitor::visitSignedInt(), and DataVisitor::visitUnsignedInt().

00075     {
00076         T t = *static_cast<T const *>(pData);
00077         assert(cbData == sizeof(T));
00078         if (std::numeric_limits<T>::is_signed) {
00079             dataVisitor.visitSignedInt(t);
00080         } else {
00081             dataVisitor.visitUnsignedInt(t);
00082         }
00083     }

template<class T, StandardTypeDescriptorOrdinal typeOrdinal>
virtual int NumericType< T, typeOrdinal >::compareValues ( void const *  pData1,
TupleStorageByteLength  cbData1,
void const *  pData2,
TupleStorageByteLength  cbData2 
) const [inline, private, virtual]

Compares two values of this type.

Parameters:
pData1 the address of the first data value
cbData1 the width of the first data value in bytes
pData2 the address of the second data value
cbData2 the width of the second data value in bytes
Returns:
negative if the first data value is less than the second; positive if greater; zero if equal

Implements StoredTypeDescriptor.

Definition at line 85 of file StandardTypeDescriptor.cpp.

00090     {
00091         assert(cbData1 == sizeof(T));
00092         assert(cbData2 == sizeof(T));
00093         T t1 = *static_cast<T const *>(pData1);
00094         T t2 = *static_cast<T const *>(pData2);
00095         if (t1 < t2) {
00096             return -1;
00097         } else if (t1 > t2) {
00098             return 1;
00099         } else {
00100             return 0;
00101         }
00102     }

template<>
void NumericType< double, STANDARD_TYPE_DOUBLE >::visitValue ( DataVisitor dataVisitor,
void const *  pData,
TupleStorageByteLength  cbData 
) const [virtual]

Visits a value of this type.

Parameters:
dataVisitor the DataVisitor which should be called with the interpreted value
pData the address of the data value
cbData the number of bytes of data

Implements StoredTypeDescriptor.

Definition at line 106 of file StandardTypeDescriptor.cpp.

References DataVisitor::visitDouble().

00110 {
00111     double d = *static_cast<double const *>(pData);
00112     assert(cbData == sizeof(double));
00113     dataVisitor.visitDouble(d);
00114 }

template<>
void NumericType< float, STANDARD_TYPE_REAL >::visitValue ( DataVisitor dataVisitor,
void const *  pData,
TupleStorageByteLength  cbData 
) const [virtual]

Visits a value of this type.

Parameters:
dataVisitor the DataVisitor which should be called with the interpreted value
pData the address of the data value
cbData the number of bytes of data

Implements StoredTypeDescriptor.

Definition at line 117 of file StandardTypeDescriptor.cpp.

References DataVisitor::visitFloat().

00121 {
00122     float d = *static_cast<float const *>(pData);
00123     assert(cbData == sizeof(float));
00124     dataVisitor.visitFloat(d);
00125 }

template<>
uint NumericType< bool, STANDARD_TYPE_BOOL >::getBitCount (  )  const [virtual]

Returns:
number of bits in marshalled representation, or 0 for a non-bit type; currently only 0 or 1 is supported

Implements StoredTypeDescriptor.

Definition at line 128 of file StandardTypeDescriptor.cpp.

00129 {
00130     return 1;
00131 }


The documentation for this class was generated from the following file:
Generated on Mon Jun 22 04:00:40 2009 for Fennel by  doxygen 1.5.1