BoxHandle Class Template Reference

#include <coherence/lang/BoxHandle.hpp>

Inherits TypedHandle< T >.

List of all members.


Detailed Description

template<class T, class B = typename T::BoxedType, bool fStrict = true>
class coherence::lang::BoxHandle< T, B, fStrict >

A TypedHandle implementation which supports auto-boxing.

To support boxing a managed class defines an inner-type named "BoxedType", and includes a public static "create" method which takes that type. The BoxedType defines the type which the BoxHandle can use to create a managed object from. Alternatively the BoxHandle declaration can identify the "BoxedType" via a secondary template parameter.

Managed classes which wish to be auto-boxing may use this handle type when defining their Handle and View definitions. See String as an example.

When used with integral types a natural ambiguity is introduced when setting or comparing a BoxHandle to NULL, as it also an integral type. In such cases one may the is_null(h) and clear_handle(h) helper functions to ensure the correct behavior.

BoxHandle can be configured as strict, or non-strict. In strict mode (the default), derefencing a NULL BoxHandle will result in a NullPointerException. In non-strict mode, dereferencing a BoxHandle will result in the BoxedType's default value being returned.

Author:
mf 2007.07.05

Public Member Functions

 BoxHandle ()
 Create an empty BoxHandle.
 BoxHandle (const B &b)
 Create a new BoxHandle from the supplied BoxedType.
template<class O>
 BoxHandle (const TypedHandle< O > &h)
 Create a new BoxHandle from the TypedHandle with a type conversion.
template<class O>
 BoxHandle (TypedHandle< O > &h)
 Create a new BoxHandle from the TypedHandle with a type conversion.
 BoxHandle (T *o)
 Create a new BoxHandle from the raw pointer.
 BoxHandle (const BoxHandle &h)
 The copy constructor.
 ~BoxHandle ()
 The destructor.
BoxHandleoperator= (const BoxedType &b)
 The "boxing" operator.
 operator BoxedType () const
 The "unboxing" operator.
template<class O>
bool operator== (const TypedHandle< O > &v) const
 The equality operator.
bool operator== (const Object *cpo) const
 The equality operator.
bool operator== (const BoxedType &b) const
 The equality operator.
template<class O>
bool operator!= (const TypedHandle< O > &h) const
 The inequality operator.
bool operator!= (const Object *cpo) const
 The inequality operator.
bool operator!= (const BoxedType &b) const
 The inequality operator.

Member Function Documentation

operator BoxedType (  )  const [inline]

The "unboxing" operator.

Returns:
a copy of the referenced Object


The documentation for this class was generated from the following file: Copyright (c) 2000-2008 Oracle. All rights reserved.