/usr/include/ThePEG/Pointer/ReferenceCounted.h is in libthepeg-dev 1.8.0-3build1.
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 | // -*- C++ -*-
//
// ReferenceCounted.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef ThePEG_ReferenceCounted_H
#define ThePEG_ReferenceCounted_H
// This is the declaration of the ReferenceCounted class.
#include "RCPtr.fh"
#include "ThePEG/Persistency/PersistentIStream.fh"
namespace ThePEG {
namespace Pointer {
/**
* ReferenceCounted must be the (virtual) base class of all
* classes which may be pointed to by the RCPtr smart
* pointer class. It keeps track of all RCPtr and
* ConstRCPtr pointers which are currently pointing to an
* object.
*
* @see RCPtr
* @see ConstRCPtr
*/
class ReferenceCounted {
/** The RCPtrBase class needs to acces the private parts of ReferenceCounted. */
friend class RCPtrBase;
friend class ThePEG::PersistentIStream;
public:
/**
* The integer type used for counting.
*/
typedef unsigned int CounterType;
protected:
/** @name Standard constructors and assignment. */
//@{
/**
* Default constructor.
*/
ReferenceCounted()
: uniqueId(++objectCounter),
theReferenceCounter(CounterType(1)) {}
/**
* Copy-constructor.
*/
ReferenceCounted(const ReferenceCounted &)
: uniqueId(++objectCounter),
theReferenceCounter(CounterType(1)) {}
/**
* Assignment.
*/
ReferenceCounted & operator=(const ReferenceCounted &)
{
return *this;
}
//@}
public:
/**
* Return the reference count.
*/
CounterType referenceCount() const
{
return theReferenceCounter;
}
private:
/**
* Increment the reference count.
*/
void incrementReferenceCount() const
{
++theReferenceCounter;
}
/**
* Decrement with the reference count.
*/
bool decrementReferenceCount() const
{
return !--theReferenceCounter;
}
public:
/**
* The unique ID. Can be used as sorting criterion, e.g. for set<> and map<>.
*/
const unsigned long uniqueId;
private:
/**
* A counter for issuing unique IDs. It will overflow back to 0 eventually,
* but it is very unlikely that two identical IDs show up in the same event.
*/
static unsigned long objectCounter;
/**
* The reference count.
*/
mutable CounterType theReferenceCounter;
};
}
}
#endif /* ThePEG_ReferenceCounted_H */
|