1 #ifndef L1Trigger_L1TCommon_l1t_Parameter_h 2 #define L1Trigger_L1TCommon_l1t_Parameter_h 24 std::map<std::string, std::vector<std::string> >
table;
34 if( type.find(
"vector") != std::string::npos ||
35 type.find(
"table") != std::string::npos )
40 if( type.find(
"vector") == std::string::npos )
return false;
44 if( type.find(
"table") == std::string::npos )
return false;
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());
54 template<
class T> std::vector<T>
getVector(
void)
const {
55 if( !
isVector() )
throw std::runtime_error(
"The registered type: '" + type +
"' is not a vector");
57 const char *
d = delim.c_str();
59 std::unique_ptr<char,void(*)(void*)>
copy( strdup(scalarOrVector.c_str()), free );
61 for(
const char *item = strtok_r(copy.get(),
d,&saveptr); item !=
nullptr; item = strtok_r(
nullptr,d,&saveptr) )
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" );
67 return std::vector<T>(elements.begin(),elements.end());
71 const std::vector<std::string> &column = table.at(colName);
72 std::vector<T> retval(column.size());
77 template<
class T> std::map<std::string,T>
getTableRow(
unsigned long rowNum)
const {
78 std::map<std::string,T> retval;
79 for(
auto &column : table)
80 retval.insert( std::make_pair(column.first, castTo<T>( column.second.at(rowNum).c_str() )) );
92 const char *procOrRole,
95 const char *delimeter=
"," 98 const char *procOrRole,
101 const std::vector<std::string>&
rows,
102 const char *delimeter=
"," 128 template<
class T>
T castTo_impl(
const char *arg, std::true_type, std::false_type);
129 template<
class T>
T castTo_impl(
const char *arg, std::false_type, std::true_type);
130 template<
class T>
T castTo_impl(
const char *arg, std::false_type, std::false_type);
134 return castTo_impl<T>(
arg, std::is_integral<T>(), std::is_floating_point<T>());
137 template<
class T>
T castTo_impl(
const char *arg, std::true_type, std::false_type){
138 return castToInt_impl<T>(
arg, std::is_unsigned<T>());
149 template<
class T>
T castTo_impl(
const char *arg, std::false_type, std::true_type){
153 template<
class T>
T castTo_impl(
const char *arg, std::false_type, std::false_type) {
char castTo< char >(const char *arg)
long double castTo< long double >(const char *arg)
unsigned int castTo< unsigned int >(const char *arg)
std::vector< T > getTableColumn(const char *colName) const
std::map< std::string, T > getTableRow(unsigned long rowNum) const
std::string getType(void) const noexcept
Parameter & operator=(const Parameter &s)=default
std::vector< T > getVector(void) const
T castTo_impl(const char *arg, std::true_type, std::false_type)
std::map< std::string, std::vector< std::string > > table
bool isTable(void) const noexcept
unsigned long long castTo< unsigned long long >(const char *arg)
std::string getValueAsStr(void) const noexcept
std::string getProcOrRole(void) const noexcept
unsigned long castTo< unsigned long >(const char *arg)
bool isScalar(void) const noexcept
std::string scalarOrVector
T castToInt_impl(const char *arg, std::true_type)
std::string getId(void) const noexcept
float castTo< float >(const char *arg)
bool castTo< bool >(const char *arg)
long long castTo< long long >(const char *arg)
T castTo(const char *arg)
std::map< std::string, unsigned int > getColumnIndices(void) const noexcept
unsigned short castTo< unsigned short >(const char *arg)
double castTo< double >(const char *arg)
short castTo< short >(const char *arg)
long castTo< long >(const char *arg)
bool isVector(void) const noexcept
std::map< std::string, unsigned int > columnNameToIndex
unsigned char castTo< unsigned char >(const char *arg)
int castTo< int >(const char *arg)