CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 21 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 = "," 
)

Definition at line 9 of file Parameter.cc.

References gpuClustering::id, and relativeConstraints::value.

10  {
11  this->id = id;
12  this->procOrRole = procOrRole;
13  this->type = type;
14  this->scalarOrVector = value;
15  this->delim = delimeter;
16  }
std::string scalarOrVector
Definition: Parameter.h:24
std::string delim
Definition: Parameter.h:24
std::string procOrRole
Definition: Parameter.h:23
std::string type
Definition: Parameter.h:23
std::string id
Definition: Parameter.h:23
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 111 of file Parameter.h.

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

Definition at line 112 of file Parameter.h.

112 {}

Member Function Documentation

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

Definition at line 96 of file Parameter.h.

References columnNameToIndex.

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

Definition at line 30 of file Parameter.h.

References id.

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

Definition at line 31 of file Parameter.h.

References procOrRole.

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

Definition at line 79 of file Parameter.h.

References a, AlCaHLTBitMon_QueryRunRegistry::string, table, and HcalDetIdTransform::transform().

79  {
80  const std::vector<std::string> &column = table.at(colName);
81  std::vector<T> retval(column.size());
83  column.begin(), column.end(), retval.begin(), [](std::string a) -> T { return castTo<T>(a.c_str()); });
84  return retval;
85  }
std::map< std::string, std::vector< std::string > > table
Definition: Parameter.h:26
double a
Definition: hdecay.h:119
long double T
unsigned transform(const HcalDetId &id, unsigned transformCode)
template<class T >
std::map<std::string, T> l1t::Parameter::getTableRow ( unsigned long  rowNum) const
inline

Definition at line 88 of file Parameter.h.

References table.

88  {
89  std::map<std::string, T> retval;
90  for (auto &column :
91  table) // insert below is never going to fail as the source map doesn't have duplicated by design
92  retval.insert(std::make_pair(column.first, castTo<T>(column.second.at(rowNum).c_str())));
93  return retval;
94  }
std::map< std::string, std::vector< std::string > > table
Definition: Parameter.h:26
std::string l1t::Parameter::getType ( void  ) const
inlinenoexcept

Definition at line 32 of file Parameter.h.

References type.

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

Definition at line 53 of file Parameter.h.

References isScalar(), and scalarOrVector.

53  {
54  if (!isScalar())
55  throw std::runtime_error("The registered type: '" + type +
56  "' is not a scalar -> try getVector() or getTable()");
57  return castTo<T>(scalarOrVector.c_str());
58  }
bool isScalar(void) const noexcept
Definition: Parameter.h:35
std::string scalarOrVector
Definition: Parameter.h:24
std::string l1t::Parameter::getValueAsStr ( void  ) const
inlinenoexcept

Definition at line 33 of file Parameter.h.

References scalarOrVector.

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

Definition at line 61 of file Parameter.h.

References filterCSVwithJSON::copy, ztail::d, delim, alignCSCRings::e, bookConverter::elements, isVector(), B2GTnPMonitor_cfi::item, scalarOrVector, and AlCaHLTBitMon_QueryRunRegistry::string.

61  {
62  if (!isVector())
63  throw std::runtime_error("The registered type: '" + type + "' is not a vector");
64  // split the vector into elements
65  const char *d = delim.c_str();
66  std::list<T> elements;
67  std::unique_ptr<char, void (*)(void *)> copy(strdup(scalarOrVector.c_str()), free);
68  char *saveptr;
69  for (const char *item = strtok_r(copy.get(), d, &saveptr); item != nullptr; item = strtok_r(nullptr, d, &saveptr))
70  try {
71  elements.push_back(castTo<T>(item));
72  } catch (std::runtime_error &e) {
73  throw std::runtime_error(std::string(e.what()) + "; check if delimeter '" + delim + "' is correct");
74  }
75  return std::vector<T>(elements.begin(), elements.end());
76  }
bool isVector(void) const noexcept
Definition: Parameter.h:40
dictionary elements
tuple d
Definition: ztail.py:151
std::string scalarOrVector
Definition: Parameter.h:24
std::string delim
Definition: Parameter.h:24
bool l1t::Parameter::isScalar ( void  ) const
inlinenoexcept

Definition at line 35 of file Parameter.h.

Referenced by getValue().

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

Definition at line 45 of file Parameter.h.

45  {
46  if (type.find("table") == std::string::npos)
47  return false;
48  return true;
49  }
bool l1t::Parameter::isVector ( void  ) const
inlinenoexcept

Definition at line 40 of file Parameter.h.

Referenced by getVector().

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

Member Data Documentation

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

Definition at line 27 of file Parameter.h.

Referenced by getColumnIndices().

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

Definition at line 24 of file Parameter.h.

Referenced by getVector().

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

Definition at line 23 of file Parameter.h.

Referenced by getId().

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

Definition at line 23 of file Parameter.h.

Referenced by getProcOrRole().

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

Definition at line 24 of file Parameter.h.

Referenced by getValue(), getValueAsStr(), and getVector().

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

Definition at line 26 of file Parameter.h.

Referenced by getTableColumn(), and getTableRow().

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