University of Sheffield   

    The Simons
    Component Library

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

TypeFailure Class Reference

#include <TypeFailure.h>

Inheritance diagram for TypeFailure:

ObjectError Exception Object List of all members.

Detailed Description

TypeFailure: signals when an object is not of the expected type.

Raise a TypeFailure exception if the object stored in an ObjectID reference is not of the expected Type. The most common cause of a TypeFailure is when an object is transferred from a general source variable to a more specific target variable, but is not of a compatible type. Type downcasts using toType() may raise a TypeFailure exception if the dynamic type of the Object stored in the source variable is not compatible with the expected type of the target variable. Methods that retrieve simple values from ObjectID variables may raise a TypeFailure if the variable does not contain a value of the expected type. Client programs may also choose to raise a TypeFailure exception after tentative downcasting with tryType() has failed. TypeFailure provides methods to access the failed object(), the message(), the expectedType() and the actualType(). Typically, a TypeFailure exception is meant to be fatal. However, it may sometimes be handled by creating a default instance of the expected Type and using this instead.


Public Member Functions

 TypeFailure ()
 Construct a default TypeFailure.

virtual ~TypeFailure ()
 Release an TypeFailure.

 TypeFailure (ObjectID, TypeID)
 Construct a TypeFailure exception, with the expected Type.

 TypeFailure (ObjectID, ObjectID)
 Construct a TypeFailure exception, with an exemplar Object.

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

TypeID actualType () const
 Access the actual type of the failed Object.


Protected Member Functions

 TypeFailure (const TypeFailure &)
 Copy another TypeFailure.


Constructor & Destructor Documentation

TypeFailure::TypeFailure const TypeFailure &  exception  )  [protected]
 

Copy another TypeFailure.

Required by C++ to ensure that copying an TypeFailure faithfully copies an ObjectError.

Parameters:
exception - the TypeFailure to copy.
Returns:
an TypeFailure, a shallow copy.

TypeFailure::TypeFailure  ) 
 

Construct a default TypeFailure.

Returns:
an TypeFailure

TypeFailure::~TypeFailure  )  [virtual]
 

Release an TypeFailure.

TypeFailure::TypeFailure ObjectID  object,
TypeID  type
 

Construct a TypeFailure exception, with the expected Type.

Used by methods that unpack simple values from Objects, if the source and target types do not match. May also be raised explicitly by client programs. Sets the expected Type. Recovery is not guaranteed; and depends on which default objects are currently registered with Type.

Parameters:
object - the Object whose type was being converted.
type - the Type expected after type conversion.
Returns:
a TypeFailure exception.

TypeFailure::TypeFailure ObjectID  object,
ObjectID  exemplar
 

Construct a TypeFailure exception, with an exemplar Object.

Raised automatically whenever an attempt is made to perform a type conversion to an incompatible type. Used by toType() when the dynamic type of the source variable is not compatible with the type of the target variable. May also be raised explicitly by client programs. Sets the expected Type. Recovery may always be attempted, since the exemplar is registered with Type. However, the expected Type may be too general to create useful instances.

Parameters:
object - the Object whose type was being converted.
exemplar - a default instance of the expected Type.
Returns:
a TypeFailure exception.


Member Function Documentation

TypeID TypeFailure::actualType  )  const [inline]
 

Access the actual type of the failed Object.

Returns:
the actual Type.

ObjectID TypeFailure::clone  )  const [virtual]
 

Clone a shallow copy of this TypeFailure.

Returns:
a TypeFailure exception, a shallow copy.

Reimplemented from Exception.


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