Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ProfilerConfig< Category > Class Template Reference

#include <G4Profiler.hh>

Public Types

using type = G4ProfilerBundle< g4tim::user_bundle< Category, G4ProfileType > >
 
using this_type = G4ProfilerConfig< Category >
 
using QueryFunc_t = G4ProfilerFunctors_t< Category, bool >
 
using LabelFunc_t = G4ProfilerFunctors_t< Category, std::string >
 
using ToolFunc_t = std::tuple< std::function< type *(const std::string &)> >
 
using QueryHandler_t = FuncHandler< this_type, QueryFunc_t, bool >
 
using LabelHandler_t = FuncHandler< this_type, LabelFunc_t, std::string >
 
using ToolHandler_t = FuncHandler< this_type, ToolFunc_t, type * >
 

Public Member Functions

 G4ProfilerConfig ()=default
 
template<typename Arg , typename... Args>
 G4ProfilerConfig (Arg, Args...)
 
 ~G4ProfilerConfig ()
 
 G4ProfilerConfig (G4ProfilerConfig &&)=default
 
G4ProfilerConfigoperator= (G4ProfilerConfig &&)=default
 
 G4ProfilerConfig (const G4ProfilerConfig &)=delete
 
G4ProfilerConfigoperator= (const G4ProfilerConfig &)=delete
 
template<typename... Args>
bool operator() (Args...)
 
 operator bool () const
 
template<int Idx>
G4ProfilerConfig< Ct >::template PersistentSettings< Idx > & GetPersistentFallback ()
 
template<int Idx>
G4ProfilerConfig< Ct >::template PersistentSettings< Idx > & GetPersistent ()
 

Static Public Member Functions

template<typename... Args>
static bool Query (Args... _args)
 
template<typename... Args>
static std::string Label (Args... _args)
 
template<typename... Args>
static typeTool (const std::string &)
 
static QueryHandler_t GetQueryFunctor ()
 
static QueryHandler_t GetFallbackQueryFunctor ()
 
static LabelHandler_t GetLabelFunctor ()
 
static LabelHandler_t GetFallbackLabelFunctor ()
 
static ToolHandler_t GetToolFunctor ()
 
static ToolHandler_t GetFallbackToolFunctor ()
 

Static Public Attributes

static constexpr size_t arg_sets
 

Detailed Description

template<size_t Category>
class G4ProfilerConfig< Category >

Definition at line 324 of file G4Profiler.hh.

Member Typedef Documentation

◆ LabelFunc_t

template<size_t Category>
using G4ProfilerConfig< Category >::LabelFunc_t = G4ProfilerFunctors_t<Category, std::string>

Definition at line 334 of file G4Profiler.hh.

◆ LabelHandler_t

template<size_t Category>
using G4ProfilerConfig< Category >::LabelHandler_t = FuncHandler<this_type, LabelFunc_t, std::string>

Definition at line 398 of file G4Profiler.hh.

◆ QueryFunc_t

template<size_t Category>
using G4ProfilerConfig< Category >::QueryFunc_t = G4ProfilerFunctors_t<Category, bool>

Definition at line 333 of file G4Profiler.hh.

◆ QueryHandler_t

template<size_t Category>
using G4ProfilerConfig< Category >::QueryHandler_t = FuncHandler<this_type, QueryFunc_t, bool>

Definition at line 397 of file G4Profiler.hh.

◆ this_type

template<size_t Category>
using G4ProfilerConfig< Category >::this_type = G4ProfilerConfig<Category>

Definition at line 328 of file G4Profiler.hh.

◆ ToolFunc_t

template<size_t Category>
using G4ProfilerConfig< Category >::ToolFunc_t = std::tuple<std::function<type*(const std::string&)> >

Definition at line 335 of file G4Profiler.hh.

◆ ToolHandler_t

template<size_t Category>
using G4ProfilerConfig< Category >::ToolHandler_t = FuncHandler<this_type, ToolFunc_t, type*>

Definition at line 399 of file G4Profiler.hh.

◆ type

template<size_t Category>
using G4ProfilerConfig< Category >::type = G4ProfilerBundle<g4tim::user_bundle<Category, G4ProfileType> >

Definition at line 327 of file G4Profiler.hh.

Constructor & Destructor Documentation

◆ G4ProfilerConfig() [1/4]

template<size_t Category>
G4ProfilerConfig< Category >::G4ProfilerConfig ( )
default

◆ G4ProfilerConfig() [2/4]

template<size_t Cat>
template<typename Arg , typename... Args>
G4ProfilerConfig< Cat >::G4ProfilerConfig ( Arg  _arg,
Args...  _args 
)

Definition at line 446 of file G4Profiler.hh.

447{
448 this->operator()(_arg, _args...);
449}
bool operator()(Args...)
Definition: G4Profiler.hh:455

◆ ~G4ProfilerConfig()

template<size_t Cat>
G4ProfilerConfig< Cat >::~G4ProfilerConfig

Definition at line 406 of file G4Profiler.cc.

407{
408 delete m_bundle;
409}

◆ G4ProfilerConfig() [3/4]

template<size_t Category>
G4ProfilerConfig< Category >::G4ProfilerConfig ( G4ProfilerConfig< Category > &&  )
default

◆ G4ProfilerConfig() [4/4]

template<size_t Category>
G4ProfilerConfig< Category >::G4ProfilerConfig ( const G4ProfilerConfig< Category > &  )
delete

Member Function Documentation

◆ GetFallbackLabelFunctor()

template<size_t Cat>
G4ProfilerConfig< Cat >::LabelHandler_t G4ProfilerConfig< Cat >::GetFallbackLabelFunctor
static

Definition at line 455 of file G4Profiler.cc.

456{
457 return LabelHandler_t{
458 GetPersistentFallback<G4ProfileOp::Label>().m_functor
459 };
460}
FuncHandler< this_type, LabelFunc_t, std::string > LabelHandler_t
Definition: G4Profiler.hh:398

◆ GetFallbackQueryFunctor()

template<size_t Cat>
G4ProfilerConfig< Cat >::QueryHandler_t G4ProfilerConfig< Cat >::GetFallbackQueryFunctor
static

Definition at line 444 of file G4Profiler.cc.

445{
446 return QueryHandler_t{
447 GetPersistentFallback<G4ProfileOp::Query>().m_functor
448 };
449}
FuncHandler< this_type, QueryFunc_t, bool > QueryHandler_t
Definition: G4Profiler.hh:397

◆ GetFallbackToolFunctor()

template<size_t Cat>
G4ProfilerConfig< Cat >::ToolHandler_t G4ProfilerConfig< Cat >::GetFallbackToolFunctor
static

Definition at line 466 of file G4Profiler.cc.

467{
468 return ToolHandler_t{ GetPersistentFallback<G4ProfileOp::Tool>().m_functor };
469}
FuncHandler< this_type, ToolFunc_t, type * > ToolHandler_t
Definition: G4Profiler.hh:399

◆ GetLabelFunctor()

template<size_t Cat>
G4ProfilerConfig< Cat >::LabelHandler_t G4ProfilerConfig< Cat >::GetLabelFunctor
static

Definition at line 425 of file G4Profiler.cc.

426{
427 return LabelHandler_t{ GetPersistent<G4ProfileOp::Label>().m_functor };
428}

◆ GetPersistent()

template<size_t Category>
template<int Idx>
G4ProfilerConfig< Ct >::template PersistentSettings< Idx > & G4ProfilerConfig< Category >::GetPersistent ( )

Definition at line 372 of file G4Profiler.cc.

373{
374 //
375 // The pointers here automatically initialize on the first
376 // invocation on a thread and a reference is returned so they
377 // can be cleanly "leaked" at the application termination. Assignment
378 // is thread-safe and this scheme avoids having to deal with getters
379 // and setters. It is designed such that we can set defaults but
380 // the user can override them at any time.
381 //
382 // the first global instance copies from the fallback rountines, which are
383 // assigned defaults in G4RunManager::ConfigureProfilers() but if the user
384 // assigns new settings before creating G4RunManager, those defaults will
385 // be ignored
386 static PersistentSettings<Idx>* _instance =
387 new PersistentSettings<Idx>(GetPersistentFallback<Idx>());
388 static thread_local PersistentSettings<Idx>* _tlinstance = [=]() {
389 static std::mutex mtx;
390 std::unique_lock<std::mutex> lk(mtx);
391 // If this is the primary thread, just return the global instance from
392 // above. Modifying that instance will result in all threads created later
393 // to inherit those settings
394 static bool _first = true;
395 if(_first) // below uses comma operator to assign to false before return
396 return ((_first = false), _instance);
397 // if not first, make a copy from the primary thread
398 return new PersistentSettings<Idx>(*_instance);
399 }();
400 return *_tlinstance;
401}

◆ GetPersistentFallback()

template<size_t Category>
template<int Idx>
G4ProfilerConfig< Ct >::template PersistentSettings< Idx > & G4ProfilerConfig< Category >::GetPersistentFallback ( )

Definition at line 358 of file G4Profiler.cc.

359{
360 // G4RunManager::ConfigureProfilers() assigns defaults to these lambdas
361 // based on environment variables. The users should (generally) not modify
362 // these.
363 static PersistentSettings<Idx> _instance = PersistentSettings<Idx>{};
364 return _instance;
365}

◆ GetQueryFunctor()

template<size_t Cat>
G4ProfilerConfig< Cat >::QueryHandler_t G4ProfilerConfig< Cat >::GetQueryFunctor
static

Definition at line 416 of file G4Profiler.cc.

417{
418 return QueryHandler_t{ GetPersistent<G4ProfileOp::Query>().m_functor };
419}

◆ GetToolFunctor()

template<size_t Cat>
G4ProfilerConfig< Cat >::ToolHandler_t G4ProfilerConfig< Cat >::GetToolFunctor
static

Definition at line 434 of file G4Profiler.cc.

435{
436 return ToolHandler_t{ GetPersistent<G4ProfileOp::Tool>().m_functor };
437}

◆ Label()

template<size_t Cat>
template<typename... Args>
std::string G4ProfilerConfig< Cat >::Label ( Args...  _args)
static

Definition at line 483 of file G4Profiler.hh.

484{
485 return LabelHandler_t{ GetPersistent<G4ProfileOp::Label>().m_functor }(
486 _args...);
487}

◆ operator bool()

template<size_t Category>
G4ProfilerConfig< Category >::operator bool ( ) const
inline

Definition at line 361 of file G4Profiler.hh.

361{ return (m_bundle != nullptr); }

◆ operator()()

template<size_t Cat>
template<typename... Args>
bool G4ProfilerConfig< Cat >::operator() ( Args...  _args)

Definition at line 455 of file G4Profiler.hh.

456{
457 if(Query(_args...))
458 {
459 m_bundle = Tool(Label(_args...));
460 if(m_bundle)
461 m_bundle->start(_args...);
462 return (m_bundle != nullptr);
463 }
464 return false;
465}
static type * Tool(const std::string &)
Definition: G4Profiler.hh:494
static bool Query(Args... _args)
Definition: G4Profiler.hh:472
static std::string Label(Args... _args)
Definition: G4Profiler.hh:483
void start(Args &&...)
Definition: G4Profiler.hh:266

◆ operator=() [1/2]

template<size_t Category>
G4ProfilerConfig & G4ProfilerConfig< Category >::operator= ( const G4ProfilerConfig< Category > &  )
delete

◆ operator=() [2/2]

template<size_t Category>
G4ProfilerConfig & G4ProfilerConfig< Category >::operator= ( G4ProfilerConfig< Category > &&  )
default

◆ Query()

template<size_t Cat>
template<typename... Args>
bool G4ProfilerConfig< Cat >::Query ( Args...  _args)
static

Definition at line 472 of file G4Profiler.hh.

473{
474 return QueryHandler_t{ GetPersistent<G4ProfileOp::Query>().m_functor }(
475 _args...);
476}

◆ Tool()

template<size_t Cat>
template<typename... Args>
G4ProfilerConfig< Cat >::type * G4ProfilerConfig< Cat >::Tool ( const std::string &  _args)
static

Definition at line 494 of file G4Profiler.hh.

496{
497 return ToolHandler_t{ GetPersistent<G4ProfileOp::Tool>().m_functor }(_args);
498}

Member Data Documentation

◆ arg_sets

template<size_t Category>
constexpr size_t G4ProfilerConfig< Category >::arg_sets
staticconstexpr
Initial value:
=
G4TypeListSize<G4ProfilerArgs_t<Category>>::value

Definition at line 330 of file G4Profiler.hh.


The documentation for this class was generated from the following files: