University of Sheffield   

    The Simons
    Component Library

Introduction   Class Hierarchy   Class Listing   Index of Classes   Index of Methods   Header Files  

Type Class Reference

#include <Type.h>

Inheritance diagram for Type:

Object List of all members.

Detailed Description

Type: the type descriptor for any object.

This class allows programs to access reflectively the type of any object and create new instances of a given Type. A Type descriptor is obtained by calling the type() method of any Object. Type descriptors may also be created explicitly using Type(StringID). You can compare() two Type descriptors and access the name() of a Type. The create() method creates an instance of this Type (ie of the Object-type denoted by this descriptor).

Type maintains a registry of known Object types. A prototype instance of each type must be registered using Type::notify() before Type can create() objects of this type. Type::registry() returns the registry, a Map from String type names to Object prototype instances.


Public Member Functions

 Type ()
 Construct a default Type.

virtual ~Type ()
 Release an unused Type.

 Type (StringID)
 Construct a Type from a String type name.

virtual ObjectID clone () const
 Clone a shallow copy of this Type.

virtual Natural hash () const
 Return a quasi-unique hash code for this type.

virtual Order compare (ObjectID) const
 Compare this Type with another Object.

Order compare (TypeID) const
 Compare this Type with another Type.

StringID name () const
 Return the name of this Type.

ObjectID create () const
 Create a default Object of this Type.


Static Public Member Functions

MapID registry ()
 Type's shared registry of Type names and Objects.

Void notify (ObjectID)
 Notify Type's registry of a new prototype.

ObjectID create (StringID)
 Create a default instance of the named Type.


Constructor & Destructor Documentation

Type::Type  ) 
 

Construct a default Type.

This creates a Type whose name is the String "Void".

Returns:
a Type descriptor for the Void type.

Type::~Type  )  [virtual]
 

Release an unused Type.

Type::Type StringID  name  ) 
 

Construct a Type from a String type name.

All SCL type identifiers are capitalised alphabetic strings, with internal capitalisation used to indicate word boundaries in multi-word identifiers. Block-type identifiers append the block-size as digits in square brackets.

Parameters:
name - a String, the type name.
Returns:
a Type descriptor for the named type.


Member Function Documentation

ObjectID Type::clone  )  const [virtual]
 

Clone a shallow copy of this Type.

Returns:
a shallow copy of this Type.

Reimplemented from Object.

Order Type::compare TypeID  type  )  const
 

Compare this Type with another Type.

Lexicographic comparison, which compares the name of this Type against the name of the other Type, returning an Order in { LESS, EQUAL, MORE }.

Parameters:
type - another Type descriptor.
Returns:
an Order in {LESS, EQUAL, MORE}

Order Type::compare ObjectID  object  )  const [virtual]
 

Compare this Type with another Object.

Generic comparison that tries to convert the other Object into a Type and proceeds to compare according to the lexicographic order of Type names. If the other Object is not a Type, the comparison is undefined and the answer is NONE.

Parameters:
object - another Object.
Returns:
an Order in {NONE, LESS, EQUAL, MORE}

Reimplemented from Object.

ObjectID Type::create StringID  name  )  [static]
 

Create a default instance of the named Type.

Creates a default instance of the named Type by cloning the prototype instance stored in Type's shared registry of known Objects and Types. Any type of Object that has been registered using notify() can be created. Raises a NullPointer exception if the requested Type of Object is unknown.

ObjectID Type::create  )  const
 

Create a default Object of this Type.

Creates a default instance of the requested Type by cloning the prototype instance stored in Type's shared registry of known Objects and Types. Any type of Object that has been registered using notify() can be created. Raises a NullPointer exception if the requested Type of Object is unknown.

Returns:
an instance of this Type.

Natural Type::hash  )  const [virtual]
 

Return a quasi-unique hash code for this type.

Hashes on the type name for this Type. Returns the hash code of the typeName String.

Reimplemented from Object.

StringID Type::name  )  const
 

Return the name of this Type.

By convention, all SCL type identifiers are capitalised alphabetic strings, with internal capitalisation used to indicate word boundaries in multi-word identifiers. Block-type identifiers append the block-size as digits in square brackets.

Returns:
the name of this Type.

Void Type::notify ObjectID  prototype  )  [static]
 

Notify Type's registry of a new prototype.

The prototype Object will be stored opposite its type name in the shared Type registry.

Parameters:
prototype - the Object prototype to register

MapID Type::registry  )  [static]
 

Type's shared registry of Type names and Objects.


The documentation for this class was generated from the following files:
Generated on Fri May 5 17:17:20 2006 for The Simons Component Library by doxygen1.3