ATLAS Offline Software
Args2Container.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef UTILITIES_COLLECTION_ARGS2CONTAINER
6 #define UTILITIES_COLLECTION_ARGS2CONTAINER
7 
8 #include <string>
9 #include <vector>
10 #include <algorithm>
11 #include <map>
14 
15 /***************************************************************
16 
17 Args2Container is a simple extension of a vector of CmdLineArgs2
18 
19 It has a name and a desc. Name is normally the program name.
20 It also adds three utility methods.
21 
22 printHelp(verbose) :
23  - (verbose = false) print out names of ArgQuals
24  for all contained pointers
25  - (verbose = true) print out names _and_ desc of ArgQuals
26  for all contained pointers
27 
28 checkValid() : Loop over pointers and call valid() method
29 
30 evalArgs(argc,argv) : save time/errors by calling evalArgs
31  on the container rather than the individual CmdLineArg2's
32 
33 bool doXML() : whether to write out an xml file with the argv
34  results classified by CmdLineArgs2
35 
36 WIP pieces for XML reading/state recovery
37 -------------------------------------------
38 void useXMLInput(Args2Container::XMLOption)
39 
40 XMLOption actions:
41 
42  OVERRIDE (NI): evalArgs
43  parse XML
44  Pt CLA2 in XML at non-argv
45  APPEND (NI): evalArgs
46  parse XML
47  if CLA2 missing pt it at non-argv
48  FILEONLY: parse XML
49  pt CLA2 in XML at non-argv
50 
51 * Note that the minimum unit is CLA2, e.g. you can't take -src
52 from the command line and -srcconnect from XML for SrcInfo
53 
54 ***************************************************************/
55 
56 #include "CoralBase/MessageStream.h"
57 
58 namespace pool
59 {
60  class Args2Container : public std::vector<CmdLineArgs2*>
61  {
62  public:
63  enum XMLVersion {V1=0,V2,NUM_VERSIONS};
65 
66  Args2Container(const std::string& name="Args2Container",
67  bool doxml = false,
68  coral::MessageStream* log = 0);
69 
70  void init();
71 
72  void printHelp(bool verbose) const;
73  bool checkValid() const;
74 
75  // Pass argv to all cliarg's
76  bool evalArgs(std::vector<std::string>& argv);
77  bool evalArgs( int argc, const char *argv[] );
78 
79  // Pass argv to specified cliarg
80  bool evalArgs(const std::string& cliarg, std::vector<std::string>& argv);
81 
82  bool doXML() const {return m_xml;}
84  m_xmlOpt = a;
85  m_xml=true; // if they're setting it, assume they're using it.
86  }
87 
88  std::stringstream desc;
89 
90  coral::MessageStream &m_log;
91 
92  private:
93 
94  // input xml methods
95  std::vector<std::string> fillCmdLineArgsFromXML(const std::string& file);
96 
97  // output xml methods
98  void writeXMLContent(std::vector<std::string>& argv);
99 
100  std::string m_name;
101  bool m_xml{};
103  XMLVersion m_ver{};
104  CmdLineArgs2 m_a2c_cla2;
105 
106  std::string m_xFileName;
107 
108  std::vector< std::string > m_argv;
109  };
110 
111 }// end pool namespace
112 
113 #endif // UTILITIES_COLLECTION_ARGS2CONTAINER
114 
115 
116 
117 
118 
119 
120 
121 
122 
pool::Args2Container::m_name
std::string m_name
Definition: Args2Container.h:178
pool::Args2Container::FILEONLY
@ FILEONLY
Definition: Args2Container.h:142
pool::Args2Container::V2
@ V2
Definition: Args2Container.h:180
ArgQual.h
pool::Args2Container::desc
std::stringstream desc
Definition: Args2Container.h:166
pool::Args2Container::OVERRIDE
@ OVERRIDE
Definition: Args2Container.h:142
pool
pool namespace
Definition: libname.h:15
pool::Args2Container::checkValid
bool checkValid() const
pool::Args2Container::m_argv
std::vector< std::string > m_argv
Definition: Args2Container.h:186
pool::Args2Container::writeXMLContent
void writeXMLContent(std::vector< std::string > &argv)
pool::Args2Container::evalArgs
bool evalArgs(std::vector< std::string > &argv)
pool::Args2Container::doXML
bool doXML() const
Definition: Args2Container.h:160
pool::Args2Container::m_a2c_cla2
CmdLineArgs2 m_a2c_cla2
Definition: Args2Container.h:182
pool::Args2Container::m_xml
bool m_xml
Definition: Args2Container.h:179
pool::Args2Container::V1
@ V1
Definition: Args2Container.h:180
pool::Args2Container::APPEND
@ APPEND
Definition: Args2Container.h:142
CmdLineArgs2.h
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
pool::Args2Container::fillCmdLineArgsFromXML
std::vector< std::string > fillCmdLineArgsFromXML(const std::string &file)
pool::Args2Container::m_xmlOpt
XMLOption m_xmlOpt
Definition: Args2Container.h:180
pool::Args2Container::printHelp
void printHelp(bool verbose) const
file
TFile * file
Definition: tile_monitor.h:29
pool::Args2Container::XMLOption
XMLOption
Definition: Args2Container.h:142
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
pool::Args2Container::setXMLOption
void setXMLOption(Args2Container::XMLOption a)
Definition: Args2Container.h:161
pool::Args2Container::init
void init()
pool::Args2Container::m_xFileName
std::string m_xFileName
Definition: Args2Container.h:184
pool::Args2Container::NUM_VERSIONS
@ NUM_VERSIONS
Definition: Args2Container.h:180
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
pool::Args2Container::Args2Container
Args2Container(const std::string &name="Args2Container", bool doxml=false, coral::MessageStream *log=0)
pool::Args2Container::XMLVersion
XMLVersion
Definition: Args2Container.h:141
a
TList * a
Definition: liststreamerinfos.cxx:10
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
pool::Args2Container::m_log
coral::MessageStream & m_log
Definition: Args2Container.h:168
pool::Args2Container::m_ver
XMLVersion m_ver
Definition: Args2Container.h:181