next up previous contents index
Next: An Overview of the Up: The Glish Client Library Previous: The Glish Client Library

An Overview of the Value Class

 

    Value objects can be constructed from C++ scalars or arrays.   For example,

    Value* v = new Value( 5 );
assigns to v a Value object representing the integer 5, while
    double* x = new double[3];
    x[0] = 1.0;
    x[1] = 3.14;
    x[2] = 4.56;
    Value* v = new Value( x, 3 );
assigns to v the equivalent of the Glish value [1, 3.14, 4.56]. By default, Value objects constructed from arrays ``take over" the array: they will realloc() the array if it grows larger and delete it when the Value object is destroyed. The class library also provides mechanisms for specifying that an array should not be altered or should first be copied (see § 13.6, page gif, below).  

The Value class provides a number of member functions for manipulating values:

A key point concerning the Value class is that it makes it easy to wrap   Glish values around an existing program's data structures. These data structures can then be made available to other programs by sending them as event values.

Note           also that both the Value and Client classes use reference-counting for memory management. The Ref() and Unref() functions manipulate each object's reference count. When the count reaches zero the object is deleted and any objects it refers to are Unref()'d. You must always delete Value and Client objects   using Unref(); never using delete.

Unref()'ing a record   until its reference count is zero will result in the record being destroyed and each of its fields being Unref()'d. Individual record fields should not be otherwise Unref()'d unless you Ref()'d them earlier.  


next up previous contents index
Next: An Overview of the Up: The Glish Client Library Previous: The Glish Client Library

Thu Nov 13 16:44:05 EST 1997