reference_counter.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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 // C++ includes
21 #include <iostream>
22 #include <sstream>
23 
24 // Local includes
26 
27 namespace libMesh
28 {
29 
30 
31 
32 // ------------------------------------------------------------
33 // ReferenceCounter class static member initializations
34 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
35 
37 
38 #endif
39 
41 Threads::atomic<unsigned int> ReferenceCounter::_n_objects;
43 
44 
45 // ------------------------------------------------------------
46 // ReferenceCounter class members
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 (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
80 
81 
82 
83 
84 
85 // avoid unused variable warnings
86 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
87 
88 void ReferenceCounter::print_info (std::ostream &out_stream)
89 {
91 }
92 
93 #else
94 
95 void ReferenceCounter::print_info (std::ostream & /* out_stream */)
96 {}
97 
98 #endif
99 
101 {
102  _enable_print_counter = true;
103  return;
104 }
105 
107 {
108  _enable_print_counter = false;
109  return;
110 }
111 
112 } // namespace libMesh

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:07 UTC

Hosted By:
SourceForge.net Logo