/usr/include/ETL/_ref_count.h is in etl-dev 0.04.19-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | /*! ========================================================================
** 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 <cassert>
/* === 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
|