30 #ifndef __ETL__HANDLE_H
31 #define __ETL__HANDLE_H
41 #define ETL_SELF_DELETING_SHARED_OBJECT
46 #define assert_cast static_cast
48 #define assert_cast dynamic_cast
55 template <
class T>
class handle;
57 template <
class T>
class rhandle;
70 #ifdef ETL_LOCK_REFCOUNTS
71 mutable etl::mutex mtx;
77 #ifdef ETL_SELF_DELETING_SHARED_OBJECT
84 virtual void ref()
const
86 #ifdef ETL_LOCK_REFCOUNTS
87 etl::mutex::lock lock(mtx);
98 #ifdef ETL_LOCK_REFCOUNTS
99 etl::mutex::lock lock(mtx);
107 #ifdef ETL_SELF_DELETING_SHARED_OBJECT
113 #ifdef ETL_SELF_DELETING_SHARED_OBJECT
126 #ifdef ETL_LOCK_REFCOUNTS
127 etl::mutex::lock lock(mtx);
156 virtual void ref()
const=0;
157 virtual bool unref()
const=0;
159 virtual int count()
const=0;
259 #ifdef ETL_SELF_DELETING_SHARED_OBJECT
263 if(xobj && !xobj->unref())
285 {
return obj?
obj->count():0; }
294 { assert(
obj);
return *
obj; }
298 { assert(
obj);
return obj; }
425 obj->front_=
obj->back_=
this;
443 if(
obj->front_==
obj->back_)
592 return obj?
obj->rcount():0;
600 assert(
obj);
return obj->front_==
obj->back_;
627 for(;iter;iter=next,next=iter?iter->
next_:0,i++)
629 assert(iter->
get()==obj_);
749 {
return obj?
obj->count():0; }
753 { assert(
obj);
return *
obj; }
757 { assert(
obj);
return obj; }
829 template <
class T,
class U>
bool operator<(const handle<T>& lhs,
const handle<U>& rhs) {
return (lhs.get()<rhs.get()); }
830 template <
class T,
class U>
bool operator<(const loose_handle<T>& lhs,
const loose_handle<U>& rhs) {
return (lhs.get()<rhs.get()); }
831 template <
class T,
class U>
bool operator<(const handle<T>& lhs,
const loose_handle<U>& rhs) {
return (lhs.get()<rhs.get()); }
832 template <
class T,
class U>
bool operator<(const loose_handle<T>& lhs,
const handle<U>& rhs) {
return (lhs.get()<rhs.get()); }
833 template <
class T>
bool operator<(const handle<T>& lhs,
const T* rhs) {
return (lhs.get()<rhs); }
834 template <
class T>
bool operator<(const loose_handle<T>& lhs,
const T* rhs) {
return (lhs.get()<rhs); }
835 template <
class T>
bool operator<(const T* lhs,const handle<T>& rhs) {
return (lhs <rhs.get()); }
836 template <
class T>
bool operator<(const T* lhs,const loose_handle<T>& rhs) {
return (lhs <rhs.get()); }