Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:03

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Author: Jonathan Madsen (May 28th 2020)
0027 //
0028 // class description:
0029 //   This is a class creates a G4RunManager instance. Once can specify an
0030 //   enumerated value to set the default. If "G4RunManagerType::Default"
0031 //   is used,
0032 //
0033 
0034 #ifndef G4RunManagerFactory_hh
0035 #define G4RunManagerFactory_hh 1
0036 
0037 #include "G4MTRunManager.hh"
0038 #include "G4RunManager.hh"
0039 #include "G4TaskRunManager.hh"
0040 #include "G4Types.hh"
0041 #include "G4VUserTaskQueue.hh"
0042 
0043 #include <map>
0044 #include <regex>
0045 #include <set>
0046 #include <string>
0047 
0048 //============================================================================//
0049 
0050 enum class G4RunManagerType : G4int
0051 {
0052   Serial = 0,
0053   SerialOnly = 1,
0054   MT = 2,
0055   MTOnly = 3,
0056   Tasking = 4,
0057   TaskingOnly = 5,
0058   TBB = 6,
0059   TBBOnly = 7,
0060   Default
0061 };
0062 
0063 //============================================================================//
0064 
0065 class G4RunManagerFactory
0066 {
0067   public:
0068     static G4RunManager* CreateRunManager(G4RunManagerType _type = G4RunManagerType::Default,
0069                                           G4VUserTaskQueue* _queue = nullptr,
0070                                           G4bool fail_if_unavail = true, G4int nthreads = 0);
0071 
0072     // provide a version which specifies to fail if unavailable
0073     static G4RunManager* CreateRunManager(G4RunManagerType _type, G4bool fail_if_unavail,
0074                                           G4int nthreads = 0, G4VUserTaskQueue* _queue = nullptr)
0075     {
0076       return CreateRunManager(_type, _queue, fail_if_unavail, nthreads);
0077     }
0078 
0079     static G4RunManager* CreateRunManager(G4RunManagerType _type, G4int nthreads,
0080                                           G4bool fail_if_unavail = true,
0081                                           G4VUserTaskQueue* _queue = nullptr)
0082     {
0083       return CreateRunManager(_type, _queue, fail_if_unavail, nthreads);
0084     }
0085 
0086     // provide string versions of above
0087     template<typename... Args>
0088     static G4RunManager* CreateRunManager(std::string type, Args&&... args)
0089     {
0090       return CreateRunManager(GetType(type), std::forward<Args>(args)...);
0091     }
0092 
0093     static std::string GetDefault();
0094     static std::string GetName(G4RunManagerType);
0095     static G4RunManagerType GetType(const std::string&);
0096     static std::set<std::string> GetOptions();
0097     static G4RunManager* GetMasterRunManager();
0098     static G4MTRunManager* GetMTMasterRunManager();
0099     static G4RunManagerKernel* GetMasterRunManagerKernel();
0100 };
0101 
0102 #endif  // G4TaskRunManagerCreator_h