/usr/include/simgear/structure/SGReferenced.hxx is in libsimgear-dev 3.4.0-3.
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 | /* -*-c++-*-
*
* Copyright (C) 2005-2006 Mathias Froehlich
*
* This program 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 program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef SGReferenced_HXX
#define SGReferenced_HXX
#include "SGAtomic.hxx"
/// Base class for all reference counted SimGear objects
/// Classes derived from this one are meant to be managed with
/// the SGSharedPtr class.
///
/// For more info see SGSharedPtr. For using weak references see
/// SGWeakReferenced.
class SGReferenced {
public:
SGReferenced(void) : _refcount(0u)
{}
/// Do not copy reference counts. Each new object has it's own counter
SGReferenced(const SGReferenced&) : _refcount(0u)
{}
/// Do not copy reference counts. Each object has it's own counter
SGReferenced& operator=(const SGReferenced&)
{ return *this; }
static unsigned get(const SGReferenced* ref)
{ if (ref) return ++(ref->_refcount); else return 0; }
static unsigned put(const SGReferenced* ref)
{ if (ref) return --(ref->_refcount); else return 0; }
static unsigned count(const SGReferenced* ref)
{ if (ref) return ref->_refcount; else return 0; }
static bool shared(const SGReferenced* ref)
{ if (ref) return 1u < ref->_refcount; else return false; }
private:
mutable SGAtomic _refcount;
};
#endif
|