GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSSourceManager.hh
Go to the documentation of this file.
1 #ifndef GUARD_GGEMS_SOURCES_GGEMSSOURCEMANAGER_HH
2 #define GUARD_GGEMS_SOURCES_GGEMSSOURCEMANAGER_HH
3 
4 // ************************************************************************
5 // * This file is part of GGEMS. *
6 // * *
7 // * GGEMS is free software: you can redistribute it and/or modify *
8 // * it under the terms of the GNU General Public License as published by *
9 // * the Free Software Foundation, either version 3 of the License, or *
10 // * (at your option) any later version. *
11 // * *
12 // * GGEMS is distributed in the hope that it will be useful, *
13 // * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 // * GNU General Public License for more details. *
16 // * *
17 // * You should have received a copy of the GNU General Public License *
18 // * along with GGEMS. If not, see <https://www.gnu.org/licenses/>. *
19 // * *
20 // ************************************************************************
21 
34 #ifdef _MSC_VER
35 #pragma warning(disable: 4251) // Deleting warning exporting STL members!!!
36 #endif
37 
39 
41 
43 
48 class GGEMS_EXPORT GGEMSSourceManager
49 {
50  private:
54  GGEMSSourceManager(void);
55 
59  ~GGEMSSourceManager(void);
60 
61  public:
68  {
69  static GGEMSSourceManager instance;
70  return instance;
71  }
72 
78  GGEMSSourceManager(GGEMSSourceManager const& source_manager) = delete;
79 
85  GGEMSSourceManager& operator=(GGEMSSourceManager const& source_manager) = delete;
86 
92  GGEMSSourceManager(GGEMSSourceManager const&& source_manager) = delete;
93 
99  GGEMSSourceManager& operator=(GGEMSSourceManager const&& source_manager) = delete;
100 
106  void Store(GGEMSSource* source);
107 
112  void PrintInfos(void) const;
113 
119  inline GGsize GetNumberOfSources(void) const {return number_of_sources_;}
120 
128  void Initialize(GGuint const& seed, bool const& is_tracking = false, GGint const& particle_tracking_id = 0) const;
129 
136  inline std::string GetNameOfSource(GGsize const& source_index) const {return sources_[source_index]->GetNameOfSource();}
137 
145  inline GGsize GetNumberOfBatchs(GGsize const& source_index, GGsize const& device_index) const {return sources_[source_index]->GetNumberOfBatchs(device_index);}
146 
155  inline GGsize GetNumberOfParticlesInBatch(GGsize const& source_index, GGsize const& device_index, GGsize const& batch_index) {return sources_[source_index]->GetNumberOfParticlesInBatch(device_index, batch_index);}
156 
162  inline GGEMSParticles* GetParticles(void) const {return particles_;}
163 
169  inline GGEMSPseudoRandomGenerator* GetPseudoRandomGenerator(void) const {return pseudo_random_generator_;}
170 
178  inline void GetPrimaries(GGsize const& source_index, GGsize const& thread_index, GGsize const& number_of_particles) const
179  {
180  particles_->SetNumberOfParticles(thread_index, number_of_particles);
181  sources_[source_index]->GetPrimaries(thread_index, number_of_particles);
182  }
183 
190  bool IsAlive(GGsize const& thread_index) const;
191 
196  void Clean(void);
197 
198  private: // Source infos
203 };
204 
210 extern "C" GGEMS_EXPORT GGEMSSourceManager* get_instance_ggems_source_manager(void);
211 
218 extern "C" GGEMS_EXPORT void initialize_source_manager(GGEMSSourceManager* source_manager, GGuint const seed);
219 
225 extern "C" GGEMS_EXPORT void print_infos_source_manager(GGEMSSourceManager* source_manager);
226 
227 #endif // End of GUARD_GGEMS_SOURCES_GGEMSSOURCEMANAGER
GGEMSSourceManager::GetInstance
static GGEMSSourceManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSSourceManager.hh:67
GGEMSParticles
Class managing the particles in GGEMS.
Definition: GGEMSParticles.hh:48
get_instance_ggems_source_manager
GGEMSSourceManager * get_instance_ggems_source_manager(void)
Get the GGEMSSourceManager pointer for python user.
Definition: GGEMSSourceManager.cc:181
GGEMSSourceManager::sources_
GGEMSSource ** sources_
Definition: GGEMSSourceManager.hh:199
GGEMSSourceManager::GetPrimaries
void GetPrimaries(GGsize const &source_index, GGsize const &thread_index, GGsize const &number_of_particles) const
Generate primary particles for a specific source.
Definition: GGEMSSourceManager.hh:178
GGEMSPseudoRandomGenerator
Class managing the random number in GGEMS.
Definition: GGEMSPseudoRandomGenerator.hh:42
GGEMSSourceManager::GetNumberOfSources
GGsize GetNumberOfSources(void) const
Get the number of sources.
Definition: GGEMSSourceManager.hh:119
GGEMSSourceManager::number_of_sources_
GGsize number_of_sources_
Definition: GGEMSSourceManager.hh:200
GGEMSParticles.hh
Class managing the particles in GGEMS.
GGEMSSource.hh
GGEMS mother class for the source.
initialize_source_manager
void initialize_source_manager(GGEMSSourceManager *source_manager, GGuint const seed)
Initialize source.
Definition: GGEMSSourceManager.cc:190
GGEMSSourceManager::operator=
GGEMSSourceManager & operator=(GGEMSSourceManager const &&source_manager)=delete
Avoid copy of the class by rvalue reference.
GGEMSSourceManager::operator=
GGEMSSourceManager & operator=(GGEMSSourceManager const &source_manager)=delete
Avoid assignement of the class by reference.
GGEMSSourceManager::GetPseudoRandomGenerator
GGEMSPseudoRandomGenerator * GetPseudoRandomGenerator(void) const
method returning the OpenCL stack on pseudo random numbers
Definition: GGEMSSourceManager.hh:169
GGEMSSourceManager::GetNumberOfParticlesInBatch
GGsize GetNumberOfParticlesInBatch(GGsize const &source_index, GGsize const &device_index, GGsize const &batch_index)
method returning the number of particles in a specific batch
Definition: GGEMSSourceManager.hh:155
GGEMSSourceManager::pseudo_random_generator_
GGEMSPseudoRandomGenerator * pseudo_random_generator_
Definition: GGEMSSourceManager.hh:202
GGsize
#define GGsize
Definition: GGEMSTypes.hh:252
GGint
#define GGint
Definition: GGEMSTypes.hh:224
GGEMSSourceManager::GetParticles
GGEMSParticles * GetParticles(void) const
method returning the OpenCL stack on particles
Definition: GGEMSSourceManager.hh:162
print_infos_source_manager
void print_infos_source_manager(GGEMSSourceManager *source_manager)
Print information about source.
Definition: GGEMSSourceManager.cc:199
GGEMSSourceManager::GetNameOfSource
std::string GetNameOfSource(GGsize const &source_index) const
get the name of the source
Definition: GGEMSSourceManager.hh:136
GGEMSSourceManager::particles_
GGEMSParticles * particles_
Definition: GGEMSSourceManager.hh:201
GGEMSSourceManager::GGEMSSourceManager
GGEMSSourceManager(GGEMSSourceManager const &&source_manager)=delete
Avoid copy of the class by rvalue reference.
GGEMSSourceManager::GetNumberOfBatchs
GGsize GetNumberOfBatchs(GGsize const &source_index, GGsize const &device_index) const
method returning the number of particles by batch
Definition: GGEMSSourceManager.hh:145
GGEMSSourceManager
GGEMS class handling the source(s)
Definition: GGEMSSourceManager.hh:49
GGuint
#define GGuint
Definition: GGEMSTypes.hh:231
GGEMSSourceManager::GGEMSSourceManager
GGEMSSourceManager(GGEMSSourceManager const &source_manager)=delete
Avoid copy of the class by reference.
GGEMSSource
GGEMS mother class for the source.
Definition: GGEMSSource.hh:45