CGEM BOSS
6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
ReferenceCount.h
Go to the documentation of this file.
1
#ifndef DCHAIN_REFERENCECOUNT_H
2
#define DCHAIN_REFERENCECOUNT_H
3
// -*- C++ -*-
4
//
5
// Package: DChain
6
// Module: ReferenceCount
7
//
8
// Description: Base class for classes that need reference counting
9
//
10
// Usage:
11
// ReferenceCount() - default constructor
12
// ~ReferenceCount() - destructor
13
// addLink() - record that another object points to this object
14
// dropLink() - record that an object no longer points to this object
15
//
16
// Author: Simon Patton
17
// Created: Fri May 17 08:01:51 EDT 1996
18
// $Id: ReferenceCount.h,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $
19
//
20
// Revision history
21
//
22
// $Log: ReferenceCount.h,v $
23
// Revision 1.1.1.1 2009/03/03 06:06:56 maqm
24
// first import of DecayChain
25
//
26
// Revision 1.1 2006/01/11 20:28:09 cdj
27
// massive class renaming, addition of [] for selection and unit tests
28
//
29
// Revision 1.4 2004/05/12 20:12:52 ryd
30
// Added missing #include
31
//
32
// Revision 1.3 2004/05/11 02:39:17 ryd
33
// Change reference count to UInt32 and throw exception if count exceeds maximum
34
//
35
// Revision 1.2 2003/05/15 19:56:01 cdj
36
// revamped memory handling so always use a ReferenceHolder to deal with the reference counting
37
//
38
// Revision 1.1.1.1 2000/12/18 22:16:49 cdj
39
// imported DChain
40
//
41
// Revision 1.2 1998/08/21 00:46:09 sjp
42
// removed unnecessary include
43
//
44
// Revision 1.1 1998/08/19 20:56:46 sjp
45
// New heder for reference counting class
46
//
47
// Revision 1.1 1998/08/17 23:59:22 sjp
48
// New file to make libraries standalone
49
//
50
51
// system include files
52
#include <stdint.h>
53
54
// user include files
55
//#include "DecayChain/util/DAException.h"
56
57
// forward declarations
58
namespace
dchain
{
59
60
/*
61
class TooManyReferencesException : public DAException
62
{
63
public:
64
TooManyReferencesException():DAException("Too many references to object in a DChain list.\n check sizes of list that you multiply."){}
65
};
66
*/
67
68
69
class
ReferenceCount
70
{
71
public
:
72
// Constructors and destructor
73
ReferenceCount
();
74
virtual
~ReferenceCount
() {}
75
76
// const member functions
77
void
addLink
()
const
;
78
void
dropLink
()
const
;
79
80
private
:
81
// Constructors and destructor
82
ReferenceCount
(
const
ReferenceCount
& ) ;
// stop default
83
84
// assignment operator(s)
85
const
ReferenceCount
& operator=(
const
ReferenceCount
& ) ;
// stop default
86
87
// data members
88
mutable
uint32_t m_linkCount ;
89
90
};
91
92
// inline function definitions
93
94
//
95
// constructors and destructor
96
//
97
98
inline
ReferenceCount::ReferenceCount
() :
99
m_linkCount( 0 )
100
{
101
}
102
103
//
104
// member functions
105
//
106
107
inline
void
ReferenceCount::addLink
()
const
108
{
109
//if (m_linkCount==0xFFFFFFFF) {
110
// throw TooManyReferencesException();
111
//}
112
++m_linkCount ;
113
}
114
115
inline
void
ReferenceCount::dropLink
()
const
116
{
117
--m_linkCount ;
118
if
( 0 == m_linkCount ) {
119
// It is necessary to throw away the 'const' so that the object
120
// can be deleted
121
delete
const_cast<
ReferenceCount
*
>
(
this
) ;
122
}
123
}
124
}
125
#endif
// DCHAIN_REFERENCECOUNT_H
dchain::ReferenceCount
Definition:
ReferenceCount.h:70
dchain::ReferenceCount::dropLink
void dropLink() const
Definition:
ReferenceCount.h:115
dchain::ReferenceCount::~ReferenceCount
virtual ~ReferenceCount()
Definition:
ReferenceCount.h:74
dchain::ReferenceCount::ReferenceCount
ReferenceCount()
Definition:
ReferenceCount.h:98
dchain::ReferenceCount::addLink
void addLink() const
Definition:
ReferenceCount.h:107
dchain
Definition:
children.h:16
source
Event
DecayChain
DecayChain-00-00-03-slc6tag
DecayChain
Element
ReferenceCount.h
Generated by
1.9.6