ThePEG
1.8.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
Pointer
ReferenceCounted.h
1
// -*- C++ -*-
2
//
3
// ReferenceCounted.h is a part of ThePEG - Toolkit for HEP Event Generation
4
// Copyright (C) 1999-2011 Leif Lonnblad
5
//
6
// ThePEG is licenced under version 2 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
Generated on Sat Jun 16 2012 16:51:05 for ThePEG by
1.8.1.1