COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Handle< T > Class Template Reference

Safe pointer to an object. This is the supported method for referring to components. More...

#include <Handle.hpp>

Public Member Functions

 Handle ()
 Default constructor, generating a null handle. More...
 
template<typename Y >
 Handle (const boost::shared_ptr< Y > &ptr)
 
template<typename Y >
 Handle (const Handle< Y > &other)
 Construction from another handle. Casting is done as in construction from shared_ptr. More...
 
T * get () const
 Raw pointer to the stored value, or null if there is none. More...
 
Handleswap (Handle &other)
 Swap two handles. More...
 
void reset ()
 Set the handle to null. More...
 
 operator bool () const
 Conversion to bool for null checking. More...
 
template<typename Y >
 operator Handle< Y > () const
 Explicit conversion to other handle type. This ony works for base classes and const/non const. More...
 
bool operator! () const
 
T * operator-> () const
 
T & operator* () const
 
template<typename Y >
bool _internal_less (Handle< Y > const &rhs) const
 Internal compare function, modeled after boost::shared_ptr. More...
 

Private Member Functions

template<typename Y >
void create_from_shared (const boost::shared_ptr< Y > &ptr)
 Helper function for the constructors. More...
 
void create_from_shared (const boost::shared_ptr< T > &ptr)
 Avoid the is_base_of stuff when both types are the same. More...
 
template<typename Y >
void create_from_shared (const boost::true_type, const boost::shared_ptr< Y > &ptr)
 Static dispatch in case T is a base of Y. More...
 
template<typename Y >
void create_from_shared (const boost::false_type, const boost::shared_ptr< Y > &ptr)
 Static dispatch in case T is not a base of Y. More...
 

Private Attributes

boost::weak_ptr< T > m_weak_ptr
 Weak pointer to the original shared pointer for the component. More...
 
T * m_cached_ptr
 Cached pointer after the first dereference. More...
 

Friends

template<class Y >
class Handle
 Needed for private access from the casting constructors. More...
 

Detailed Description

template<typename T>
class cf3::Handle< T >

Safe pointer to an object. This is the supported method for referring to components.

Definition at line 39 of file Handle.hpp.

Constructor & Destructor Documentation

Handle ( )
inline

Default constructor, generating a null handle.

Definition at line 43 of file Handle.hpp.

Handle ( const boost::shared_ptr< Y > &  ptr)
inlineexplicit

Construction from shared_ptr. This constructor may cast the argument:

  • If T is a base class of Y, a static cast is done
  • otherwise, a dynamic cast is done. If this fails, the resulting Handle is null.

Definition at line 49 of file Handle.hpp.

Handle ( const Handle< Y > &  other)
inlineexplicit

Construction from another handle. Casting is done as in construction from shared_ptr.

Definition at line 57 of file Handle.hpp.

Member Function Documentation

bool _internal_less ( Handle< Y > const &  rhs) const
inline

Internal compare function, modeled after boost::shared_ptr.

Definition at line 123 of file Handle.hpp.

void create_from_shared ( const boost::shared_ptr< Y > &  ptr)
inlineprivate

Helper function for the constructors.

Definition at line 131 of file Handle.hpp.

void create_from_shared ( const boost::shared_ptr< T > &  ptr)
inlineprivate

Avoid the is_base_of stuff when both types are the same.

Definition at line 137 of file Handle.hpp.

void create_from_shared ( const boost::true_type  ,
const boost::shared_ptr< Y > &  ptr 
)
inlineprivate

Static dispatch in case T is a base of Y.

Definition at line 145 of file Handle.hpp.

void create_from_shared ( const boost::false_type  ,
const boost::shared_ptr< Y > &  ptr 
)
inlineprivate

Static dispatch in case T is not a base of Y.

Definition at line 153 of file Handle.hpp.

T* get ( ) const
inline

Raw pointer to the stored value, or null if there is none.

Definition at line 65 of file Handle.hpp.

operator bool ( ) const
inline

Conversion to bool for null checking.

Definition at line 88 of file Handle.hpp.

operator Handle< Y > ( ) const
inline

Explicit conversion to other handle type. This ony works for base classes and const/non const.

Definition at line 95 of file Handle.hpp.

bool operator! ( ) const
inline

Definition at line 105 of file Handle.hpp.

T& operator* ( ) const
inline

Definition at line 116 of file Handle.hpp.

T* operator-> ( ) const
inline

Definition at line 110 of file Handle.hpp.

void reset ( )
inline

Set the handle to null.

Definition at line 81 of file Handle.hpp.

Handle& swap ( Handle< T > &  other)
inline

Swap two handles.

Definition at line 74 of file Handle.hpp.

Friends And Related Function Documentation

friend class Handle
friend

Needed for private access from the casting constructors.

Definition at line 166 of file Handle.hpp.

Member Data Documentation

T* m_cached_ptr
mutableprivate

Cached pointer after the first dereference.

Definition at line 163 of file Handle.hpp.

boost::weak_ptr<T> m_weak_ptr
private

Weak pointer to the original shared pointer for the component.

Definition at line 160 of file Handle.hpp.


The documentation for this class was generated from the following file:
Send comments to:
COOLFluiD Web Admin