Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Public Member Functions
Teuchos::Handle< PointerType > Class Template Reference

Generic templated handle class. More...

#include <Teuchos_Handle.hpp>

Inheritance diagram for Teuchos::Handle< PointerType >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Handle ()
 
 Handle (const RCP< PointerType > &smartPtr)
 Construct with an existing RCP.
 Handle (Handleable< PointerType > *rawPtr)
 Construct with a raw pointer to a Handleable.
RCP< PointerType > ptr () const
 Read/write access to the underlying smart pointer.
PointerType * rawPtr () const
 Access to non-const raw pointer.

Detailed Description

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

Generic templated handle class.

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

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

 RCP<Base> r = rcp(new Derived(blahblah));
 Handle<Base> h = r;

and construction from a raw pointer,

 Handle<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 Handleable interface; this is necessary to avoid any implicit conversions from raw pointers to smart pointers.

Note that the first form must be used whenever the object being handled has been allocated on the stack.

Definition at line 122 of file Teuchos_Handle.hpp.


Constructor & Destructor Documentation

template<typename PointerType>
Teuchos::Handle< PointerType >::Handle ( ) [inline]

Definition at line 126 of file Teuchos_Handle.hpp.

template<typename PointerType>
Teuchos::Handle< PointerType >::Handle ( const RCP< PointerType > &  smartPtr) [inline]

Construct with an existing RCP.

Definition at line 129 of file Teuchos_Handle.hpp.

template<typename PointerType>
Teuchos::Handle< PointerType >::Handle ( Handleable< PointerType > *  rawPtr) [inline, explicit]

Construct with a raw pointer to a Handleable.

This will make a call to rcp() internally, thus removing that call from the user interface.

Definition at line 140 of file Teuchos_Handle.hpp.


Member Function Documentation

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

Read/write access to the underlying smart pointer.

Definition at line 148 of file Teuchos_Handle.hpp.

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

Access to non-const raw pointer.

Definition at line 150 of file Teuchos_Handle.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines