X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftags%2F0.4.11%2FETL%2F_ref_count.h;fp=ETL%2Ftags%2F0.4.11%2FETL%2F_ref_count.h;h=0000000000000000000000000000000000000000;hb=3a6643238c67c043fc3592837a05d6d2861967f1;hp=9f05b466a38efd85489c2b75032e74dd65c913ff;hpb=47fce282611fbba1044921d22ca887f9b53ad91a;p=synfig.git diff --git a/ETL/tags/0.4.11/ETL/_ref_count.h b/ETL/tags/0.4.11/ETL/_ref_count.h deleted file mode 100644 index 9f05b46..0000000 --- a/ETL/tags/0.4.11/ETL/_ref_count.h +++ /dev/null @@ -1,158 +0,0 @@ -/*! ======================================================================== -** Extended Template Library -** -** $Id$ -** -** Copyright (c) 2002 Robert B. Quattlebaum Jr. -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** -** === N O T E S =========================================================== -** -** This is an internal header file, included by other ETL headers. -** You should not attempt to use it directly. -** -** ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __ETL_REF_COUNT_H -#define __ETL_REF_COUNT_H - -/* === H E A D E R S ======================================================= */ - -#include "_curve_func.h" -#include - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -_ETL_BEGIN_NAMESPACE - -class weak_reference_counter; - -// ======================================================================== -/*! \class reference_counter _ref_count.h ETL/ref_count -** \brief Reference counter -** \see weak_reference_counter -** \writeme -*/ -class reference_counter -{ - friend class weak_reference_counter; -private: - int* counter_; -public: - - reference_counter(const bool &x=true):counter_(x?new int(1):0) { } - - reference_counter(const reference_counter &x):counter_(x.counter_) - { if(counter_) (*counter_)++; } - - reference_counter(const weak_reference_counter &x); - - ~reference_counter() { detach(); } - - reference_counter& operator=(const reference_counter &rhs) - { - detach(); - counter_=rhs.counter_; - if(counter_) - { - assert(*counter_>0); - (*counter_)++; - } - return *this; - } - - void detach() - { - if(counter_) - { - assert(*counter_>0); - if(!--(*counter_)) - delete counter_; - counter_=0; - } - } - - void reset() - { - detach(); - counter_=new int(1); - } - - int count()const { return counter_?*counter_:0; } - - bool unique()const { return counter_?*counter_==1:0; } - - operator int()const { return count(); } -}; // END of class reference_counter - -// ======================================================================== -/*! \class weak_reference_counter _ref_count.h ETL/ref_count -** \brief Weak Reference counter -** \see reference_counter -** \writeme -*/ -class weak_reference_counter -{ - friend class reference_counter; -private: - int* counter_; -public: - weak_reference_counter():counter_(0) { } - - weak_reference_counter(const weak_reference_counter &x):counter_(x.counter_) { } - - weak_reference_counter(const reference_counter &x):counter_(x.counter_) { } - - ~weak_reference_counter() { } - - weak_reference_counter& operator=(const reference_counter &rhs) - { - counter_=rhs.counter_; - assert(*counter_>0); - return *this; - } - - weak_reference_counter& operator=(const weak_reference_counter &rhs) - { - counter_=rhs.counter_; - assert(*counter_>0); - return *this; - } - - void detach() { counter_=0; } - - int count()const { return counter_?*counter_:0; } - - bool unique()const { return counter_?*counter_==1:0; } - - operator int()const { return count(); } -}; // END of class weak_reference_counter - -inline reference_counter::reference_counter(const weak_reference_counter &x): - counter_(x.counter_) -{ - if(counter_) (*counter_)++; -} - -_ETL_END_NAMESPACE - -/* === E X T E R N S ======================================================= */ - -/* === E N D =============================================================== */ - -#endif