15 using std::ostringstream;
23 const string myname =
"DuneToolManager::fclFilename: ";
24 if ( dbg >= 2 ) cout << myname <<
"Called with " << a_fclname <<
endl;
25 static string fclname;
26 bool haveName = fclname.size();
27 bool setName = a_fclname.size();
28 if ( !haveName && !setName ) {
32 ssftmp <<
"tmpproc" << pid <<
".tmp";
33 string sftmp = ssftmp.str();
35 sscom <<
"ps -fwwp " << pid <<
" >" << sftmp;
36 string scom = sscom.str();
38 ifstream fin(sftmp.c_str());
40 getline(fin, hdrline);
41 string::size_type iposCom = hdrline.find(
"CMD");
43 getline(fin, longline);
44 string line = longline.substr(iposCom);
47 if ( dbg >= 1 ) cout << myname <<
"Taking fcl name from command line: " << line <<
endl;
51 for ( string::size_type ipos=0; ipos<line.size(); ++ipos ) {
65 for (
Index iwrd=0; iwrd<words.size(); ++iwrd ) {
66 string word = words[iwrd];
67 if ( word ==
"-c" || word ==
"--config") {
68 if ( words.size() > iwrd+1 ) fclname = words[iwrd+1];
69 }
else if ( word.substr(0,2) ==
"-c" ) {
70 fclname = word.substr(2);
74 if ( fclname.empty() ) {
75 cout << myname <<
"ERROR: unable to retrieve configuration file name from command line." <<
endl;
76 fclname =
"tools_dune.fcl";
78 }
else if ( !haveName && setName ) {
80 }
else if ( haveName && setName ) {
81 if ( a_fclname != fclname ) {
82 cout << myname <<
"WARNING: Ignoring inconsistent configuration name: " 83 << a_fclname <<
" != " << fclname <<
endl;
86 if ( fclname.empty() ) {
87 cout << myname <<
"ERROR: Unexpected empty file name!" <<
endl;
88 fclname =
"nosuchfile.fcl";
96 const string myname =
"DuneToolManager::instance: ";
97 if ( dbg >= 2 ) cout << myname <<
"Called with " << a_fclname <<
endl;
98 static std::unique_ptr<DuneToolManager> pins;
107 cout <<
"DuneToolManager provides access to named tools." <<
endl;
108 cout <<
"It is typically accessed a singleton, e.g." <<
endl;
109 cout <<
" DuneToolManager* ptm = DuneToolManger::instance();" <<
endl;
110 cout <<
"The name of the fcl file defining the tools may be provided as an argument." <<
endl;
112 cout <<
"Available tools may be listed with:" <<
endl;
113 cout <<
" ptm->print() // Displays the names of available tools." <<
endl;
114 cout <<
" ptm->toolNames() // Returns a vector of the tool names." <<
endl;
116 cout <<
"A private instance of a tool with type MyTool may be otained with:" <<
endl;
117 cout <<
" ptm->getPrivate<MyTool>(\"tnam\")" <<
endl;
118 cout <<
"The tool configuration is taken from the fcl block tools.tnam." <<
endl;
119 cout <<
"A unique pointer is returned so the tool instance is destroyed with that pointer." <<
endl;
121 cout <<
"A shared instance of a tool may be obtained with:" <<
endl;
122 cout <<
" ptm->getShared<MyTool>(\"tnam\")" <<
endl;
123 cout <<
"A bare pointer is returned and subsequent callers receive the same pointer." <<
endl;
124 cout <<
"The tool manager deletes all shared tools when it is destroyed." <<
endl;
126 cout <<
"In either case, tool instances are created only when they are obtained." <<
endl;
136 get<fhicl::ParameterSet>(
"tools");
168 if ( scfgin.size() < 1 )
return 1;
170 if ( scfgin[0] ==
'{' ) {
171 if ( scfgin[scfgin.size()-1] !=
'}' )
return 2;
172 scfg = scfgin.substr(1, scfgin.size()-2);
static ParameterSet make(intermediate_table const &tbl)
std::vector< std::string > get_pset_names() const
static constexpr double ps
intermediate_table parse_document(std::string const &filename, cet::filepath_maker &maker)
void line(double t, double *p, double &x, double &y, double &z)
union ptb::content::word::word word
QTextStream & endl(QTextStream &s)