ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
TCS::ParameterSpace Class Reference

#include <ParameterSpace.h>

Collaboration diagram for TCS::ParameterSpace:

Public Types

typedef std::vector< TCS::Parameterdata_t
 
typedef data_t::iterator iterator
 
typedef data_t::const_iterator const_iterator
 

Public Member Functions

 ParameterSpace (const std::string &algName)
 
 ParameterSpace ()
 
bool isInitialized () const
 
const std::string & algName () const
 
ParameterSpaceaddParameter (const Parameter &p)
 
ParameterSpaceaddParameter (const std::string &name, TCS::parType_t value)
 
ParameterSpaceaddParameter (const std::string &name, TCS::parType_t value, unsigned int selection)
 
ParameterSpacesetParameter (const Parameter &p)
 
ParameterSpacesetParameter (const std::string &name, TCS::parType_t value)
 
ParameterSpacesetParameter (const std::string &name, TCS::parType_t value, unsigned int selection)
 
const Parameterparameter (const std::string &parameterName) const
 
const Parameterparameter (const std::string &parameterName, unsigned int selection) const
 
const std::vector< TCS::Parameter > & parameters () const
 
bool contains (const std::string &parameterName, unsigned int selection) const
 
void clear ()
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
data_toperator() ()
 
const data_toperator() () const
 
unsigned index () const
 
void setIndex (unsigned int index)
 

Private Attributes

data_t m_parameters
 
unsigned int m_index
 
std::string m_algName
 

Detailed Description

Definition at line 18 of file ParameterSpace.h.

Member Typedef Documentation

◆ const_iterator

typedef data_t::const_iterator TCS::ParameterSpace::const_iterator

Definition at line 22 of file ParameterSpace.h.

◆ data_t

Definition at line 20 of file ParameterSpace.h.

◆ iterator

typedef data_t::iterator TCS::ParameterSpace::iterator

Definition at line 21 of file ParameterSpace.h.

Constructor & Destructor Documentation

◆ ParameterSpace() [1/2]

TCS::ParameterSpace::ParameterSpace ( const std::string &  algName)
inline

Definition at line 24 of file ParameterSpace.h.

24  :
25  m_index(0),
27  {};

◆ ParameterSpace() [2/2]

TCS::ParameterSpace::ParameterSpace ( )
inline

Definition at line 29 of file ParameterSpace.h.

29  :
30  m_index(0),
31  m_algName("NONE")
32  {};

Member Function Documentation

◆ addParameter() [1/3]

ParameterSpace & ParameterSpace::addParameter ( const Parameter p)

Definition at line 29 of file ParameterSpace.cxx.

29  {
30  if( contains(p.name(), p.selection()) ) {
31  TCS_EXCEPTION("ParameterSpace: parameter '" << p.name() << "|" << p.selection() <<
32  "' exists already in parameter space of '" << algName() << "' and can't be added");
33  }
34  m_parameters.push_back(p);
35  m_parameters.back().setIsDefault(true);
36  return *this;
37 }

◆ addParameter() [2/3]

ParameterSpace & ParameterSpace::addParameter ( const std::string &  name,
TCS::parType_t  value 
)

Definition at line 16 of file ParameterSpace.cxx.

16  {
17  return addParameter( Parameter(name, value));
18 }

◆ addParameter() [3/3]

ParameterSpace & ParameterSpace::addParameter ( const std::string &  name,
TCS::parType_t  value,
unsigned int  selection 
)

Definition at line 22 of file ParameterSpace.cxx.

22  {
24 }

◆ algName()

const std::string& TCS::ParameterSpace::algName ( ) const
inline

Definition at line 36 of file ParameterSpace.h.

36 { return m_algName; }

◆ begin() [1/2]

iterator TCS::ParameterSpace::begin ( )
inline

Definition at line 64 of file ParameterSpace.h.

64 { return m_parameters.begin(); }

◆ begin() [2/2]

const_iterator TCS::ParameterSpace::begin ( ) const
inline

Definition at line 65 of file ParameterSpace.h.

65 { return m_parameters.begin(); }

◆ clear()

void TCS::ParameterSpace::clear ( )
inline

Definition at line 62 of file ParameterSpace.h.

62 { m_parameters.clear(); }

◆ contains()

bool ParameterSpace::contains ( const std::string &  parameterName,
unsigned int  selection 
) const

Definition at line 92 of file ParameterSpace.cxx.

92  {
93  for(const Parameter& pa: m_parameters)
94  if( (pa.name() == parameterName) && (pa.selection() == selection) ) return true;
95  return false;
96 }

◆ end() [1/2]

iterator TCS::ParameterSpace::end ( )
inline

Definition at line 67 of file ParameterSpace.h.

67 { return m_parameters.end(); }

◆ end() [2/2]

const_iterator TCS::ParameterSpace::end ( ) const
inline

Definition at line 68 of file ParameterSpace.h.

68 { return m_parameters.end(); }

◆ index()

unsigned TCS::ParameterSpace::index ( ) const
inline

Definition at line 73 of file ParameterSpace.h.

73 { return m_index; }

◆ isInitialized()

bool TCS::ParameterSpace::isInitialized ( ) const
inline

Definition at line 34 of file ParameterSpace.h.

34 { return m_algName != "NONE"; }

◆ operator()() [1/2]

data_t& TCS::ParameterSpace::operator() ( )
inline

Definition at line 70 of file ParameterSpace.h.

70 { return m_parameters; }

◆ operator()() [2/2]

const data_t& TCS::ParameterSpace::operator() ( ) const
inline

Definition at line 71 of file ParameterSpace.h.

71 { return m_parameters; }

◆ parameter() [1/2]

const Parameter & ParameterSpace::parameter ( const std::string &  parameterName) const

Definition at line 101 of file ParameterSpace.cxx.

101  {
102  for(const Parameter & pa : m_parameters) {
103  if( pa.isExtended() ) continue;
104  if( pa.name() == parameterName )
105  return pa;
106  }
107 
108  TCS_EXCEPTION("Single parameter " << parameterName << " not found for algorithm " << algName());
109  return m_parameters[0]; // doesn't make sense, but should never get here
110 }

◆ parameter() [2/2]

const Parameter & ParameterSpace::parameter ( const std::string &  parameterName,
unsigned int  selection 
) const

Definition at line 114 of file ParameterSpace.cxx.

114  {
115  for(const Parameter & pa : m_parameters) {
116  if( ! pa.isExtended() ) continue;
117  if( (pa.name() == parameterName) && (pa.selection() == selection) )
118  return pa;
119  }
120 
121  TCS_EXCEPTION("Array parameter " << parameterName << "[" << selection << "] not found for algorithm " << algName());
122  return m_parameters[0]; // doesn't make sense, but should never get here
123 }

◆ parameters()

const std::vector<TCS::Parameter>& TCS::ParameterSpace::parameters ( ) const
inline

Definition at line 57 of file ParameterSpace.h.

57 { return m_parameters; }

◆ setIndex()

void TCS::ParameterSpace::setIndex ( unsigned int  index)
inline

Definition at line 74 of file ParameterSpace.h.

74 { m_index = index; }

◆ setParameter() [1/3]

ParameterSpace & ParameterSpace::setParameter ( const Parameter p)

Definition at line 49 of file ParameterSpace.cxx.

49  {
50 
51  bool foundParameter = false;
52 
53  //cout << "Setting parameter " << p.name() << "[" << p.selection() << "] for algorithm " << algName() << endl;
54 
55  for(TCS::Parameter& pa : m_parameters) {
56  foundParameter =
57  ( !pa.isExtended() && pa.name()==p.name() ) ||
58  ( pa.isExtended() && pa.name()==p.name() && pa.selection()==p.selection() );
59 
60  if(! foundParameter) continue;
61 
62  if( pa.isExtended() ) {
63  pa.setValue(p.value());
64  pa.setPosition(p.position());
65  pa.setSelection(p.selection());
66  pa.setIsExtended(true); // for parameters to print correctly
67  } else {
68  pa.setValue(p.value());
69  pa.setIsExtended(false);
70  }
71  pa.setIsDefault(false);
72  break;
73  }
74 
75  if( ! foundParameter ) {
76  cout << "Parameter '" << p.name() << "' not found for algorithm " << algName()
77  << " and can't be set. Available parameters are" << endl;
78 
79  for(TCS::Parameter& pa : m_parameters) {
80  cout << " " << pa.name() << " " << (pa.isExtended()?"array":"single") << endl;
81  }
82  TCS_EXCEPTION( "Parameter '" << p.name() << "' not found for algorithm " << algName() << " and can't be set." );
83  }
84  return *this;
85 }

◆ setParameter() [2/3]

ParameterSpace& TCS::ParameterSpace::setParameter ( const std::string &  name,
TCS::parType_t  value 
)

◆ setParameter() [3/3]

ParameterSpace & ParameterSpace::setParameter ( const std::string &  name,
TCS::parType_t  value,
unsigned int  selection 
)

Definition at line 41 of file ParameterSpace.cxx.

41  {
43 }

Member Data Documentation

◆ m_algName

std::string TCS::ParameterSpace::m_algName
private

Definition at line 81 of file ParameterSpace.h.

◆ m_index

unsigned int TCS::ParameterSpace::m_index
private

Definition at line 78 of file ParameterSpace.h.

◆ m_parameters

data_t TCS::ParameterSpace::m_parameters
private

Definition at line 77 of file ParameterSpace.h.


The documentation for this class was generated from the following files:
TCS::Parameter
Definition: Parameter.h:24
TCS::ParameterSpace::addParameter
ParameterSpace & addParameter(const Parameter &p)
Definition: ParameterSpace.cxx:29
athena.value
value
Definition: athena.py:124
TCS::ParameterSpace::index
unsigned index() const
Definition: ParameterSpace.h:73
TCS::ParameterSpace::m_index
unsigned int m_index
Definition: ParameterSpace.h:78
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TCS::ParameterSpace::setParameter
ParameterSpace & setParameter(const Parameter &p)
Definition: ParameterSpace.cxx:49
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
selection
std::string selection
Definition: fbtTestBasics.cxx:75
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TCS::ParameterSpace::contains
bool contains(const std::string &parameterName, unsigned int selection) const
Definition: ParameterSpace.cxx:92
TCS::ParameterSpace::m_algName
std::string m_algName
Definition: ParameterSpace.h:81
TCS::ParameterSpace::algName
const std::string & algName() const
Definition: ParameterSpace.h:36
TCS::ParameterSpace::m_parameters
data_t m_parameters
Definition: ParameterSpace.h:77