UQTk: Uncertainty Quantification Toolkit 3.1.5
Object.h
Go to the documentation of this file.
1/* =====================================================================================
2
3 The UQ Toolkit (UQTk) version 3.1.5
4 Copyright (2024) NTESS
5 https://www.sandia.gov/UQToolkit/
6 https://github.com/sandialabs/UQTk
7
8 Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
9 Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government
10 retains certain rights in this software.
11
12 This file is part of The UQ Toolkit (UQTk)
13
14 UQTk is open source software: you can redistribute it and/or modify
15 it under the terms of BSD 3-Clause License
16
17 UQTk is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 BSD 3 Clause License for more details.
21
22 You should have received a copy of the BSD 3 Clause License
23 along with UQTk. If not, see https://choosealicense.com/licenses/bsd-3-clause/.
24
25 Questions? Contact the UQTk Developers at https://github.com/sandialabs/UQTk/discussions
26 Sandia National Laboratories, Livermore, CA, USA
27===================================================================================== */
28// -*- C++ -*-
29
30#ifndef _base_class_Object_
31#define _base_class_Object_
32
33#include "RefPtr.h"
34
47class Object {
48 template <class T> friend class RefPtr;
49 template <class T> friend class ConstRefPtr;
50public:
52 Object() : refs_(0) {
53 }
54
56 virtual ~Object() {
57 }
58
60 long int reference_count() const {
61 return refs_;
62 }
63
64protected:
67 long int reference_grab() const {
68 return ++refs_;
69 }
70
71 long int reference_release() const {
72 return --refs_;
73 }
74
75private:
76 mutable long int refs_;
77};
78
79#endif //_utility_ref_Object_
Definition Object.h:47
long int reference_count() const
Returns the number of references that are held to this object.
Definition Object.h:60
long int refs_
Definition Object.h:76
long int reference_grab() const
Definition Object.h:67
Object()
Construct a new reference counted object with a zero reference count.
Definition Object.h:52
virtual ~Object()
Destroy this object.
Definition Object.h:56
friend class ConstRefPtr
Definition Object.h:49
long int reference_release() const
Definition Object.h:71
Definition RefPtr.h:46