Accessing and Copying Point Values

Cogent API and Utilities: Version 4.1
Prev | Chapter 2. Point Structure, Storage, and Manipulation | Next

# 2.3. Accessing and Copying Point Values

Cascade DataHub points may take on one of three types:

- integer, using the type `PT_TYPE_INT32`;

- floating point, using the type `PT_TYPE_REAL`; and

- string, using the type `PT_TYPE_STRING`.

Since the type may change during the life of a point, care must be taken to ensure that the appropriate value is used in a given situation. This can be simplified by using the accessor functions `PT_PointString`, `PT_PointInt` and `PT_PointReal`, which will perform a best-guess conversion of the point type to the type requested. The `PT_PointString` function will also format the point value according to a printf-style format directive. The value of a point really includes attributes like its timestamp, confidence factor and security, so it is better to copy the point value using the `PT_PointCopyValue` function, which will copy all related information into the destination point. If the type of the point is `PT_TYPE_STRING`, then the point value will be allocated on the heap. In addition, if the destination point is an existing point of type `PT_TYPE_STRING`, then its current value will be freed using the `free()` C library call.

Prev | Home | Next
Maintaining a Point Hash Table | Up | Memory Allocation and String Values

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.