BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
ReferenceHolderBase.h
Go to the documentation of this file.
1#ifndef DCHAIN_REFERENCEHOLDERBASE_H
2#define DCHAIN_REFERENCEHOLDERBASE_H
3// -*- C++ -*-
4//
5// Package: DChain
6// Module: ReferenceHolderBase
7//
8// Description: Base implementation of smart pointer for classes that inherit from ReferenceCount
9//
10// Usage:
11// ReferenceHolderBase() - default constructor
12// ~ReferenceHolderBase() - destructor
13//
14// Author: Simon Patton
15// Created: Fri May 17 08:01:51 EDT 1996
16// $Id: ReferenceHolderBase.h,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $
17//
18// Revision history
19//
20// $Log: ReferenceHolderBase.h,v $
21// Revision 1.1.1.1 2009/03/03 06:06:56 maqm
22// first import of DecayChain
23//
24// Revision 1.1 2006/01/11 20:28:10 cdj
25// massive class renaming, addition of [] for selection and unit tests
26//
27// Revision 1.1 2003/05/15 19:56:02 cdj
28// revamped memory handling so always use a ReferenceHolder to deal with the reference counting
29//
30//
31
32// system include files
33
34// user include files
35
36
37// forward declarations
38namespace dchain {
39template< class TPtr, class TRef>
41{
42 public:
43 // Constructors and destructor
44 ReferenceHolderBase() : m_ref(0) {}
45 ReferenceHolderBase(TPtr iRef) : m_ref(iRef) {
46 if(0 != m_ref) { m_ref->addLink(); } }
48 if (0 != m_ref ) {m_ref->dropLink();}
49 }
50
52 m_ref( iOther.m_ref ) {
53 if(0 != m_ref ) {
54 m_ref->addLink();
55 }
56 }
57
58 // assignment operator(s)
60 if( 0 != iRHS.m_ref ) {
61 iRHS.m_ref->addLink();
62 }
63 if( 0 != m_ref ) {
64 m_ref->dropLink();
65 }
66 m_ref = iRHS.m_ref;
67 return *this;
68 }
69
70 // const member functions
71 TPtr operator->() const {
72 return m_ref;
73 }
74
75 TRef operator*() const {
76 return *m_ref;
77 }
78
79 TPtr pointer() const {
80 return m_ref;
81 }
82
83 private:
84
85 // data members
86 TPtr m_ref;
87
88};
89
90// inline function definitions
91
92//
93// constructors and destructor
94//
95
96//
97// member functions
98//
99
100}
101#endif // DCHAIN_REFERENCEHOLDERBASE_H
ReferenceHolderBase(const ReferenceHolderBase< TPtr, TRef > &iOther)
const ReferenceHolderBase & operator=(const ReferenceHolderBase< TPtr, TRef > &iRHS)