golib  0.5
goType Class Reference

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 goStringgetString () 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 goTypeoperator= (const goType &other)
 
- Public Member Functions inherited from goObjectBase
 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 goStringgetObjectName () 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

- Protected Member Functions inherited from goObjectBase
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...
 

Detailed Description

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)];
 ...
 

Constructor & Destructor Documentation

◆ goType()

goType::goType ( goTypeEnum  t)

Constructor.

Parameters
tType enumerator for this object. See goTypeEnum

Member Function Documentation

◆ getEqualFunction()

goCompareFunction goType::getEqualFunction ( ) const

Get a compare function for "equal" relation.

Returns
Compare function for "equal" relation.

◆ getGreaterThanFunction()

goCompareFunction goType::getGreaterThanFunction ( ) const

Get a compare function for "greater than" relation.

Returns
Compare function for "greater than" relation.

◆ getID()

goTypeEnum goType::getID ( ) const

Get enumerator for the type set in this object.

Returns
The enumerator t of the type set in the constructor goType(t).
Examples
videocapture/videocapture.cpp.

◆ getIndexFunction()

goIndexFunction goType::getIndexFunction ( ) const

Get an index function.

Returns
The standard index generating function for this data type.

◆ getLowerThanFunction()

goCompareFunction goType::getLowerThanFunction ( ) const

Get a compare function for "lower than" relation.

Returns
Compare function for "lower than" relation.

◆ getMaximum()

goDouble goType::getMaximum ( ) const

Get the maximum value represented by this data type.

Returns
The maximum value cast to goDouble.

◆ getMaxIndex()

goIndex_t goType::getMaxIndex ( ) const

Get the maximum index.

Returns
The maximum index generated by the standard index function for this data type.

◆ getMinimum()

goDouble goType::getMinimum ( ) const

Get the minimum value represented by this data type.

Returns
The minimum value cast to goDouble.

◆ getMinIndex()

goIndex_t goType::getMinIndex ( ) const

Get the minimum index.

Returns
The minimum index generated by the standard index function for this data type.

◆ getSize() [1/2]

goSize_t goType::getSize ( ) const

Get size of this type.

Returns
Size of the type set in this object.

◆ getSize() [2/2]

goSize_t goType::getSize ( goTypeEnum  t)
static

Get size of type t.

Parameters
tType enumerator.
Returns
The size of the type t in bytes.

◆ getString() [1/2]

const goString & goType::getString ( ) const

Get description string of this type.

Returns
Const reference to a goString containing the description for the type set in this object.

◆ getString() [2/2]

void goType::getString ( goTypeEnum  t,
goString stringRet 
)
static

Get description string for type t.

Parameters
tType enumerator.
stringRetString containing the description after the method returned.

◆ isSigned() [1/2]

bool goType::isSigned ( ) const

Query signedness of this type.

Returns
True if the type set in this object is signed, false otherwise.

◆ isSigned() [2/2]

bool goType::isSigned ( goTypeEnum  t)
static

Returns signedness of type t.

Parameters
tType enumerator.
Returns
True if t is signed, false otherwise.

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