Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: An Overview of the Client Class 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 § 15.7, page [*], 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 results 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 Client Class Up: The Glish Client Library Previous: The Glish Client Library   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15