X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftrunk%2FETL%2F_handle.h;h=9c0b2baba02fe1bae8bf7c325a09b3ab5ac2bcb2;hb=cee5940bae97612105db8b7e1ffcf513f9d9150c;hp=317f6c2bde27807dd1cdcc67a16bd8caf95c72ea;hpb=dee84efa006428fdfbf0e84b66ee94eb23113ad9;p=synfig.git diff --git a/ETL/trunk/ETL/_handle.h b/ETL/trunk/ETL/_handle.h index 317f6c2..9c0b2ba 100644 --- a/ETL/trunk/ETL/_handle.h +++ b/ETL/trunk/ETL/_handle.h @@ -66,7 +66,7 @@ class shared_object { private: mutable int refcount; - + protected: shared_object():refcount(0) { } @@ -75,11 +75,11 @@ protected: #else ~shared_object() { } #endif - -public: + +public: void ref()const { assert(refcount>=0); refcount++; } - + //! Returns \c false if object needs to be deleted bool unref()const { @@ -97,7 +97,7 @@ public: return true; } - + int count()const { return refcount; } }; // END of class shared_object @@ -182,7 +182,7 @@ public: return *this; } */ - + //! Assignment operator handle & operator=(const handle &x) @@ -229,7 +229,7 @@ public: void reset() { detach(); } bool empty()const { return obj==0; } - + //! Creates a new instance of a T object and puts it in the handle. /*! Uses the default constructor */ void spawn() { operator=(handle(new T())); } @@ -327,20 +327,20 @@ private: public: void *front_; void *back_; - + protected: rshared_object():rrefcount(0),front_(0),back_(0) { } - -public: + +public: void rref()const { rrefcount++; } - + void runref()const { assert(rrefcount>0); rrefcount--; } - + int rcount()const { return rrefcount; } }; // END of class rshared_object @@ -372,7 +372,7 @@ public: using handle::get; using handle::operator *; using handle::operator ->; - + /* operator const handle&()const { return *this; } @@ -380,7 +380,7 @@ public: private: using handle::obj; - + rhandle *prev_; rhandle *next_; @@ -398,7 +398,7 @@ private: prev_=next_=0; return; } - + prev_=reinterpret_cast*>(obj->back_); next_=0; prev_->next_=this; @@ -429,7 +429,7 @@ private: else next_->prev_=prev_; } - + public: //! Default constructor - empty handle @@ -457,7 +457,7 @@ public: //! Handle is released on deletion ~rhandle() { detach(); } - + //! Template Assignment operator /*! \note This class may not be necessary, and may be removed ** at some point in the future. @@ -480,7 +480,7 @@ public: return *this; } */ - + //! Assignment operator rhandle & operator=(const rhandle &x) @@ -578,32 +578,32 @@ public: // value_type*& obj(handle::obj); // Required to keep gcc 3.4.2 form barfing assert(obj); assert(x.get()!=obj); - + if(x.get()==obj) return 0; - + rhandle *iter; rhandle *next; - + iter=reinterpret_cast*>(obj->front_); - assert(iter); + assert(iter); next=iter->next_; - + int i=0; #ifndef NDEBUG pointer obj_=obj; #endif - + for(;iter;iter=next,next=iter?iter->next_:0,i++) { - assert(iter->get()==obj_); + assert(iter->get()==obj_); (*iter)=x; } assert(obj==x.get()); - + return i; } @@ -711,7 +711,7 @@ public: //void release() { detach(); } void reset() { detach(); } - + bool empty()const { return obj==0; } handle clone()const { assert(obj); return obj->clone(); } @@ -782,8 +782,8 @@ template template handle handle::cast_reinterpret(const loose_handle &x) { return handle(reinterpret_cast(x.get())); } - - + + template template handle handle::cast_static(const rhandle &x) { return handle(static_cast(x.get())); } @@ -800,8 +800,8 @@ template template handle handle::cast_reinterpret(const rhandle &x) { return handle(reinterpret_cast(x.get())); } - - + + template template handle handle::cast_static(U* x) { return handle(static_cast(x)); }