lib::Handle< IMP > Class Template Reference

#include <handle.hpp>

Inheritance diagram for lib::Handle< IMP >:

Inheritance graph
[legend]
Collaboration diagram for lib::Handle< IMP >:

Collaboration graph
[legend]

List of all members.


Detailed Description

template<class IMP>
class lib::Handle< IMP >

Generic opaque reference counting handle, for accessing a service and managing its lifecycle.

Usually such a handle is created by an service interface and activated by setting up the link to some internal implementation object. This setup can only be done by a friend or derived class, //////////////////////////TODO: that was the intention. Why didn't this work out as expected? while client code is free to copy and store handle objects. Finally, any handle can be closed, thereby decrementing the use count.

Definition at line 70 of file handle.hpp.


Public Member Functions

Handleactivate (shared_ptr< IMP > const &impl)
 another way of activating a handle by sharing ownership with an existing smart-ptr
template<typename DEL>
Handleactivate (IMP *impl, DEL whenDead)
 Activation of the handle by the managing service.
void close ()
 deactivate this handle, so it isn't tied any longer to the associated implementation or service object.
template<class Y>
 Handle (std::auto_ptr< Y > &ar)
template<class Y>
 Handle (weak_ptr< Y > const &wr)
template<class Y>
 Handle (shared_ptr< Y > const &r)
 Handle (Handle const &r)
 Handle ()
 by default create an Null handle.
bool isValid () const
 implicit conversion to bool (BoolCheckable)
template<class Y>
Handleoperator= (std::auto_ptr< Y > &ar)
template<class Y>
Handleoperator= (shared_ptr< Y > const &sr)
Handleoperator= (Handle const &r)

Protected Types

typedef std::tr1::shared_ptr< IMP > SmPtr

Protected Member Functions

IMP & impl () const

Protected Attributes

SmPtr smPtr_

Constructor & Destructor Documentation

template<class IMP>
lib::Handle< IMP >::Handle (  )  [inline]

by default create an Null handle.

Typically this is followed by activating the handle by the managing service.

Definition at line 84 of file handle.hpp.


Member Function Documentation

template<class IMP>
Handle& lib::Handle< IMP >::activate ( shared_ptr< IMP > const &  impl  )  [inline]

another way of activating a handle by sharing ownership with an existing smart-ptr

Definition at line 114 of file handle.hpp.

template<class IMP>
template<typename DEL>
Handle& lib::Handle< IMP >::activate ( IMP *  impl,
DEL  whenDead 
) [inline]

Activation of the handle by the managing service.

Parameters:
impl the implementation object this handle is tied to
whenDead functor to be invoked when reaching end-of-life
Exceptions:
std::bad_alloc,in which case whenDead(impl) is invoked

Definition at line 105 of file handle.hpp.

Referenced by control::Command::activate().

Here is the caller graph for this function:

template<class IMP>
void lib::Handle< IMP >::close (  )  [inline]

deactivate this handle, so it isn't tied any longer to the associated implementation or service object.

When all handles have either been deactivated or went out of scope, the associated implementation reaches end-of-life.

Definition at line 126 of file handle.hpp.

template<class IMP>
bool lib::Handle< IMP >::isValid (  )  const [inline]

implicit conversion to bool (BoolCheckable)

Reimplemented in mobject::MORef< MO >, and mobject::MORef< mobject::session::Binding >.

Definition at line 130 of file handle.hpp.


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

Generated on Sun Aug 1 21:32:58 2010 for Lumiera by  doxygen 1.5.6