NetDEM v1.0
Loading...
Searching...
No Matches
dem_object_pool.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "contact_pp.hpp"
4#include "contact_pw.hpp"
5#include "particle.hpp"
6#include <memory>
7
8namespace netdem {
9
20public:
24 DEMObjectPool(const DEMObjectPool &) = delete;
25
30
37 static DEMObjectPool instance;
38 return instance;
39 }
40
48
56
64
71 ContactPP *Clone(ContactPP const *cnt);
72
79 ContactPW *Clone(ContactPW const *cnt);
80
86 void RecycleParticle(Particle **p);
87
94 void RecycleContactPP(ContactPP **cnt);
95
102 void RecycleContactPW(ContactPW **cnt);
103
111
118 void RecycleContactPP(VecXT<ContactPP *> *cnt_list);
119
126 void RecycleContactPW(VecXT<ContactPW *> *cnt_list);
127
136
141
142private:
146 DEMObjectPool() {}
147
151 VecXT<Particle *> particle_pool;
152
156 VecXT<ContactPP *> contact_pp_pool;
157
161 VecXT<ContactPW *> contact_pw_pool;
162};
163
164} // namespace netdem
A class representing a contact between two particles.
Definition contact_pp.hpp:20
A class representing a contact between a particle and a wall.
Definition contact_pw.hpp:22
A class implementing object pooling for particles and contacts.
Definition dem_object_pool.hpp:19
ContactPW * GetContactPW()
Get a free ContactPW object from the pool, creating a new one if necessary.
Definition dem_object_pool.cpp:25
ContactPP * Clone(ContactPP const *cnt)
Clone a ContactPP object.
Definition dem_object_pool.cpp:30
void RecycleContactPP(ContactPP **cnt)
Recycle a ContactPP object and store it in the pool for later re-use.
Definition dem_object_pool.cpp:43
void RecycleContactPW(ContactPW **cnt)
Recycle a ContactPW object and store it in the pool for later re-use.
Definition dem_object_pool.cpp:48
DEMObjectPool & operator=(const DEMObjectPool &)=delete
Copy assignment operator deleted.
Particle * GetParticle()
Get a free Particle object from the pool, creating a new one if necessary.
Definition dem_object_pool.cpp:7
DEMObjectPool(const DEMObjectPool &)=delete
Copy constructor deleted.
~DEMObjectPool()
Destructor for the DEMObjectPool class.
Definition dem_object_pool.cpp:83
ContactPP * GetContactPP()
Get a free ContactPP object from the pool, creating a new one if necessary.
Definition dem_object_pool.cpp:20
void RecycleParticle(Particle **p)
Recycle a Particle object and store it in the pool for later re-use.
Definition dem_object_pool.cpp:38
static DEMObjectPool & GetInstance()
Get the singleton instance of the DEMObjectPool.
Definition dem_object_pool.hpp:36
Definition particle.hpp:26
Definition bond_entry.hpp:7
std::vector< T > VecXT
Definition utils_macros.hpp:31