GET_TYPE(CXXLB)

Shore Programmer's Manual - 2 August 96

NAME

get_type \- get type object

SYNOPSIS

#include <ShoreApp.h>

	/////////////////////////////////////////////
	// Return the OID of T's persistent type object
	/////////////////////////////////////////////
shrc     Ref<T>::get_type(LOID &type_loid) const;

	/////////////////////////////////////////////
	// The combination of the macro TYPE_OBJECT
	// and the method isa() lets you cast references:
	//
	// returns a Ref<T> 
	// if "any" points to a T or subclass of T; 
	// otherwise they return a null ref:
	//
	// pardon the pseudo-code ...
	/////////////////////////////////////////////
const Ref<T> TYPE_OBJECT(T).isa(const Ref<U> &any);

{
    Ref<any>     aref;
    Ref<I>       iref;

    iref = TYPE_OBJECT(I).isa(a);
}

DESCRIPTION

The first form of get_type returns the logical oid of the object's type object. If the ref is nil, LOID::null is returned.

The CPP macro TYPE_OBJECT(T) yields a reference to the compiled-in C++ type object for T. Uses of TYPE_OBJECT will not compile if the SDL language binding for T is not included at compile time.

The second form of get_type returns a pointer to the given object's C++ type object, even if the SDL language binding for T is not included at compile time. In that case, the C++ type object is constructed from the type's persistent object. A null pointer is returned if the reference is not to a Shore object.

Get_type obtains a SH-mode (share-mode) lock on the object.

The method isa returns typed references:

    iref = TYPE_OBJECT(T).isa(a);
If any points to a T or subclass of T, any is cast to a Ref<T> and returned. If not, a null reference is returned.

VERSION

This manual page applies to Version 1.0 of theShore software.

SPONSORSHIP

The Shore project is sponsored by the Advanced Research Project Agency, ARPA order number 018 (formerly 8230), monitored by the U.S. Army Research Laboratory under contract DAAB07-92-C-Q508.

COPYRIGHT

Copyright (c) 1994, 1995, 1996 Computer Sciences Department, University of Wisconsin -- Madison. All Rights Reserved.

SEE ALSO

ref(cxxlb) , stat(oc) , ostat(cxxlb) .