reference_counted_object.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_REFERENCE_COUNTED_OBJECT_H
21 #define LIBMESH_REFERENCE_COUNTED_OBJECT_H
22 
23 // Local includes
25 
26 // C++ includes
27 #include <typeinfo>
28 
29 namespace libMesh
30 {
31 
64 template <typename T>
66 {
67 protected:
68 
75  {
76 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
77 
78  increment_constructor_count(typeid(T).name());
79 
80 #endif
81  }
82 
87  : ReferenceCounter(other)
88  {
89 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
90 
91  increment_constructor_count(typeid(T).name());
92 
93 #endif
94  }
95 
100  : ReferenceCounter(std::move(other))
101  {
102 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
103 
104  increment_constructor_count(typeid(T).name());
105 
106 #endif
107  }
108 
117  {
118  return *this;
119  }
120 
121 
122 public:
123 
128  {
129 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
130 
131  increment_destructor_count(typeid(T).name());
132 
133 #endif
134  }
135 };
136 
137 
138 } // namespace libMesh
139 
140 
141 #endif // LIBMESH_REFERENCE_COUNTED_OBJECT_H
std::string name(const ElemQuality q)
Definition: elem_quality.C:42
ReferenceCountedObject(ReferenceCountedObject &&other) noexcept
void increment_constructor_count(const std::string &name)
ReferenceCountedObject & operator=(const ReferenceCountedObject &)
Common base for all objects whose creations/destructions are counted.
ReferenceCountedObject(const ReferenceCountedObject &other)
void increment_destructor_count(const std::string &name)