PSCF v1.5.0
ReferenceCounter.h
1#ifndef UTIL_REFERENCE_COUNTER_H
2#define UTIL_REFERENCE_COUNTER_H
3
4/*
5* Util Package - C++ Utilities for Scientific Computation
6*
7* Copyright 2010 - 2026, David Morse (morse012@um.edu)
8* Distributed under the terms of the GNU General Public License.
9*/
10
11namespace Util {
12
49 {
50
51 public:
52
57
61 int nRef() const;
62
66 bool hasRefs() const;
67
68 private:
69
71 mutable int nRef_;
72
73 friend class CountedReference;
74
75 };
76
77 // Get the number of associated CountedReferences.
78 inline int ReferenceCounter::nRef() const
79 { return nRef_; }
80
81 // Does this counter have one or more associated CountedReferences?
82 inline bool ReferenceCounter::hasRefs() const
83 { return (nRef_ > 0); }
84
85} // namespace Util
86#endif
bool hasRefs() const
Does this counter have references (is nRef > 0)?
int nRef() const
Get the number of references to a shareable resource.
Utility classes for scientific computation.