Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MnRefCountedPointer.h
Go to the documentation of this file.
1// @(#)root/minuit2:$Id$
2// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7 * *
8 **********************************************************************/
9
10#ifndef ROOT_Minuit2_MnRefCountedPointer
11#define ROOT_Minuit2_MnRefCountedPointer
12
13#include "MnReferenceCounter.h"
14
15namespace ROOT {
16
17namespace Minuit2 {
18
19template <class T>
21
22public:
23 // Default constructor needed for use inside array, vector, etc.
24 MnRefCountedPointer() : fPtr(0), fCounter(nullptr) {}
25
27
29 {
31 }
32
34 {
35 /*
36 if(References() == 0) {
37 if(fPtr) delete fPtr;
38 if(fCounter) delete fCounter;
39 }
40 else RemoveReference();
41 */
42 if (References() != 0)
44 }
45
46 bool IsValid() const { return fPtr != 0; }
47
49 {
50 if (this != &other && fPtr != other.fPtr) {
52 fPtr = other.fPtr;
53 fCounter = other.fCounter;
55 }
56 return *this;
57 }
58
60 {
61 if (fPtr != ptr) {
62 fPtr = ptr;
64 }
65 return *this;
66 }
67
68 T *Get() const { return fPtr; }
69
70 T *operator->() const
71 {
72 DoCheck();
73 return fPtr;
74 }
75
76 T &operator*() const
77 {
78 DoCheck();
79 return *fPtr;
80 }
81
82 bool operator==(const T *otherP) const { return fPtr == otherP; }
83
84 bool operator<(const T *otherP) const { return fPtr < otherP; }
85
86 unsigned int References() const { return fCounter->References(); }
87
88 void AddReference() const { fCounter->AddReference(); }
89
91 {
93 if (References() == 0) {
94 delete fPtr;
95 fPtr = 0;
96 delete fCounter;
97 fCounter = nullptr;
98 }
99 }
100
101private:
104
105private:
106 void DoCheck() const { assert(IsValid()); }
107};
108
109} // namespace Minuit2
110
111} // namespace ROOT
112
113#endif // ROOT_Minuit2_MnRefCountedPointer
MnRefCountedPointer & operator=(const MnRefCountedPointer< T > &other)
bool operator==(const T *otherP) const
MnRefCountedPointer & operator=(T *ptr)
bool operator<(const T *otherP) const
MnRefCountedPointer(const MnRefCountedPointer< T > &other)
TPaveText * pt
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...