ATLAS Offline Software
AsgComponentFactories.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #ifndef ASG_TOOLS__ASG_COMPONENT_FACTORIES_H
8 #define ASG_TOOLS__ASG_COMPONENT_FACTORIES_H
9 
11 #include <functional>
12 #include <memory>
13 
14 namespace asg
15 {
16  class AsgComponent;
17 
18 #ifdef XAOD_STANDALONE
19 
21  StatusCode registerComponentFactory (const std::string& type, const std::function<std::unique_ptr<AsgComponent>(const std::string& name)>& factory);
22 
24  const std::function<std::unique_ptr<AsgComponent>(const std::string& name)> *getComponentFactory (const std::string& type);
25 
26 
32  template<typename T> StatusCode registerToolFactory (const std::string& type)
33  {
34  return registerComponentFactory (type, [] (const std::string& name) -> std::unique_ptr<AsgComponent> { return std::make_unique<T> (name); });
35  }
36  template<typename T> StatusCode registerServiceFactory (const std::string& type)
37  {
38  return registerComponentFactory (type, [] (const std::string& name) -> std::unique_ptr<AsgComponent> { return std::make_unique<T> (name, nullptr); });
39  }
40  template<typename T> StatusCode registerAlgorithmFactory (const std::string& type)
41  {
42  return registerComponentFactory (type, [] (const std::string& name) -> std::unique_ptr<AsgComponent> { return std::make_unique<T> (name, nullptr); });
43  }
45 
46 #endif
47 }
48 
49 #endif
asg
Definition: DataHandleTestTool.h:28
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
StatusCode.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78