1 #ifndef SIGCXX_HANDLE_H
2 #define SIGCXX_HANDLE_H
3 #include <sigc++/sigc++config.h>
5 #ifdef SIGC_CXX_NAMESPACES
10 // Signiture for Handles
11 template <class Obj,class Scope_>
20 return static_cast<Obj*>(scope_.cache());
24 return static_cast<Obj*>(scope_.cache());
27 bool connected() const
28 {return (scope_.object()!=0);}
34 Obj& operator*() const
36 Obj* operator->() const
41 const Scope_& scope() const
45 {scope_.disconnect(0);}
48 Handle& operator =(Obj* obj)
49 {scope_.set(obj,obj,true); return *this;}
50 Handle& operator =(Obj& obj)
51 {scope_.set(&obj,&obj,false); return *this;}
52 #ifndef SIGC_CXX_TEMPLATE_CCTOR
53 Handle& operator =(const Handle& handle)
56 scope_.set(o,o,false);
60 template <class Obj2,class Scope2>
61 Handle& operator = (const Handle<Obj2,Scope2>& handle)
64 scope_.set(o,o,false);
70 Handle(Obj *obj):scope_() {scope_.set(obj,obj,true);}
71 Handle(Obj &obj):scope_() {scope_.set(&obj,&obj,false);}
72 #ifndef SIGC_CXX_TEMPLATE_CCTOR
73 Handle(const Handle& handle)
77 scope_.set(o,o,false);
80 template <class Obj2,class Scope2>
81 Handle(const Handle<Obj2,Scope2>& handle)
85 scope_.set(o,o,false);
90 #define HANDLE_CTORS(X,T,P) \
92 X(T *t):Handle<T,P>(t) {} \
93 X(T &t):Handle<T,P>(t) {} \
94 template <class T2,class P2> \
95 X(const Handle<T2,P2> &h):Handle<T,P>(h) {} \
97 {return Handle<T,P>::operator=(t);} \
99 {return Handle<T,P>::operator=(t);} \
100 template <class T2,class P2> \
101 X& operator =(const Handle<T2,P2> &t) \
102 {return Handle<T,P>::operator=(t);}
105 // class Ref:public Handle<T,Scopes::RefCount>
107 // HANDLE_CTORS(Ref,T,Scopes::RefCount)
110 #ifdef SIGC_CXX_NAMESPACES