Teuchos::ConstHandle< PointerType > Class Template Reference

Templated handle class with strong const protection. More...

#include <Teuchos_Handle.hpp>

Inheritance diagram for Teuchos::ConstHandle< PointerType >:

Teuchos::Describable Teuchos::LabeledObject Teuchos::Handle< PointerType > List of all members.

Public Member Functions

 ConstHandle (const RCP< const PointerType > &ptr)
 Construct with an existing RCP.
 ConstHandle (const ConstHandleable< PointerType > *ptr)
 Construct with a raw pointer to a ConstHandleable. This will make a call to rcp(), thus removing that call from the user interface.
const RCP< const PointerType > & constPtr () const
 Read-only access to the underlying smart pointer.
const PointerType *const rawPtr ()
 Access to raw pointer.

Protected Member Functions

 ConstHandle ()
 The empty ctor will only be called by Handle ctors.
void setRcp (const RCP< PointerType > &ptr)
 This function is needed in Handle ctors.
RCP< PointerType > nonConstPtr () const
 Protected non-const access to the underlying smart pointer.

Detailed Description

template<typename PointerType>
class Teuchos::ConstHandle< PointerType >

Templated handle class with strong const protection.

In writing derived types, it is usually simplest to use the TEUCHOS_CONST_HANDLE_CTORS macro to generate boilerplate constructor code.

There are two modes of construction: construction from an existing RCP,

 RCP<const Base> r = rcp(new Derived(blahblah));
 ConstHandle<Base> h = r;
and construction from a raw pointer,
 ConstHandle<Base> h = new Derived(blahblah);
The second form makes the code slightly cleaner. Note that to use this second form, it is necessary that Derived implement the ConstHandleable interface; this is necessary to avoid any implicit conversions from just any raw pointer to a smart pointer.

Note that the first form with rcp() must be used whenever the object being handled has been allocated on the stack (using rcp(ptr,false) of course).

Definition at line 66 of file Teuchos_Handle.hpp.


Constructor & Destructor Documentation

template<typename PointerType>
Teuchos::ConstHandle< PointerType >::ConstHandle ( const RCP< const PointerType > &  ptr  )  [inline]

Construct with an existing RCP.

Definition at line 70 of file Teuchos_Handle.hpp.

template<typename PointerType>
Teuchos::ConstHandle< PointerType >::ConstHandle ( const ConstHandleable< PointerType > *  ptr  )  [inline, explicit]

Construct with a raw pointer to a ConstHandleable. This will make a call to rcp(), thus removing that call from the user interface.

Definition at line 73 of file Teuchos_Handle.hpp.

template<typename PointerType>
Teuchos::ConstHandle< PointerType >::ConstHandle (  )  [inline, explicit, protected]

The empty ctor will only be called by Handle ctors.

Definition at line 80 of file Teuchos_Handle.hpp.


Member Function Documentation

template<typename PointerType>
const RCP<const PointerType>& Teuchos::ConstHandle< PointerType >::constPtr (  )  const [inline]

Read-only access to the underlying smart pointer.

Definition at line 75 of file Teuchos_Handle.hpp.

template<typename PointerType>
const PointerType* const Teuchos::ConstHandle< PointerType >::rawPtr (  )  [inline]

Access to raw pointer.

Definition at line 77 of file Teuchos_Handle.hpp.

template<typename PointerType>
void Teuchos::ConstHandle< PointerType >::setRcp ( const RCP< PointerType > &  ptr  )  [inline, protected]

This function is needed in Handle ctors.

The Handle ctors call the empty ConstHandle ctor and then set the pointer in the ConstHandle with a call to setRcp().

Definition at line 85 of file Teuchos_Handle.hpp.

template<typename PointerType>
RCP<PointerType> Teuchos::ConstHandle< PointerType >::nonConstPtr (  )  const [inline, protected]

Protected non-const access to the underlying smart pointer.

This will be called by the nonConstPtr() method of the non-const Handle subclass

Definition at line 91 of file Teuchos_Handle.hpp.


The documentation for this class was generated from the following file:
Generated on Tue Jul 13 09:23:01 2010 for Teuchos - Trilinos Tools Package by  doxygen 1.4.7