CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
Args Class Reference

Public Member Functions

 Args ()
 
std::vector< std::string > arguments () const
 
std::string command () const
 
void defineOption (const std::string &fOption, const std::string &fComment="")
 
void defineParameter (const std::string &fParameter, const std::string &fComment="")
 
std::string getParameter (const std::string &fKey)
 
bool optionIsSet (const std::string &fOption) const
 
void parse (int nArgs, char *fArgs[])
 
void printOptionsHelp () const
 
 ~Args ()
 

Private Attributes

std::vector< std::string > mArgs
 
std::map< std::string, std::string > mComments
 
std::vector< std::string > mOptions
 
std::vector< std::string > mParameters
 
std::map< std::string, std::string > mParsed
 
std::string mProgramName
 

Detailed Description

Definition at line 31 of file hcalPublishConditions.cc.

Constructor & Destructor Documentation

◆ Args()

Args::Args ( )
inline

Definition at line 33 of file hcalPublishConditions.cc.

33 {};

◆ ~Args()

Args::~Args ( )
inline

Definition at line 34 of file hcalPublishConditions.cc.

34 {};

Member Function Documentation

◆ arguments()

std::vector< std::string > Args::arguments ( ) const

Definition at line 181 of file hcalInitDb.cc.

181 {return mArgs;}

References arguments().

Referenced by arguments().

◆ command()

std::string Args::command ( ) const

Definition at line 176 of file hcalInitDb.cc.

176  {
177  int ipos = mProgramName.rfind ('/');
178  return std::string (mProgramName, ipos+1);
179 }

References AlCaHLTBitMon_QueryRunRegistry::string.

◆ defineOption()

void Args::defineOption ( const std::string &  fOption,
const std::string &  fComment = "" 
)

Definition at line 125 of file hcalInitDb.cc.

125  {
126  mOptions.push_back (fOption);
127  mComments [fOption] = fComment;
128 }

References defineOption().

Referenced by defineOption().

◆ defineParameter()

void Args::defineParameter ( const std::string &  fParameter,
const std::string &  fComment = "" 
)

Definition at line 130 of file hcalInitDb.cc.

130  {
131  mParameters.push_back (fParameter);
132  mComments [fParameter] = fComment;
133 }

References defineParameter().

Referenced by defineParameter().

◆ getParameter()

std::string Args::getParameter ( const std::string &  fKey)

Definition at line 187 of file hcalInitDb.cc.

187  {
188  if (optionIsSet (fKey)) return mParsed [fKey];
189  return "";
190 }

References getParameter().

Referenced by getParameter(), and Mixins._Parameterizable::hasParameter().

◆ optionIsSet()

bool Args::optionIsSet ( const std::string &  fOption) const

Definition at line 183 of file hcalInitDb.cc.

183  {
184  return mParsed.find (fOption) != mParsed.end ();
185 }

References optionIsSet().

Referenced by optionIsSet().

◆ parse()

void Args::parse ( int  nArgs,
char *  fArgs[] 
)

Definition at line 135 of file hcalInitDb.cc.

135  {
136  if (nArgs <= 0) return;
137  mProgramName = std::string (fArgs [0]);
138  int iarg = 0;
139  while (++iarg < nArgs) {
140  std::string arg (fArgs [iarg]);
141  if (arg [0] != '-') mArgs.push_back (arg);
142  else {
143  if (std::find (mOptions.begin(), mOptions.end (), arg) != mOptions.end ()) {
144  mParsed [arg] = "";
145  }
146  if (std::find (mParameters.begin(), mParameters.end (), arg) != mParameters.end ()) {
147  if (iarg >= nArgs) {
148  std::cerr << "ERROR: Parameter " << arg << " has no value specified. Ignore parameter." << std::endl;
149  }
150  else {
151  mParsed [arg] = std::string (fArgs [++iarg]);
152  }
153  }
154  }
155  }
156 }

References beam_dqm_sourceclient-live_cfg::cerr, spr::find(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ printOptionsHelp()

void Args::printOptionsHelp ( ) const

Definition at line 158 of file hcalInitDb.cc.

158  {
159  char buffer [1024];
160  std::cout << "Parameters:" << std::endl;
161  for (unsigned i = 0; i < mParameters.size (); i++) {
162  std::map<std::string, std::string>::const_iterator it = mComments.find (mParameters [i]);
163  std::string comment = it != mComments.end () ? it->second : "uncommented";
164  sprintf (buffer, " %-8s <value> : %s", (mParameters [i]).c_str(), comment.c_str());
165  std::cout << buffer << std::endl;
166  }
167  std::cout << "Options:" << std::endl;
168  for (unsigned i = 0; i < mOptions.size (); i++) {
169  std::map<std::string, std::string>::const_iterator it = mComments.find (mOptions [i]);
170  std::string comment = it != mComments.end () ? it->second : "uncommented";
171  sprintf (buffer, " %-8s : %s", (mOptions [i]).c_str(), comment.c_str());
172  std::cout << buffer << std::endl;
173  }
174 }

References edmScanValgrind::buffer, comment, gather_cfg::cout, mps_fire::i, printOptionsHelp(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by printOptionsHelp().

Member Data Documentation

◆ mArgs

std::vector<std::string> Args::mArgs
private

Definition at line 47 of file hcalPublishConditions.cc.

◆ mComments

std::map<std::string, std::string> Args::mComments
private

Definition at line 49 of file hcalPublishConditions.cc.

◆ mOptions

std::vector<std::string> Args::mOptions
private

Definition at line 45 of file hcalPublishConditions.cc.

◆ mParameters

std::vector<std::string> Args::mParameters
private

Definition at line 46 of file hcalPublishConditions.cc.

◆ mParsed

std::map<std::string, std::string> Args::mParsed
private

Definition at line 48 of file hcalPublishConditions.cc.

◆ mProgramName

std::string Args::mProgramName
private

Definition at line 44 of file hcalPublishConditions.cc.

mps_fire.i
i
Definition: mps_fire.py:355
gather_cfg.cout
cout
Definition: gather_cfg.py:144
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
Args::mComments
std::map< std::string, std::string > mComments
Definition: hcalPublishConditions.cc:49
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Args::mProgramName
std::string mProgramName
Definition: hcalPublishConditions.cc:44
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
Args::mParameters
std::vector< std::string > mParameters
Definition: hcalPublishConditions.cc:46
comment
#define comment(par)
Definition: vmac.h:163
Args::mParsed
std::map< std::string, std::string > mParsed
Definition: hcalPublishConditions.cc:48
Args::mOptions
std::vector< std::string > mOptions
Definition: hcalPublishConditions.cc:45
funct::arg
A arg
Definition: Factorize.h:36
Args::mArgs
std::vector< std::string > mArgs
Definition: hcalPublishConditions.cc:47