thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
ReferenceCounted.h
1// -*- C++ -*-
2//
3// ReferenceCounted.h is a part of ThePEG - Toolkit for HEP Event Generation
4// Copyright (C) 1999-2019 Leif Lonnblad
5//
6// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8//
9#ifndef ThePEG_ReferenceCounted_H
10#define ThePEG_ReferenceCounted_H
11// This is the declaration of the ReferenceCounted class.
12
13
14#include "RCPtr.fh"
15#include "ThePEG/Persistency/PersistentIStream.fh"
16
17namespace ThePEG {
18namespace Pointer {
19
31
33 friend class RCPtrBase;
34 friend class ThePEG::PersistentIStream;
35
36public:
37
41 typedef unsigned int CounterType;
42
43protected:
44
53
60
65 {
66 return *this;
67 }
68
70
71public:
72
77 {
78 return theReferenceCounter;
79 }
80
81private:
82
87 {
89 }
90
95 {
96 return !--theReferenceCounter;
97 }
98
99public:
100
104 const unsigned long uniqueId;
105
106private:
107
112 static unsigned long objectCounter;
113
118
119};
120
121
122}
123}
124
125#endif /* ThePEG_ReferenceCounted_H */
126
PersistentIStream is used to read persistent objects from a stream where they were previously written...
RCPtrBase is the base class of RCPtr and ConstRCPtr which are reference counted (smart) pointers.
Definition: RCPtr.h:30
ReferenceCounted must be the (virtual) base class of all classes which may be pointed to by the RCPtr...
ReferenceCounted & operator=(const ReferenceCounted &)
Assignment.
static unsigned long objectCounter
A counter for issuing unique IDs.
ReferenceCounted(const ReferenceCounted &)
Copy-constructor.
bool decrementReferenceCount() const
Decrement with the reference count.
CounterType referenceCount() const
Return the reference count.
unsigned int CounterType
The integer type used for counting.
const unsigned long uniqueId
The unique ID.
ReferenceCounted()
Default constructor.
void incrementReferenceCount() const
Increment the reference count.
CounterType theReferenceCounter
The reference count.
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28