golib
0.5
|
Provides type information. More...
#include <gotype.h>
Public Member Functions | |
goType (goTypeEnum t) | |
Constructor. More... | |
goType (const goType &other) | |
bool | setID (goTypeEnum t) |
goSize_t | getSize () const |
Get size of this type. More... | |
bool | isSigned () const |
Query signedness of this type. More... | |
const goString & | getString () const |
Get description string of this type. More... | |
goTypeEnum | getID () const |
Get enumerator for the type set in this object. More... | |
goCompareFunction | getLowerThanFunction () const |
Get a compare function for "lower than" relation. More... | |
goCompareFunction | getGreaterThanFunction () const |
Get a compare function for "greater than" relation. More... | |
goCompareFunction | getEqualFunction () const |
Get a compare function for "equal" relation. More... | |
goIndexFunction | getIndexFunction () const |
Get an index function. More... | |
goIndex_t | getMinIndex () const |
Get the minimum index. More... | |
goIndex_t | getMaxIndex () const |
Get the maximum index. More... | |
goDouble | getMinimum () const |
Get the minimum value represented by this data type. More... | |
goDouble | getMaximum () const |
Get the maximum value represented by this data type. More... | |
const goType & | operator= (const goType &other) |
![]() | |
goObjectBase () | |
Constructor. | |
virtual | ~goObjectBase () |
Destructor. More... | |
const char * | getClassName () const |
Returns the class name. More... | |
int | getClassID () const |
virtual goSize_t | memoryUsage () const |
Returns the size of this object or some measure of its memory consumption. More... | |
void | setObjectName (const char *name) |
Set name string for an object. More... | |
void | setObjectName (const goString &name) |
Set name string for an object. More... | |
const goString & | getObjectName () const |
Get the object name. More... | |
virtual bool | writeObjectFile (FILE *) const |
Write object to a file. More... | |
virtual bool | readObjectFile (FILE *) |
Read object from a file. More... | |
void | connectObject (goObjectBase *object) |
Connects an object to this object. More... | |
void | disconnectObject (const goObjectBase *object) |
Disconnects an object from this object. | |
virtual bool | callObjectMethod (int methodID, goObjectMethodParameters *param=NULL) |
Call an object method by identifier. More... | |
virtual bool | queueObjectMethod (int methodID, goObjectMethodParameters *param=NULL, bool blocking=false) |
Enqueue a method call to an internal list of methods. More... | |
bool | callQueuedMethods () |
Call all queued methods. More... | |
Static Public Member Functions | |
static goSize_t | getSize (goTypeEnum t) |
Get size of type t. More... | |
static bool | isSigned (goTypeEnum t) |
Returns signedness of type t. More... | |
static void | getString (goTypeEnum t, goString &stringRet) |
Get description string for type t. More... | |
Additional Inherited Members | |
![]() | |
void | setClassID (int id) |
Sets the class name. | |
void | printClassMessage (const char *msg) |
Sets the class name. More... | |
void | printClassMessage (goString &msg) |
Prints an informational message to the calling console. More... | |
void | sendObjectMessage (int messageID, void *data=NULL) |
Sends a message to all connected objects. | |
void | sendObjectMessage (goObjectBase *object, int messageID, void *data=NULL) |
Sends a message to a specific object. | |
virtual void | receiveObjectMessage (const goObjectMessage &message) |
Receive a message. More... | |
Provides type information.
This class contains information about a data type. It provides an ID enumerator (see goTypeEnum) such as GO_UINT8, GO_INT8, GO_UINT16, GO_INT16, GO_UINT32, GO_INT32, GO_FLOAT, GO_DOUBLE, ..., a character string describing the type, the data size in bytes, and a means to generate lookup tables for data. In order to create a lookup table, you can use getIndexFunction() to get a function which generates indices of type goIndex_t from a void* to a data value. You may also specify your own index generating functions for a specific type (see goIndexFunction). Get the minimum and maximum indices created by the function returned by getIndexFunction() using the methods getMinIndex() and getMaxIndex() and use these values to simply create an array of values you want to map each index to, like this:
... goSignal3D<void>* sig = ...; goArray<goUInt16> LUT; goUInt16* LUTOrigin = 0; { goType targetType (GO_UINT16); goIndex_t minIndex = sig->getDataType().getMinIndex(); goIndex_t maxIndex = sig->getDataType().getMaxIndex(); goDouble delta = (targetType.getMaximum() - targetType.getMinimum())/ (goDouble)(maxIndex - minIndex); LUT.resize (maxIndex - minIndex + 1); LUTOrigin = LUT.getPtr() - minIndex; goIndex_t i; goDouble value = (goDouble)targetType.getMinimum(); for (i = minIndex; i <= maxIndex; ++i) { LUTOrigin[i] = (goUInt16)value; value += delta; } } goIndexFunction indexFunction = sig->getDataType().getIndexFunction(); // Get the uint16 value for the data value at (5,1,2): goUInt16 value = LUTOrigin[indexFunction(sig->getPtr(5,1,2)]; ...
You can also use the function goCreateQuantizationTable() for this:
... goSignal3D<void>* sig = ...; goArray<goUInt16> LUT; goUInt16* LUTOrigin = 0; lutOrigin = goCreateQuantizationTable (dataType, goUInt16(0), goUInt16(65535), minIndex, maxIndex, lut); goIndexFunction indexFunction = sig->getDataType().getIndexFunction(); // Get the uint16 value for the data value at (5,1,2): goUInt16 value = LUTOrigin[indexFunction(sig->getPtr(5,1,2)]; ...
goType::goType | ( | goTypeEnum | t | ) |
Constructor.
t | Type enumerator for this object. See goTypeEnum |
goCompareFunction goType::getEqualFunction | ( | ) | const |
Get a compare function for "equal" relation.
goCompareFunction goType::getGreaterThanFunction | ( | ) | const |
Get a compare function for "greater than" relation.
goTypeEnum goType::getID | ( | ) | const |
Get enumerator for the type set in this object.
goIndexFunction goType::getIndexFunction | ( | ) | const |
Get an index function.
goCompareFunction goType::getLowerThanFunction | ( | ) | const |
Get a compare function for "lower than" relation.
goDouble goType::getMaximum | ( | ) | const |
Get the maximum value represented by this data type.
goIndex_t goType::getMaxIndex | ( | ) | const |
Get the maximum index.
goDouble goType::getMinimum | ( | ) | const |
Get the minimum value represented by this data type.
goIndex_t goType::getMinIndex | ( | ) | const |
Get the minimum index.
goSize_t goType::getSize | ( | ) | const |
Get size of this type.
|
static |
Get size of type t.
t | Type enumerator. |
const goString & goType::getString | ( | ) | const |
Get description string of this type.
|
static |
Get description string for type t.
t | Type enumerator. |
stringRet | String containing the description after the method returned. |
bool goType::isSigned | ( | ) | const |
Query signedness of this type.
|
static |
Returns signedness of type t.
t | Type enumerator. |