Ref Class

The mapping in the C++ programming language of an SQL REF value, which is a reference to an SQL structured type value in the database.

Each REF value has a unique identifier of the object it refers to. An SQL REF value may be used in place of the SQL structured type it references; it may be used as either a column value in a table or an attribute value in a structured type.

Because an SQL REF value is a logical pointer to an SQL structured type, a Ref object is by default also a logical pointer; thus, retrieving an SQL REF value as a Ref object does not materialize the attributes of the structured type on the client.

A Ref object can be saved to persistent storage and is de-referenced through operator*(), operator->() or ptr() methods. T must be a class derived from PObject. In the following sections, T* and PObject* are used interchangeably.

getConnection()

isClear()

isNull()

This method tests whether the Ref object is NULL. If the Ref object is NULL, then TRUE is returned; otherwise, FALSE is returned.

Syntax

bool isNull() const;

markDelete()

This method marks the referenced object as deleted.

Syntax

void markDelete();

operator->()

This method dereferences the Ref object and pins, or fetches the referenced object if necessary. This might result in prefetching a graph of objects if prefetch attributes of the referenced object are set.

Syntax

Description

T *operator->();

Dereferenes and pins or fetches a non-constRef object.

const T *operator->() const;

Dereferences and pins or fetches a constRef object.

operator*()

This method dereferences the Ref object and pins or fetches the referenced object if necessary. This might result in prefetching a graph of objects if prefetch attributes of the referenced object are set. The object does not need to be deleted. Destructor would be automatically called when it goes out of scope.

Syntax

Description

T& operator*();

Dereferenes and pins or fetches a non-constRef object.

const T& operator*() const;

Dereferences and pins or fetches a constRef object.

operator==()

This method tests whether two Ref objects are referencing the same object. If the Ref objects are referencing the same object, then TRUE is returned; otherwise, FALSE is returned.

Syntax

bool operator == (
const Ref<T> &ref) const;

Parameter

Description

ref

The Ref object of the object to be compared.

operator!=()

This method tests whether two Ref objects are referencing the same object. If the Ref objects are not referencing the same object, then TRUE is returned; otherwise, FALSE is returned.

Syntax

bool operator!= (
const Ref<T> &ref) const;

Parameter

Description

ref

The Ref object of the object to be compared.

operator=()

Assigns the Ref or the object to a Ref. For the first case, the Refs are assigned and for the second case, the Ref is constructed from the object and then assigned.

Syntax

Description

Ref<T>& operator=(
const Ref<T> &src);

Assigns a Ref to a Ref.

Ref<T>& operator=(
const T *)obj;

Assigns a Ref to an object.

Parameter

Description

src

The source Ref object to be assigned.

obj

The source object pointer whose Ref object is to be assigned.

ptr()

Returns a pointer to a PObject. This operator dereferences the Ref and pins or fetches the object if necessary. This might result in prefetching a graph of objects if prefetch attributes of the Ref are set.

Syntax

Description

T *ptr();

Returns a pointer of a non-constRef object.

const T *ptr() const;

Returns a pointer of a constRef object.

setPrefetch()

Sets the prefetching options for the complex object retrieval. This method specifies depth up to which all objects reachable from this object through Refs (transitive closure) should be prefetched. If only selected attribute types are to be prefetched, then setPrefetch(type_name, depth) should be used. This method specifies which Ref attributes of the object it refers to should be followed for prefetching of the objects (complex object retrieval) and how many levels deep those links should be followed.

Syntax

Description

void setPrefetch(
const string &typeName,
unsigned int depth);

Get the value of a parameter as a PObject.

void setPrefetch(
unsigned int depth);

Get the value of a parameter as a PObject.

void setPrefetch(
const UString &typeName,
unsigned int depth);

Get the value of a parameter as a PObject.

Parameter

Description

typeName

Type of the Ref attribute to be prefetched.

depth

Depth level to which the links should be followed.

setLock()

This method specifies how the object should be locked when dereferenced.