PSCF v1.4.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, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11namespace Util {
12
43 {
44
45 public:
46
51
55 int nRef() const;
56
60 bool hasRefs() const;
61
62 private:
63
65 int nRef_;
66
67 friend class CountedReference;
68
69 };
70
71 // Get the number of associated CountedReferences.
72 inline int ReferenceCounter::nRef() const
73 { return nRef_; }
74
75 // Does this counter have one or more associated CountedReferences?
76 inline bool ReferenceCounter::hasRefs() const
77 { return (nRef_ > 0); }
78
79} // namespace Util
80#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.