Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/handle.hpp"
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. 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 > | |
Handle & | activate (IMP *impl, DEL whenDead) |
Activation of the handle by the managing service. More... | |
Handle & | activate (shared_ptr< IMP > const &impl) |
another way of activating a handle by sharing ownership with an existing smart-ptr | |
Handle & | activate (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 | |
Handle & | operator= (Handle const &r)=default |
Handle & | operator= (Handle &&rr)=default |
template<class Y > | |
Handle & | operator= (shared_ptr< Y > const &sr) |
template<class Y > | |
Handle & | operator= (shared_ptr< Y > &&srr) |
template<class Y > | |
Handle & | operator= (unique_ptr< Y > &&urr) |
Protected Types | |
typedef std::shared_ptr< IMP > | SmPtr |
Protected Member Functions | |
IMP & | impl () const |
Protected Attributes | |
SmPtr | smPtr_ |
|
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().
|
inline |
Activation of the handle by the managing service.
impl | the implementation object this handle is tied to |
whenDead | functor to be invoked when reaching end-of-life |
std::bad_alloc,in | which case whenDead(impl) is invoked |
Definition at line 112 of file handle.hpp.
Referenced by Handle< steam::play::PlayProcess >::activate(), and ProcessImpl::createHandle().
|
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.