BOSS
8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/DecayChain/include/DecayChain/Element/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
65
list.\n check sizes of list that you multiply."){}
66
};
67
*/
68
69
class
ReferenceCount
{
70
public
:
71
// Constructors and destructor
72
ReferenceCount
();
73
virtual
~ReferenceCount
() {}
74
75
// const member functions
76
void
addLink
()
const
;
77
void
dropLink
()
const
;
78
79
private
:
80
// Constructors and destructor
81
ReferenceCount
(
const
ReferenceCount
& );
// stop default
82
83
// assignment operator(s)
84
const
ReferenceCount
& operator=(
const
ReferenceCount
& );
// stop default
85
86
// data members
87
mutable
uint32_t m_linkCount;
88
};
89
90
// inline function definitions
91
92
//
93
// constructors and destructor
94
//
95
96
inline
ReferenceCount::ReferenceCount
() : m_linkCount( 0 ) {}
97
98
//
99
// member functions
100
//
101
102
inline
void
ReferenceCount::addLink
()
const
{
103
// if (m_linkCount==0xFFFFFFFF) {
104
// throw TooManyReferencesException();
105
// }
106
++m_linkCount;
107
}
108
109
inline
void
ReferenceCount::dropLink
()
const
{
110
--m_linkCount;
111
if
( 0 == m_linkCount )
112
{
113
// It is necessary to throw away the 'const' so that the object
114
// can be deleted
115
delete
const_cast<
ReferenceCount
*
>
( this );
116
}
117
}
118
}
// namespace dchain
119
#endif
// DCHAIN_REFERENCECOUNT_H
dchain::ReferenceCount
Definition
Event/DecayChain/include/DecayChain/Element/ReferenceCount.h:69
dchain::ReferenceCount::dropLink
void dropLink() const
Definition
Event/DecayChain/include/DecayChain/Element/ReferenceCount.h:109
dchain::ReferenceCount::~ReferenceCount
virtual ~ReferenceCount()
Definition
Event/DecayChain/include/DecayChain/Element/ReferenceCount.h:73
dchain::ReferenceCount::ReferenceCount
ReferenceCount()
Definition
Event/DecayChain/include/DecayChain/Element/ReferenceCount.h:96
dchain::ReferenceCount::addLink
void addLink() const
Definition
Event/DecayChain/include/DecayChain/Element/ReferenceCount.h:102
dchain
Definition
Event/DecayChain/include/DecayChain/Element/children.h:16
8.0.0
BOSS_Source
Event
DecayChain
include
DecayChain
Element
ReferenceCount.h
Generated by
1.16.1