![]() |
The Simons
|
#include <Type.h>
Inheritance diagram for Type:
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. |
|
Construct a default Type. This creates a Type whose name is the String "Void".
|
|
Release an unused Type.
|
|
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.
|
|
Clone a shallow copy of this Type.
Reimplemented from Object. |
|
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 }.
|
|
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.
Reimplemented from Object. |
|
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. |
|
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.
|
|
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. |
|
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.
|
|
Notify Type's registry of a new prototype. The prototype Object will be stored opposite its type name in the shared Type registry.
|
|
Type's shared registry of Type names and Objects.
|