thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Pointer
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
17
namespace
ThePEG
{
18
namespace
Pointer {
19
30
class
ReferenceCounted
{
31
33
friend
class
RCPtrBase
;
34
friend
class
ThePEG::PersistentIStream
;
35
36
public
:
37
41
typedef
unsigned
int
CounterType
;
42
43
protected
:
44
50
ReferenceCounted
()
51
:
uniqueId
(++
objectCounter
),
52
theReferenceCounter
(
CounterType
(1)) {}
53
57
ReferenceCounted
(
const
ReferenceCounted
&)
58
:
uniqueId
(++
objectCounter
),
59
theReferenceCounter
(
CounterType
(1)) {}
60
64
ReferenceCounted
&
operator=
(
const
ReferenceCounted
&)
65
{
66
return
*
this
;
67
}
68
70
71
public
:
72
76
CounterType
referenceCount
()
const
77
{
78
return
theReferenceCounter
;
79
}
80
81
private
:
82
86
void
incrementReferenceCount
()
const
87
{
88
++
theReferenceCounter
;
89
}
90
94
bool
decrementReferenceCount
()
const
95
{
96
return
!--
theReferenceCounter
;
97
}
98
99
public
:
100
104
const
unsigned
long
uniqueId
;
105
106
private
:
107
112
static
unsigned
long
objectCounter
;
113
117
mutable
CounterType
theReferenceCounter
;
118
119
};
120
121
122
}
123
}
124
125
#endif
/* ThePEG_ReferenceCounted_H */
126
ThePEG::PersistentIStream
PersistentIStream is used to read persistent objects from a stream where they were previously written...
Definition:
PersistentIStream.h:48
ThePEG::Pointer::RCPtrBase
RCPtrBase is the base class of RCPtr and ConstRCPtr which are reference counted (smart) pointers.
Definition:
RCPtr.h:30
ThePEG::Pointer::ReferenceCounted
ReferenceCounted must be the (virtual) base class of all classes which may be pointed to by the RCPtr...
Definition:
ReferenceCounted.h:30
ThePEG::Pointer::ReferenceCounted::operator=
ReferenceCounted & operator=(const ReferenceCounted &)
Assignment.
Definition:
ReferenceCounted.h:64
ThePEG::Pointer::ReferenceCounted::objectCounter
static unsigned long objectCounter
A counter for issuing unique IDs.
Definition:
ReferenceCounted.h:112
ThePEG::Pointer::ReferenceCounted::ReferenceCounted
ReferenceCounted(const ReferenceCounted &)
Copy-constructor.
Definition:
ReferenceCounted.h:57
ThePEG::Pointer::ReferenceCounted::decrementReferenceCount
bool decrementReferenceCount() const
Decrement with the reference count.
Definition:
ReferenceCounted.h:94
ThePEG::Pointer::ReferenceCounted::referenceCount
CounterType referenceCount() const
Return the reference count.
Definition:
ReferenceCounted.h:76
ThePEG::Pointer::ReferenceCounted::CounterType
unsigned int CounterType
The integer type used for counting.
Definition:
ReferenceCounted.h:41
ThePEG::Pointer::ReferenceCounted::uniqueId
const unsigned long uniqueId
The unique ID.
Definition:
ReferenceCounted.h:104
ThePEG::Pointer::ReferenceCounted::ReferenceCounted
ReferenceCounted()
Default constructor.
Definition:
ReferenceCounted.h:50
ThePEG::Pointer::ReferenceCounted::incrementReferenceCount
void incrementReferenceCount() const
Increment the reference count.
Definition:
ReferenceCounted.h:86
ThePEG::Pointer::ReferenceCounted::theReferenceCounter
CounterType theReferenceCounter
The reference count.
Definition:
ReferenceCounted.h:117
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6