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.
pool_object.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: Pooyan Dadvand
11 //
12 //
13 
14 #if !defined(KRATOS_POOL_OBJECT_H_INCLUDED )
15 #define KRATOS_POOL_OBJECT_H_INCLUDED
16 
17 
18 
19 // System includes
20 #include <string>
21 #include <iostream>
22 
23 
24 // External includes
25 
26 
27 // Project includes
28 #include "includes/define.h"
29 #include "includes/memory_pool.h"
30 
31 
32 namespace Kratos
33 {
36 
39 
43 
47 
51 
55 
57 
59  class PoolObject
60  {
61  public:
64 
67 
71 
74 
76  virtual ~PoolObject() {}
77 
78 
82 
83  void* operator new(std::size_t Size){
84  return MemoryPool::Allocate(Size);
85  }
86 
87  void operator delete(void* pPointerToRelease, std::size_t Size){
88  MemoryPool::Deallocate(pPointerToRelease, Size);
89  }
90 
94 
95 
99 
100 
104 
105 
109 
111  virtual std::string Info() const {
112  return "PoolObject";
113  }
114 
116  virtual void PrintInfo(std::ostream& rOStream) const {
117  rOStream << Info();
118  }
119 
121  virtual void PrintData(std::ostream& rOStream) const {
122 
123  }
124 
125 
129 
130 
132 
133  protected:
136 
137 
141 
142 
146 
147 
151 
152 
156 
157 
161 
162 
166 
167 
169 
170  private:
173 
174 
178 
179 
183 
184 
188 
189 
193 
194 
198 
199 
203 
205  PoolObject& operator=(PoolObject const& rOther);
206 
208  PoolObject(PoolObject const& rOther);
209 
210 
212 
213  }; // Class PoolObject
214 
216 
219 
220 
224 
225 
227  inline std::istream& operator >> (std::istream& rIStream,
228  PoolObject& rThis);
229 
231  inline std::ostream& operator << (std::ostream& rOStream,
232  const PoolObject& rThis)
233  {
234  rThis.PrintInfo(rOStream);
235  rOStream << std::endl;
236  rThis.PrintData(rOStream);
237 
238  return rOStream;
239  }
241 
243 
244 } // namespace Kratos.
245 
246 #endif // KRATOS_POOL_OBJECT_H_INCLUDED defined
static void Deallocate(void *pPointrerToRelease, std::size_t ObjectSizeInBytes)
Definition: memory_pool.h:81
static void * Allocate(std::size_t ObjectSizeInBytes)
Definition: memory_pool.h:77
This redefines the new and delete operators of derived class to be allocated in pool.
Definition: pool_object.h:60
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: pool_object.h:121
virtual ~PoolObject()
Destructor.
Definition: pool_object.h:76
PoolObject()
Default constructor.
Definition: pool_object.h:73
KRATOS_CLASS_POINTER_DEFINITION(PoolObject)
Pointer definition of PoolObject.
virtual std::string Info() const
Turn back information as a string.
Definition: pool_object.h:111
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: pool_object.h:116
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
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