ATLAS Offline Software
Functions
asg_component_factory_scanner.cxx File Reference
#include <AsgTools/AsgComponentFactories.h>
#include <AsgTools/MessageCheckAsgTools.h>
#include <fstream>
Include dependency graph for asg_component_factory_scanner.cxx:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

IMPORTANT: this file is only used in AnalysisBase, in any Athena-based project the corresponding Gaudi mechanism is used instead.

This program scans a component library and provides a map of all the contained components. The files can then be merged in CMake by simply concatenating the files. The component factory system knows how to find and read those files, and can then use them to load the corresponding component library on demand and create components from them. By and large all of this is handled by AtlasCMake and users shouldn't have to call it manually.

The way this works internally is that the program loads the component library and then reports all known component factories as belonging to that component library. Should the library internally link another component library this would report components from both libraries. However, that is generally not allowed in Athena either, so not having a special handler in AnalysisBase ought not to create a problem there either.

Definition in file asg_component_factory_scanner.cxx.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 45 of file asg_component_factory_scanner.cxx.

46 {
47  if (argc != 3)
48  {
49  ATH_MSG_ERROR ("usage: " << argv[0] << " <module path> <output file>");
50  return 1;
51  }
52 
53  const std::string modulePathName = argv[1];
54  const std::string outputFile = argv[2];
55 
56  std::string modulePath, moduleName;
57  {
58  const auto pos = modulePathName.find_last_of ('/');
59  if (pos != std::string::npos)
60  {
61  modulePath = modulePathName.substr (0, pos);
62  moduleName = modulePathName.substr (pos + 1);
63  }
64  else
65  {
66  modulePath = ".";
67  moduleName = modulePathName;
68  }
69  }
70 
71  if (auto types = getLoadedComponentFactoryTypes (); !types.empty())
72  {
73  ANA_MSG_ERROR ("already loaded component factory types:");
74  for (const auto& type : types)
75  ANA_MSG_ERROR (" " << type);
76  return 1;
77  }
78 
79  ATH_MSG_DEBUG ("loading component factory preloader module from " << modulePath << " with name " << moduleName);
80  loadComponentFactoryModule (moduleName, modulePath);
81 
82  std::ofstream outputStream (outputFile);
83  for (auto& type : getLoadedComponentFactoryTypes ())
84  {
85  ANA_MSG_DEBUG ("module loaded type " << type);
86  outputStream << moduleName << " " << type << "\n";
87  }
88 
89  return 0;
90 }
RunGeantinoStepRecordingITk.outputStream
outputStream
Definition: RunGeantinoStepRecordingITk.py:126
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
compareGeometries.outputFile
string outputFile
Definition: compareGeometries.py:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:19
python.root_lsr_rank.types
types
Definition: root_lsr_rank.py:35
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288