DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4Handle.h
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 #ifndef DD4HEP_DDG4_GEANT4SETUP_H
16 #define DD4HEP_DDG4_GEANT4SETUP_H
17 
18 // Framework include files
20 #include "DD4hep/LCDD.h"
21 
22 // C/C++ include files
23 #include <string>
24 #include <memory>
25 
27 namespace DD4hep {
28 
30  namespace Simulation {
31 
33  class Geant4Kernel;
34  class Geant4Action;
35 
37 
42  template <typename TYPE> class Geant4Handle {
43  protected:
44  void checked_assign(TYPE* p);
45  public:
46  typedef TYPE handled_type;
48  mutable handled_type* value;
50  explicit Geant4Handle();
54  template <typename T> Geant4Handle(T* typ) : value(0) {
55  checked_assign(dynamic_cast<handled_type*>(typ));
56  }
60  Geant4Handle(Geant4Kernel&, const char* type_name, bool shared=false);
62  Geant4Handle(Geant4Kernel&, const std::string& type_name, bool shared=false);
64  Geant4Handle(Geant4Kernel& ctxt, const std::string& type_name, const std::string& detector, bool shared=false);
66  ~Geant4Handle();
68  Property& operator[](const std::string& property_name) const;
74  bool operator!() const;
76  Geant4Action* action() const;
78  handled_type* operator->() const;
80  operator handled_type*() const;
82  handled_type* get() const;
85  };
86 
88 
93  class KernelHandle {
94  public:
97  mutable handled_type* value;
99  explicit KernelHandle();
101  explicit KernelHandle(Geant4Kernel* k);
107  operator handled_type*() const { return value; }
109  handled_type* get() const { return value; }
111  handled_type* operator->() const { return value; }
115  void destroy();
116  };
117 
118  } // End namespace Simulation
119 } // End namespace DD4hep
120 
121 #endif // DD4HEP_DDG4_GEANT4SETUP_H
handled_type * operator->() const
Access to the underlying object.
Geant4Handle & operator=(const Geant4Handle &handle)
Assignment operator.
~KernelHandle()
Default destructor.
Definition: Geant4Handle.h:105
The property class to assign options to actions.
bool operator!() const
Validity check.
handled_type * value
Pointer to referenced object.
Definition: Geant4Handle.h:97
Geant4Handle(T *typ)
Cross type initialization.
Definition: Geant4Handle.h:54
handled_type * value
Pointer to referenced object.
Definition: Geant4Handle.h:48
Property & operator[](const std::string &property_name) const
Property accessor.
Handle to Geant4 actions with built-in creation mechanism.
Definition: Geant4Config.h:29
KernelHandle(const KernelHandle &k)
Copy constructor.
Definition: Geant4Handle.h:103
handled_type * operator->() const
Access to the underlying object.
Definition: Geant4Handle.h:111
Class, which allows all Geant4Action derivatives to access the DDG4 kernel structures.
Definition: Geant4Kernel.h:43
KernelHandle worker()
Access to worker thread.
Geant4Action * action() const
Access to the underlying object.
handled_type * release()
Release the underlying object.
void destroy()
Destroy referenced object (program termination)
Handle to Geant4 actions with built-in creation mechanism.
Definition: Geant4Handle.h:93
~Geant4Handle()
Default destructor.
void handle(const O *o, const C &c, F pmf)
Geant4Handle()
Default constructor.
KernelHandle()
Default constructor.
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:91