26#include <Inventor/STL/map>
31#include <Inventor/STL/limits>
35#pragma warning( push )
36#pragma warning(disable:4251)
105 inline operator unsigned int()
const;
116 inline unsigned int getSize()
const;
156 double getLowest()
const;
161 static void initClass();
170 inline double normalize(
double val)
const;
179 static const bool m_true;
186 template<
typename T>
static SbDataType getTemplateType (
const T&);
191 unsigned char l_uCHAR;
192 unsigned short l_uSHORT;
195 signed short l_sSHORT;
211 template <
typename T>
212 DataValue cast( T value )
const;
214 template <
typename T>
215 T cast(
void* value)
const;
218 typedef std::map<DataType, SbString> TypeToStrMap;
221 template<
typename T>
static double getMinInternal();
224 template<
typename T>
static double getMaxInternal();
227 template<
typename T>
static double getLowestInternal();
233 static TypeToStrMap s_typeToStrMap;
234 static std::map<SbString, DataType> s_strToTypeMap;
245SbDataType::operator
unsigned int()
const
247 return static_cast<unsigned int >(m_type);
262 return (1 << (m_type % 4));
269 return (1 << (m_type % 4)) * 8;
281SbDataType::normalize(
double val)
const
285 double minType =
getMin();
286 double maxType =
getMax();
287 val = (val-minType)/(maxType-minType);
299SbDataType::cast( T value )
const
304 case UNSIGNED_BYTE : dataValue.l_uCHAR = (
unsigned char)value;
break;
305 case UNSIGNED_SHORT: dataValue.l_uSHORT = (
unsigned short)value;
break;
306 case UNSIGNED_INT32: dataValue.l_uINT = (
unsigned int)value;
break;
307 case SIGNED_BYTE : dataValue.l_sCHAR = (
signed char)value;
break;
308 case SIGNED_SHORT : dataValue.l_sSHORT = (
signed short)value;
break;
309 case SIGNED_INT32 : dataValue.l_sINT = (
signed int)value;
break;
310 case FLOAT : dataValue.l_FLOAT = (float)value;
break;
311 case DOUBLE : dataValue.l_DOUBLE = (double)value;
break;
312 default :
SoDebugError::postWarning(
"SbDataType::cast()",
"Unknown data type %d", m_type); memset(&dataValue, 0,
sizeof(DataValue));
break;
320SbDataType::cast(
void* value )
const
324 case UNSIGNED_BYTE :
return (T)(*(
unsigned char*)value);
break;
327 case SIGNED_BYTE :
return (T)(*(
signed char*)value);
break;
328 case SIGNED_SHORT :
return (T)(*(
signed short*)value);
break;
329 case SIGNED_INT32 :
return (T)(*(
signed int*)value);
break;
330 case FLOAT :
return (T)(*(
float*)value);
break;
331 case DOUBLE :
return (T)(*(
double*)value);
break;
340SbDataType::getTemplateType (
const unsigned char&)
348SbDataType::getTemplateType (
const unsigned short&)
356SbDataType::getTemplateType (
const uint32_t&)
364SbDataType::getTemplateType (
const signed char&)
372SbDataType::getTemplateType (
const signed short&)
380SbDataType::getTemplateType (
const int&)
388SbDataType::getTemplateType (
const float&)
396SbDataType::getTemplateType (
const double&)
404SbDataType::getTemplateType (
const T&)
414 switch ( type.m_type )
417 return os <<
"uint8";
419 return os <<
"uint16";
421 return os <<
"uint32";
425 return os <<
"int16";
427 return os <<
"int32";
429 return os <<
"float";
431 return os <<
"double";
433 return os <<
"unknown data type!";
439#pragma warning( pop )
#define TRUE
Possible value of SbBool.
#define FALSE
Possible value of SbBool.
std::ostream & operator<<(std::ostream &os, const SbDataType type)
Writes the type to the specified output stream.
Class encoding a data type.
SbBool isInteger() const
Returns true if the type is an integer type.
DataType getType() const
Returns the type as an enum.
DataType
Supported Data type.
@ UNSIGNED_INT32
unsigned int (32bits)
@ UNKNOWN
unknown data type
@ UNSIGNED_BYTE
unsigned byte
@ SIGNED_SHORT
signed short
@ UNSIGNED_SHORT
unsigned short
@ SIGNED_INT32
signed int (32bits)
double getMax() const
Returns the maximum value of the type.
unsigned int getSize() const
Returns size in bytes of the type.
SbDataType(const SbString &type)
Constructor from a string.
friend std::ostream & operator<<(std::ostream &os, const SbDataType type)
ostream operator for SbDataType
SbDataType(DataType type)
Copy constructor.
SbString getString() const
Returns the type as a string, e.g.
SbDataType()
Default constructor.
unsigned int getNumBits() const
Returns the numer of bits in the type.
double getMin() const
Returns the minimum value of the type.
SbBool isSigned() const
Returns true if the type is signed.
Class for smart character strings.
static void postWarning(const char *methodName, const char *formatString ...)
Posts a warning.