KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
object_counter.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Riccardo Rossi
11 //
12 //
13 
14 
15 #if !defined(KRATOS_OBJECT_COUNTER_H_INCLUDED )
16 #define KRATOS_OBJECT_COUNTER_H_INCLUDED
17 
18 
19 
20 // System includes
21 #include <string>
22 #include <iostream>
23 
24 
25 // External includes
26 
27 
28 // Project includes
29 #include "includes/define.h"
30 
31 
32 namespace Kratos
33 {
34 
37 
41 
45 
49 
53 
55 
57 template<class TCountedType>
59 {
60 public:
63 
66 
67  typedef unsigned int SizeType;
68 
72 
73 
77 
78 
82 
83 
87 
88  // return number of existing objects:
89  static SizeType Counter()
90  {
92  }
93 
97 
98 
102 
104  virtual std::string Info() const
105  {
106  return std::string("ObjectCounter");
107  }
108 
110  virtual void PrintInfo(std::ostream& rOStream) const
111  {
112  rOStream << Info();
113  }
114 
116  virtual void PrintData(std::ostream& rOStream) const
117  {
118  rOStream << Counter() << " objects";
119  }
120 
121 
125 
126 
128 
129 protected:
132 
133 
137 
138 
142 
143 
147 
148 
152 
153 
157 
158 
162 
165  {
167  }
168 
171  {
173  }
174 
176  virtual ~ObjectCounter()
177  {
179  }
180 
182 
183 private:
186 
188  static SizeType msCounter;
189 
193 
194 
198 
199 
203 
204 
208 
209 
213 
214 
218 
220  ObjectCounter& operator=(ObjectCounter const& rOther);
221 
223 
224 }; // Class ObjectCounter
225 
227 
230 
231 
235 
236 
238 template<class TCountedType>
239 inline std::istream& operator >> (std::istream& rIStream,
241 
243 template<class TCountedType>
244 inline std::ostream& operator << (std::ostream& rOStream,
245  const ObjectCounter<TCountedType>& rThis)
246 {
247  rThis.PrintInfo(rOStream);
248  rOStream << " : ";
249  rThis.PrintData(rOStream);
250 
251  return rOStream;
252 }
254 
255 // initialize counter with zero
256 template<typename TCountedType>
257 typename ObjectCounter<TCountedType>::SizeType ObjectCounter<TCountedType>::msCounter = 0;
258 
259 } // namespace Kratos.
260 
261 #endif // KRATOS_OBJECT_COUNTER_H_INCLUDED defined
262 
263 
Short class definition.
Definition: object_counter.h:59
ObjectCounter()
Default constructor.
Definition: object_counter.h:164
virtual std::string Info() const
Turn back information as a string.
Definition: object_counter.h:104
static SizeType Counter()
Definition: object_counter.h:89
unsigned int SizeType
Definition: object_counter.h:67
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: object_counter.h:116
virtual ~ObjectCounter()
Destructor.
Definition: object_counter.h:176
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: object_counter.h:110
ObjectCounter(ObjectCounter< TCountedType > const &rOther)
Copy constructor.
Definition: object_counter.h:170
KRATOS_CLASS_POINTER_DEFINITION(ObjectCounter)
Pointer definition of ObjectCounter.
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432