Logo ROOT  
Reference Guide
MnReferenceCounter.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_MnReferenceCounter
11#define ROOT_Minuit2_MnReferenceCounter
12
13#include <cassert>
14
15#include "StackAllocator.h"
16
17namespace ROOT {
18
19namespace Minuit2 {
20
21// extern StackAllocator gStackAllocator;
22
24
25public:
27
29
31 {
33 return *this;
34 }
35
36 ~MnReferenceCounter() { assert(fReferences == 0); }
37
38 void *operator new(size_t nbytes) { return StackAllocatorHolder::Get().Allocate(nbytes); }
39
40 void operator delete(void *p, size_t /*nbytes */) { StackAllocatorHolder::Get().Deallocate(p); }
41
42 unsigned int References() const { return fReferences; }
43
44 void AddReference() const { fReferences++; }
45
46 void RemoveReference() const { fReferences--; }
47
48private:
49 mutable unsigned int fReferences;
50};
51
52} // namespace Minuit2
53
54} // namespace ROOT
55
56#endif // ROOT_Minuit2_MnReferenceCounter
winID h TVirtualViewer3D TVirtualGLPainter p
MnReferenceCounter(const MnReferenceCounter &other)
MnReferenceCounter & operator=(const MnReferenceCounter &other)
static StackAllocator & Get()
void * Allocate(size_t nBytes)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.