libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
Public 成员函数 | 静态 Public 成员函数 | Protected 类型 | Protected 成员函数 | 静态 Protected 属性 | 所有成员列表
libMesh::ReferenceCounter类 参考

This is the base class for enabling reference counting. 更多...

#include <reference_counter.h>

类 libMesh::ReferenceCounter 继承关系图:
[图例]

Public 成员函数

 ~ReferenceCounter ()
 Destructor. 更多...
 

静态 Public 成员函数

static std::string get_info ()
 Gets a string containing the reference information. 更多...
 
static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out. 更多...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. 更多...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() 更多...
 
static void disable_print_counter_info ()
 

Protected 类型

typedef std::map< std::string,
std::pair< unsigned int,
unsigned int > > 
Counts
 Data structure to log the information. 更多...
 

Protected 成员函数

 ReferenceCounter ()
 Constructors. 更多...
 
 ReferenceCounter (const ReferenceCounter &)
 
 ReferenceCounter (ReferenceCounter &&other) noexcept
 Move constructor, must be declared noexcept. 更多...
 
void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter. 更多...
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter. 更多...
 

静态 Protected 属性

static Counts _counts
 Actually holds the data. 更多...
 
static Threads::atomic
< unsigned int > 
_n_objects
 The number of objects. 更多...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. 更多...
 
static bool _enable_print_counter = true
 Flag to control whether reference count information is printed when print_info is called. 更多...
 

详细描述

This is the base class for enabling reference counting.

It should not be used by the user, thus it has a private constructor.

作者
Benjamin S. Kirk
日期
2002-2007 Common base for all objects whose creations/destructions are counted.

在文件 reference_counter.h46 行定义.

成员类型定义说明

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protected

Data structure to log the information.

The log is identified by the class name.

在文件 reference_counter.h119 行定义.

构造及析构函数说明

libMesh::ReferenceCounter::ReferenceCounter ( )
inlineprotected

Constructors.

Protected so that you cannot instantiate a ReferenceCounter, only derive from it.

在文件 reference_counter.h150 行定义.

参考 _n_objects.

151 {
152  ++_n_objects;
153 }
static Threads::atomic< unsigned int > _n_objects
The number of objects.
libMesh::ReferenceCounter::ReferenceCounter ( const ReferenceCounter )
inlineprotected

在文件 reference_counter.h157 行定义.

参考 _n_objects.

158 {
159  ++_n_objects;
160 }
static Threads::atomic< unsigned int > _n_objects
The number of objects.
libMesh::ReferenceCounter::ReferenceCounter ( ReferenceCounter &&  other)
inlineprotectednoexcept

Move constructor, must be declared noexcept.

在文件 reference_counter.h164 行定义.

参考 _n_objects.

165 {
166  ++_n_objects;
167 }
static Threads::atomic< unsigned int > _n_objects
The number of objects.
libMesh::ReferenceCounter::~ReferenceCounter ( )
inline

Destructor.

在文件 reference_counter.h171 行定义.

参考 _n_objects.

172 {
173  --_n_objects;
174 }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

成员函数说明

void libMesh::ReferenceCounter::disable_print_counter_info ( )
static

在文件 reference_counter.C100 行定义.

参考 _enable_print_counter.

101 {
102  _enable_print_counter = false;
103  return;
104 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
void libMesh::ReferenceCounter::enable_print_counter_info ( )
static

Methods to enable/disable the reference counter output from print_info()

在文件 reference_counter.C94 行定义.

参考 _enable_print_counter.

95 {
96  _enable_print_counter = true;
97  return;
98 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
std::string libMesh::ReferenceCounter::get_info ( )
static

Gets a string containing the reference information.

在文件 reference_counter.C47 行定义.

参考 _counts.

参考自 print_info().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (const auto & [name, cd] : _counts)
59  oss << "| " << name << " reference count information:\n"
60  << "| Creations: " << cd.first << '\n'
61  << "| Destructions: " << cd.second << '\n';
62 
63  oss << " ---------------------------------------------------------------------------- \n";
64 
65  return oss.str();
66 
67 #else
68 
69  return "";
70 
71 #endif
72 }
static Counts _counts
Actually holds the data.
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectednoexcept

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

在文件 reference_counter.h183 行定义.

参考 libMesh::err.

参考自 libMesh::ReferenceCountedObject< SparseMatrix< T > >::ReferenceCountedObject().

184 {
185  libmesh_try
186  {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189  p.first++;
190  }
191  libmesh_catch (...)
192  {
193  auto stream = libMesh::err.get();
194  stream->exceptions(stream->goodbit); // stream must not throw
195  libMesh::err << "Encountered unrecoverable error while calling "
196  << "ReferenceCounter::increment_constructor_count() "
197  << "for a(n) " << name << " object." << std::endl;
198  std::terminate();
199  }
200 }
OStreamProxy err
static Counts _counts
Actually holds the data.
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectednoexcept

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

在文件 reference_counter.h207 行定义.

参考 libMesh::err.

参考自 libMesh::ReferenceCountedObject< SparseMatrix< T > >::~ReferenceCountedObject().

208 {
209  libmesh_try
210  {
211  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
212  std::pair<unsigned int, unsigned int> & p = _counts[name];
213  p.second++;
214  }
215  libmesh_catch (...)
216  {
217  auto stream = libMesh::err.get();
218  stream->exceptions(stream->goodbit); // stream must not throw
219  libMesh::err << "Encountered unrecoverable error while calling "
220  << "ReferenceCounter::increment_destructor_count() "
221  << "for a(n) " << name << " object." << std::endl;
222  std::terminate();
223  }
224 }
OStreamProxy err
static Counts _counts
Actually holds the data.
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestatic

Prints the number of outstanding (created, but not yet destroyed) objects.

在文件 reference_counter.h85 行定义.

参考 _n_objects.

参考自 libMesh::LibMeshInit::~LibMeshInit().

86  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.
void libMesh::ReferenceCounter::print_info ( std::ostream &  out_stream = libMesh::out)
static

Prints the reference information, by default to libMesh::out.

在文件 reference_counter.C81 行定义.

参考 _enable_print_counter , 以及 get_info().

参考自 libMesh::LibMeshInit::~LibMeshInit().

82 {
84  out_stream << ReferenceCounter::get_info();
85 }
static std::string get_info()
Gets a string containing the reference information.
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

类成员变量说明

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotected

Actually holds the data.

在文件 reference_counter.h124 行定义.

参考自 get_info().

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotected

Flag to control whether reference count information is printed when print_info is called.

在文件 reference_counter.h143 行定义.

参考自 disable_print_counter_info(), enable_print_counter_info() , 以及 print_info().

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotected

Mutual exclusion object to enable thread-safe reference counting.

在文件 reference_counter.h137 行定义.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotected

The number of objects.

Print the reference count information when the number returns to 0.

在文件 reference_counter.h132 行定义.

参考自 n_objects(), ReferenceCounter() , 以及 ~ReferenceCounter().


该类的文档由以下文件生成: