Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
Handle< IMP > Class Template Reference

#include "lib/handle.hpp"

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 a suitable hidden 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 63 of file handle.hpp.

Public Member Functions

 Handle ()=default
 by default create an Null handle.
 
 Handle (IMP *imp)
 directly establish handle from an implementation, which typically way just heap allocated beforehand.
 
 Handle (Handle const &r)=default
 
 Handle (Handle &&rr)=default
 
template<class Y >
 Handle (shared_ptr< Y > const &r)
 
template<class Y >
 Handle (shared_ptr< Y > &&srr)
 
template<class Y >
 Handle (weak_ptr< Y > const &wr)
 
template<class Y >
 Handle (unique_ptr< Y > &&urr)
 
Handleoperator= (Handle const &r)=default
 
Handleoperator= (Handle &&rr)=default
 
template<class Y >
Handleoperator= (shared_ptr< Y > const &sr)
 
template<class Y >
Handleoperator= (shared_ptr< Y > &&srr)
 
template<class Y >
Handleoperator= (unique_ptr< Y > &&urr)
 
 operator bool () const
 
bool isValid () const
 
template<typename DEL >
Handleactivate (IMP *impl, DEL whenDead)
 Activation of the handle by the managing service.
 
Handleactivate (shared_ptr< IMP > const &impl)
 another way of activating a handle by sharing ownership with an existing smart-ptr
 
Handleactivate (shared_ptr< IMP > &&impl)
 
void close ()
 deactivate this handle, so it isn't tied any longer to the associated implementation or service object.
 

Protected Types

typedef std::shared_ptr< IMP > SmPtr
 

Protected Member Functions

IMP & impl () const
 

Protected Attributes

SmPtr smPtr_
 

Constructor & Destructor Documentation

◆ Handle() [1/8]

template<class IMP >
Handle ( )
default

by default create an Null handle.

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

◆ Handle() [2/8]

template<class IMP >
Handle ( IMP *  imp)
inlineexplicit

directly establish handle from an implementation, which typically way just heap allocated beforehand.

Definition at line 82 of file handle.hpp.

◆ Handle() [3/8]

template<class IMP >
Handle ( Handle< IMP > const &  r)
default

◆ Handle() [4/8]

template<class IMP >
Handle ( Handle< IMP > &&  rr)
default

◆ Handle() [5/8]

template<class IMP >
template<class Y >
Handle ( shared_ptr< Y > const &  r)
inlineexplicit

Definition at line 88 of file handle.hpp.

◆ Handle() [6/8]

template<class IMP >
template<class Y >
Handle ( shared_ptr< Y > &&  srr)
inlineexplicit

Definition at line 89 of file handle.hpp.

◆ Handle() [7/8]

template<class IMP >
template<class Y >
Handle ( weak_ptr< Y > const &  wr)
inlineexplicit

Definition at line 90 of file handle.hpp.

◆ Handle() [8/8]

template<class IMP >
template<class Y >
Handle ( unique_ptr< Y > &&  urr)
inlineexplicit

Definition at line 91 of file handle.hpp.

Member Typedef Documentation

◆ SmPtr

template<class IMP >
typedef std::shared_ptr<IMP> SmPtr
protected

Definition at line 66 of file handle.hpp.

Member Function Documentation

◆ operator=() [1/5]

template<class IMP >
Handle & operator= ( Handle< IMP > const &  r)
default

◆ operator=() [2/5]

template<class IMP >
Handle & operator= ( Handle< IMP > &&  rr)
default

◆ operator=() [3/5]

template<class IMP >
template<class Y >
Handle & operator= ( shared_ptr< Y > const &  sr)
inline

Definition at line 95 of file handle.hpp.

References Handle< IMP >::smPtr_.

◆ operator=() [4/5]

template<class IMP >
template<class Y >
Handle & operator= ( shared_ptr< Y > &&  srr)
inline

Definition at line 96 of file handle.hpp.

References Handle< IMP >::smPtr_.

◆ operator=() [5/5]

template<class IMP >
template<class Y >
Handle & operator= ( unique_ptr< Y > &&  urr)
inline

Definition at line 97 of file handle.hpp.

References Handle< IMP >::smPtr_.

◆ operator bool()

template<class IMP >
operator bool ( ) const
inlineexplicit

Definition at line 100 of file handle.hpp.

References Handle< IMP >::smPtr_.

◆ isValid()

template<class IMP >
bool isValid ( ) const
inline

Definition at line 101 of file handle.hpp.

References Handle< IMP >::smPtr_.

Referenced by MORef< MO >::isValid().

+ Here is the caller graph for this function:

◆ activate() [1/3]

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

Activation of the handle by the managing service.

Parameters
implthe implementation object this handle is tied to
whenDeadfunctor to be invoked when reaching end-of-life
Exceptions
std::bad_alloc,inwhich case whenDead(impl) is invoked

Definition at line 112 of file handle.hpp.

References Handle< IMP >::impl(), and Handle< IMP >::smPtr_.

Referenced by OutputSlotImplBase::ConnectionManager< CON >::connectOutputSink(), and ProcessTable::establishProcess().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ activate() [2/3]

template<class IMP >
Handle & activate ( shared_ptr< IMP > const &  impl)
inline

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

Definition at line 121 of file handle.hpp.

References Handle< IMP >::impl(), and Handle< IMP >::smPtr_.

+ Here is the call graph for this function:

◆ activate() [3/3]

template<class IMP >
Handle & activate ( shared_ptr< IMP > &&  impl)
inline

Definition at line 128 of file handle.hpp.

References Handle< IMP >::impl(), and Handle< IMP >::smPtr_.

+ Here is the call graph for this function:

◆ close()

template<class IMP >
void 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 140 of file handle.hpp.

References Handle< IMP >::smPtr_.

Referenced by MObjectRef_test::checkComparison(), MObjectRef_test::checkLifecycle(), MObjectRef_test::checkTypeHandling(), SpecialJobFun::SpecialExecutor< FUN >::invokeJobOperation(), and DummyPlayConnection_test::verify_simulatedPlayback().

+ Here is the caller graph for this function:

◆ impl()

template<class IMP >
IMP & impl ( ) const
inlineprotected

Definition at line 149 of file handle.hpp.

References Handle< IMP >::smPtr_.

Referenced by Handle< IMP >::activate(), Handle< IMP >::activate(), and Handle< IMP >::activate().

+ Here is the caller graph for this function:

Member Data Documentation

◆ smPtr_

+ Inheritance diagram for Handle< IMP >:
+ Collaboration diagram for Handle< IMP >:

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