Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
Teuchos::Handle< PointerType > Class Template Reference

Generic templated handle class. More...

#include <Teuchos_Handle.hpp>

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

Public Member Functions

 Handle ()
 
 Handle (const RCP< PointerType > &smartPtr)
 Construct with an existing RCP. More...
 
 Handle (Handleable< PointerType > *rawPtr)
 Construct with a raw pointer to a Handleable. More...
 
RCP< PointerType > ptr () const
 Read/write access to the underlying smart pointer. More...
 
PointerType * rawPtr () const
 Access to non-const raw pointer. More...
 
- Public Member Functions inherited from Teuchos::ConstHandle< PointerType >
 ConstHandle (const RCP< const PointerType > &ptr)
 Construct with an existing RCP. More...
 
 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. More...
 
const RCP< const PointerType > & constPtr () const
 Read-only access to the underlying smart pointer. More...
 
const PointerType *const rawPtr ()
 Access to raw pointer. More...
 
- Public Member Functions inherited from Teuchos::Describable
virtual std::string description () const
 Return a simple one-line description of this object. More...
 
virtual void describe (FancyOStream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
 Print the object with some verbosity level to a FancyOStream. More...
 
void describe (std::ostream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
 Version of describe() that takes an std::ostream instead of a FancyOStream. More...
 
virtual ~Describable ()
 Destructor (marked virtual for memory safety of derived classes). More...
 
- Public Member Functions inherited from Teuchos::LabeledObject
 LabeledObject ()
 Construct with an empty label. More...
 
virtual ~LabeledObject ()
 
virtual void setObjectLabel (const std::string &objectLabel)
 Set the object label (see LabeledObject). More...
 
virtual std::string getObjectLabel () const
 Get the object label (see LabeledObject). More...
 

Additional Inherited Members

- Static Public Attributes inherited from Teuchos::Describable
static const EVerbosityLevel verbLevel_default = VERB_DEFAULT
 Default value for the verbLevel argument of describe(). More...
 
- Protected Member Functions inherited from Teuchos::ConstHandle< PointerType >
 ConstHandle ()
 The empty ctor will only be called by Handle ctors. More...
 
void setRcp (const RCP< PointerType > &ptr)
 This function is needed in Handle ctors. More...
 
RCP< PointerType > nonConstPtr () const
 Protected non-const access to the underlying smart pointer. More...
 

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 135 of file Teuchos_Handle.hpp.

Constructor & Destructor Documentation

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

Definition at line 139 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 142 of file Teuchos_Handle.hpp.

template<typename PointerType >
Teuchos::Handle< PointerType >::Handle ( Handleable< PointerType > *  rawPtr)
inlineexplicit

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 153 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 161 of file Teuchos_Handle.hpp.

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

Access to non-const raw pointer.

Definition at line 163 of file Teuchos_Handle.hpp.


The documentation for this class was generated from the following file: