/usr/include/bobcat/refcount is in libbobcat-dev 3.23.01-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 | #ifndef INCLUDED_BOBCAT_REFCOUNT_
#define INCLUDED_BOBCAT_REFCOUNT_
#include <iostream>
#include <typeinfo>
namespace FBB
{
class RefCount
{
mutable size_t d_refcount;
protected:
RefCount();
RefCount(RefCount const &other); // used by clone()
virtual ~RefCount();
public:
size_t refcount() const;
void release();
template <typename X>
static X *share(X const *x);
template <typename X>
static X &modifying(X **x);
private:
virtual RefCount *clone() const = 0;
};
inline RefCount::RefCount()
:
d_refcount(1)
{}
inline RefCount::RefCount(RefCount const &other) // used by clone()
:
d_refcount(1)
{}
inline size_t RefCount::refcount() const
{
return d_refcount;
}
template <typename X>
X *RefCount::share(X const *x)
{
x->d_refcount++;
return const_cast<X *>(x);
}
template <typename X>
X &RefCount::modifying(X **x)
{
if ((*x)->d_refcount != 1)
{
(*x)->d_refcount--;
*x = dynamic_cast<X *>
(
reinterpret_cast<RefCount *>(*x)->clone()
);
if (!*x)
throw std::bad_cast();
}
return **x;
}
} // FBB
#endif
|