CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
l1t::Parameter Class Reference

#include <Parameter.h>

Public Member Functions

std::map< std::string, unsigned int > getColumnIndices (void) const noexcept
 
std::string getId (void) const noexcept
 
std::string getProcOrRole (void) const noexcept
 
template<class T >
std::vector< TgetTableColumn (const char *colName) const
 
template<class T >
std::map< std::string, TgetTableRow (unsigned long rowNum) const
 
std::string getType (void) const noexcept
 
template<class T >
T getValue (void) const
 
std::string getValueAsStr (void) const noexcept
 
template<class T >
std::vector< TgetVector (void) const
 
bool isScalar (void) const noexcept
 
bool isTable (void) const noexcept
 
bool isVector (void) const noexcept
 
Parameteroperator= (const Parameter &s)=default
 
Parameteroperator= (Parameter &&s)=default
 
 Parameter (const Parameter &s)=default
 
 Parameter (Parameter &&s)=default
 
 Parameter (const char *id, const char *procOrRole, const char *type, const char *value, const char *delimeter=",")
 
 Parameter (const char *id, const char *procOrRole, const char *types, const char *columns, const std::vector< std::string > &rows, const char *delimeter=",")
 
 Parameter (void)
 
 ~Parameter (void)
 

Private Attributes

std::map< std::string, unsigned int > columnNameToIndex
 
std::string delim
 
std::string id
 
std::string procOrRole
 
std::string scalarOrVector
 
std::map< std::string, std::vector< std::string > > table
 
std::string type
 

Detailed Description

Definition at line 20 of file Parameter.h.

Constructor & Destructor Documentation

l1t::Parameter::Parameter ( const Parameter s)
default
l1t::Parameter::Parameter ( Parameter &&  s)
default
l1t::Parameter::Parameter ( const char *  id,
const char *  procOrRole,
const char *  type,
const char *  value,
const char *  delimeter = "," 
)
l1t::Parameter::Parameter ( const char *  id,
const char *  procOrRole,
const char *  types,
const char *  columns,
const std::vector< std::string > &  rows,
const char *  delimeter = "," 
)
l1t::Parameter::Parameter ( void  )
inline

Definition at line 105 of file Parameter.h.

Referenced by getColumnIndices().

105 {}
l1t::Parameter::~Parameter ( void  )
inline

Member Function Documentation

std::map<std::string,unsigned int> l1t::Parameter::getColumnIndices ( void  ) const
inlinenoexcept

Definition at line 84 of file Parameter.h.

References columnNameToIndex, mps_check::columns, operator=(), Parameter(), tablePrinter::rows, alignCSCRings::s, and cutBasedMuonId_MuonPOG_V0_cff::types.

84 { return columnNameToIndex; }
std::map< std::string, unsigned int > columnNameToIndex
Definition: Parameter.h:25
std::string l1t::Parameter::getId ( void  ) const
inlinenoexcept

Definition at line 28 of file Parameter.h.

References id.

28 { return id; }
std::string id
Definition: Parameter.h:22
std::string l1t::Parameter::getProcOrRole ( void  ) const
inlinenoexcept

Definition at line 29 of file Parameter.h.

References procOrRole.

29 { return procOrRole; }
std::string procOrRole
Definition: Parameter.h:22
template<class T >
std::vector<T> l1t::Parameter::getTableColumn ( const char *  colName) const
inline

Definition at line 70 of file Parameter.h.

References a, AlCaHLTBitMon_QueryRunRegistry::string, and create_public_lumi_plots::transform.

70  {
71  const std::vector<std::string> &column = table.at(colName);
72  std::vector<T> retval(column.size());
73  std::transform(column.begin(),column.end(),retval.begin(), [](std::string a) ->T { return castTo<T>(a.c_str()); });
74  return retval;
75  }
std::map< std::string, std::vector< std::string > > table
Definition: Parameter.h:24
double a
Definition: hdecay.h:121
long double T
template<class T >
std::map<std::string,T> l1t::Parameter::getTableRow ( unsigned long  rowNum) const
inline

Definition at line 77 of file Parameter.h.

77  {
78  std::map<std::string,T> retval;
79  for(auto &column : table) // insert below is never going to fail as the source map doesn't have duplicated by design
80  retval.insert( std::make_pair(column.first, castTo<T>( column.second.at(rowNum).c_str() )) );
81  return retval;
82  }
std::map< std::string, std::vector< std::string > > table
Definition: Parameter.h:24
std::string l1t::Parameter::getType ( void  ) const
inlinenoexcept

Definition at line 30 of file Parameter.h.

References type.

30 { return type; }
std::string type
Definition: Parameter.h:22
template<class T >
T l1t::Parameter::getValue ( void  ) const
inline

Definition at line 49 of file Parameter.h.

References isScalar().

49  {
50  if( !isScalar() ) throw std::runtime_error("The registered type: '" + type + "' is not a scalar -> try getVector() or getTable()");
51  return castTo<T>(scalarOrVector.c_str());
52  }
type
Definition: HCALResponse.h:21
bool isScalar(void) const noexcept
Definition: Parameter.h:33
std::string scalarOrVector
Definition: Parameter.h:23
std::string l1t::Parameter::getValueAsStr ( void  ) const
inlinenoexcept

Definition at line 31 of file Parameter.h.

References scalarOrVector.

31 { return scalarOrVector; }
std::string scalarOrVector
Definition: Parameter.h:23
template<class T >
std::vector<T> l1t::Parameter::getVector ( void  ) const
inline

Definition at line 54 of file Parameter.h.

References popcon2dropbox::copy(), edmIntegrityCheck::d, MillePedeFileConverter_cfg::e, allElectronIsolations_cfi::elements, isVector(), NULL, and AlCaHLTBitMon_QueryRunRegistry::string.

54  {
55  if( !isVector() ) throw std::runtime_error("The registered type: '" + type + "' is not a vector");
56  // split the vector into elements
57  const char *d = delim.c_str();
58  std::list<T> elements;
59  std::unique_ptr<char,void(*)(void*)> copy( strdup(scalarOrVector.c_str()), free );
60  char *saveptr;
61  for(const char *item = strtok_r(copy.get(),d,&saveptr); item != NULL; item = strtok_r(NULL,d,&saveptr) )
62  try {
63  elements.push_back( castTo<T>(item) );
64  } catch (std::runtime_error &e){
65  throw std::runtime_error( std::string(e.what()) + "; check if delimeter '" + delim + "' is correct" );
66  }
67  return std::vector<T>(elements.begin(),elements.end());
68  }
type
Definition: HCALResponse.h:21
#define NULL
Definition: scimark2.h:8
std::string scalarOrVector
Definition: Parameter.h:23
std::string delim
Definition: Parameter.h:23
bool isVector(void) const noexcept
Definition: Parameter.h:39
bool l1t::Parameter::isScalar ( void  ) const
inlinenoexcept

Definition at line 33 of file Parameter.h.

Referenced by getValue().

33  {
34  if( type.find("vector") != std::string::npos ||
35  type.find("table") != std::string::npos )
36  return false;
37  return true;
38  }
type
Definition: HCALResponse.h:21
bool l1t::Parameter::isTable ( void  ) const
inlinenoexcept

Definition at line 43 of file Parameter.h.

43  {
44  if( type.find("table") == std::string::npos ) return false;
45  return true;
46  }
type
Definition: HCALResponse.h:21
bool l1t::Parameter::isVector ( void  ) const
inlinenoexcept

Definition at line 39 of file Parameter.h.

Referenced by getVector().

39  {
40  if( type.find("vector") == std::string::npos ) return false;
41  return true;
42  }
type
Definition: HCALResponse.h:21
Parameter& l1t::Parameter::operator= ( const Parameter s)
default

Referenced by getColumnIndices().

Parameter& l1t::Parameter::operator= ( Parameter &&  s)
default

Member Data Documentation

std::map<std::string,unsigned int> l1t::Parameter::columnNameToIndex
private

Definition at line 25 of file Parameter.h.

Referenced by getColumnIndices().

std::string l1t::Parameter::delim
private

Definition at line 23 of file Parameter.h.

std::string l1t::Parameter::id
private

Definition at line 22 of file Parameter.h.

Referenced by getId().

std::string l1t::Parameter::procOrRole
private

Definition at line 22 of file Parameter.h.

Referenced by getProcOrRole().

std::string l1t::Parameter::scalarOrVector
private

Definition at line 23 of file Parameter.h.

Referenced by getValueAsStr().

std::map<std::string, std::vector<std::string> > l1t::Parameter::table
private

Definition at line 24 of file Parameter.h.

std::string l1t::Parameter::type
private