Lumiera  0.pre.03
»edit your freedom«
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 72 of file handle.hpp.

Public Member Functions

 Handle ()=default
 by default create an Null handle. More...
 
 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)
 
template<typename DEL >
Handleactivate (IMP *impl, DEL whenDead)
 Activation of the handle by the managing service. More...
 
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. More...
 
bool isValid () const
 
 operator bool () const
 
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)
 

Protected Types

typedef std::shared_ptr< IMP > SmPtr
 

Protected Member Functions

IMP & impl () const
 

Protected Attributes

SmPtr smPtr_
 

Constructor & Destructor Documentation

◆ Handle()

Handle ( )
default

by default create an Null handle.

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

Referenced by Handle< steam::play::PlayProcess >::Handle().

+ Here is the caller graph for this function:

Member Function Documentation

◆ activate()

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 121 of file handle.hpp.

Referenced by Handle< steam::play::PlayProcess >::activate(), and ProcessImpl::createHandle().

+ Here is the caller graph for this function:

◆ close()

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 149 of file handle.hpp.

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

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