Merge commit 'ichthyo/guistart' into merge
This commit is contained in:
commit
d3b6a7a07f
1 changed files with 18 additions and 17 deletions
|
|
@ -68,27 +68,28 @@ namespace lib {
|
||||||
*/
|
*/
|
||||||
template<class IMP>
|
template<class IMP>
|
||||||
class Handle
|
class Handle
|
||||||
: protected std::tr1::shared_ptr<IMP>
|
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
std::tr1::shared_ptr<IMP> smPtr_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef std::tr1::shared_ptr<IMP> SmP;
|
|
||||||
|
|
||||||
/** by default create an Null handle.
|
/** by default create an Null handle.
|
||||||
* Typically this is followed by activating
|
* Typically this is followed by activating
|
||||||
* the handle by the managing service.
|
* the handle by the managing service.
|
||||||
*/
|
*/
|
||||||
Handle ( )
|
Handle ( )
|
||||||
: SmP()
|
: smPtr_()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Handle (Handle const& r) : SmP(r) {}
|
Handle (Handle const& r) : smPtr_(r.smPtr_) { }
|
||||||
template<class Y> Handle (shared_ptr<Y> const& r) : SmP(r) {}
|
template<class Y> Handle (shared_ptr<Y> const& r) : smPtr_(r) { }
|
||||||
template<class Y> explicit Handle (weak_ptr<Y> const& wr) : SmP(wr) {}
|
template<class Y> explicit Handle (weak_ptr<Y> const& wr) : smPtr_(wr) { }
|
||||||
template<class Y> explicit Handle (std::auto_ptr<Y> & ar) : SmP(ar) {}
|
template<class Y> explicit Handle (std::auto_ptr<Y> & ar) : smPtr_(ar) { }
|
||||||
|
|
||||||
Handle& operator= (Handle const& r) { SmP::operator= (r); return *this; }
|
Handle& operator= (Handle const& r) { smPtr_ = r.smPtr_; return *this; }
|
||||||
template<class Y> Handle& operator=(shared_ptr<Y> const& sr) { SmP::operator= (sr); return *this; }
|
template<class Y> Handle& operator=(shared_ptr<Y> const& sr) { smPtr_ = sr; return *this; }
|
||||||
template<class Y> Handle& operator=(std::auto_ptr<Y> & ar) { SmP::operator= (ar); return *this; }
|
template<class Y> Handle& operator=(std::auto_ptr<Y> & ar) { smPtr_ = ar; return *this; }
|
||||||
|
|
||||||
|
|
||||||
/** deactivate this handle, so it isn't tied any longer
|
/** deactivate this handle, so it isn't tied any longer
|
||||||
|
|
@ -97,14 +98,14 @@ namespace lib {
|
||||||
* went out of scope, the associated implementation
|
* went out of scope, the associated implementation
|
||||||
* reaches end-of-life.
|
* reaches end-of-life.
|
||||||
*/
|
*/
|
||||||
void close () { SmP::reset(); }
|
void close () { smPtr_.reset(); }
|
||||||
|
|
||||||
|
|
||||||
typedef IMP* SmP::*__unspecified_bool_type;
|
typedef std::tr1::shared_ptr<IMP> Handle::*__unspecified_bool_type;
|
||||||
|
|
||||||
/** implicit conversion to "bool" */
|
/** implicit conversion to "bool" */
|
||||||
operator __unspecified_bool_type() const { return *this; } // never throws
|
operator __unspecified_bool_type() const { return &Handle::smPtr_; } // never throws
|
||||||
bool operator! () const { return !SmP::get(); } // dito
|
bool operator! () const { return !bool(smPtr_); } // dito
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -119,15 +120,15 @@ namespace lib {
|
||||||
Handle&
|
Handle&
|
||||||
activate (IMP* impl, DEL whenDead)
|
activate (IMP* impl, DEL whenDead)
|
||||||
{
|
{
|
||||||
SmP::reset (impl, whenDead);
|
smPtr_.reset (impl, whenDead);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMP&
|
IMP&
|
||||||
impl()
|
impl()
|
||||||
{
|
{
|
||||||
REQUIRE (SmP::get(), "Lifecycle-Error");
|
REQUIRE (smPtr_.get(), "Lifecycle-Error");
|
||||||
return *(SmP::get());
|
return *(smPtr_.get());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue