Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

rel::OpaqueValue Class Reference

#include <SmartPtr.h>

Inheritance diagram for rel::OpaqueValue:

Inheritance graph
Collaboration diagram for rel::OpaqueValue:

Collaboration graph
List of all members.

Public Types

enum  DestructorFlag { No_Destructor }

Public Methods

 OpaqueValue ()
 OpaqueValue (const OpaqueValue &value)
 OpaqueValue (OpaqueValueData *value)
 ~OpaqueValue ()
const std::type_info & type () const
bool interpret (const std::type_info &attemptedResultType, const OpaqueValue *args, OpaqueValue *output)
OpaqueValue & operator= (const OpaqueValue &src)
void * get () const
bool checkType (const std::type_info &dst)
void assertType (const std::type_info &dst)
void assertNotNull (const void *value) const
void reset (OpaqueValueData *value=NULL)

Detailed Description

Wrapper around a smart pointer. This can hold any type of object, along with a symbolic type id string which is used internally for error checking.

Due to the type checking string, an OpaqueValue can only be cast to the same type it was stored as. For example, if class B is derived from class A, and an instance of type B is stored, it can not be pulled out as type A.

In order to be able to hold arbitrary type data, this also holds additional data about an object, such as the destruction function.

All of this extra information is transparent to the user. For instance, if we knew a type "int" was stored in a map, we could look it up as follows:

      SmartPtr<int> result = GlobalObjectMap()->find(Path("..."));

The find operation always returns OpaqueData, which can be automatically cast to SmartPtr<Type> - which does type checking along the way. Attempting to cast to the wrong type will lead to an exception. See SmartPtr<> for details.

The documentation for this class was generated from the following files:
Generated at Sat Sep 22 02:20:02 2001 for librel by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001