ATLAS Offline Software
Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
CaloRec::ToolConstants Class Reference

Container for the tool constants managed by ToolWithConstants. More...

#include <ToolConstants.h>

Collaboration diagram for CaloRec::ToolConstants:

Public Types

typedef std::map< std::string, CxxUtils::ArrayrepMaptype
 Type of the map from keys to values. More...
 

Public Member Functions

 ToolConstants ()
 Default constructor. More...
 
const CxxUtils::Arrayrepnewrep (const std::string &context, const std::string &key, const std::string &val)
 Make a new entry. More...
 
const CxxUtils::Arrayrepgetrep (const std::string &context, const std::string &key) const
 Look up an entry. More...
 
void setrep (const std::string &key, const CxxUtils::Arrayrep &rep)
 Set an entry. More...
 
void setrep (const std::string &key, CxxUtils::Arrayrep &&rep)
 Set an entry. More...
 
bool hasrep (const std::string &key) const
 Test to see if a given key is present. More...
 
void writeConstants (std::ostream &stream, const std::string &name) const
 Writes out constants in a python-like format. More...
 
std::string toString (const std::string &name) const
 Return the data as a formatted string. More...
 
const std::string & clsname () const
 Return the name of the C++ class that operates on these constants. More...
 
void clsname (const std::string &name)
 Set the name of the C++ class that operates on these constants. More...
 
int version () const
 Return the version of the C++ class that operates on these constants. More...
 
void version (int version)
 Set the version of the C++ class that operates on these constants. More...
 
const Maptypemap () const
 Return the key -> value map. More...
 

Static Private Member Functions

static void error (const std::string &context, const std::string &key, const std::string &msg)
 Report an error. More...
 

Private Attributes

Maptype m_map
 The map of keys to values. More...
 
std::string m_clsname
 Name of the C++ class that operates on these constants. More...
 
int m_version
 Version number of the C++ class that operates on these constants. More...
 

Detailed Description

Container for the tool constants managed by ToolWithConstants.

This is just a simple map from constant name to Arrayrep.

Definition at line 31 of file ToolConstants.h.

Member Typedef Documentation

◆ Maptype

typedef std::map<std::string, CxxUtils::Arrayrep> CaloRec::ToolConstants::Maptype

Type of the map from keys to values.

Definition at line 35 of file ToolConstants.h.

Constructor & Destructor Documentation

◆ ToolConstants()

CaloRec::ToolConstants::ToolConstants ( )

Default constructor.

Definition at line 23 of file ToolConstants.cxx.

24  : m_version (0)
25 {
26 }

Member Function Documentation

◆ clsname() [1/2]

const std::string & CaloRec::ToolConstants::clsname ( ) const

Return the name of the C++ class that operates on these constants.

Definition at line 152 of file ToolConstants.cxx.

153 {
154  return m_clsname;
155 }

◆ clsname() [2/2]

void CaloRec::ToolConstants::clsname ( const std::string &  name)

Set the name of the C++ class that operates on these constants.

Definition at line 161 of file ToolConstants.cxx.

162 {
163  m_clsname = name;
164 }

◆ error()

void CaloRec::ToolConstants::error ( const std::string &  context,
const std::string &  key,
const std::string &  msg 
)
staticprivate

Report an error.

Parameters
contextContext string for the error.
keyKey involved in the error.
msgError message.

Definition at line 114 of file ToolConstants.cxx.

117 {
118  throw GaudiException (msg, context+":"+key, StatusCode::FAILURE);
119 }

◆ getrep()

const CxxUtils::Arrayrep & CaloRec::ToolConstants::getrep ( const std::string &  context,
const std::string &  key 
) const

Look up an entry.

Parameters
contextThe context name, for error reporting.
keyThe key of the new entry.

Looks up key and returns its Arrayrep. Raises an exception if key isn't found.

Definition at line 59 of file ToolConstants.cxx.

61 {
62  Maptype::const_iterator i = m_map.find (key);
63  if (i == m_map.end()) {
64  std::ostringstream ss;
65  for (const auto& p : m_map) {
66  ss << " " << p.first;
67  }
68  error (context, key, "Can't find key in" + ss.str());
69  }
70  return i->second;
71 }

◆ hasrep()

bool CaloRec::ToolConstants::hasrep ( const std::string &  key) const

Test to see if a given key is present.

Definition at line 101 of file ToolConstants.cxx.

102 {
103  return m_map.contains(key);
104 }

◆ map()

const ToolConstants::Maptype & CaloRec::ToolConstants::map ( ) const

Return the key -> value map.

Definition at line 188 of file ToolConstants.cxx.

189 {
190  return m_map;
191 }

◆ newrep()

const CxxUtils::Arrayrep & CaloRec::ToolConstants::newrep ( const std::string &  context,
const std::string &  key,
const std::string &  val 
)

Make a new entry.

Parameters
contextThe context name, for error reporting.
keyThe key of the new entry.
valThe value of the new entry, as a string.

Converts val to an Arrayrep and stores it. Raises an exception if the key already exists or if there's a conversion error.

Definition at line 40 of file ToolConstants.cxx.

43 {
44  if (m_map.contains(key)) {
45  error (context, key, "Duplicate key");
46  }
47  return m_map[key] = CxxUtils::Arrayrep (val, context+":"+key);
48 }

◆ setrep() [1/2]

void CaloRec::ToolConstants::setrep ( const std::string &  key,
const CxxUtils::Arrayrep rep 
)

Set an entry.

Parameters
keyThe key of the entry to set.
repThe value of the new entry.

Definition at line 79 of file ToolConstants.cxx.

81 {
82  m_map[key] = rep;
83 }

◆ setrep() [2/2]

void CaloRec::ToolConstants::setrep ( const std::string &  key,
CxxUtils::Arrayrep &&  rep 
)

Set an entry.

Parameters
keyThe key of the entry to set.
repThe value of the new entry.

Definition at line 91 of file ToolConstants.cxx.

93 {
94  m_map[key] = std::move (rep);
95 }

◆ toString()

std::string CaloRec::ToolConstants::toString ( const std::string &  name) const

Return the data as a formatted string.

Parameters
nameName of the Maker-Algorithm.

Definition at line 141 of file ToolConstants.cxx.

142 {
143  std::ostringstream ss;
145  return ss.str();
146 }

◆ version() [1/2]

int CaloRec::ToolConstants::version ( ) const

Return the version of the C++ class that operates on these constants.

Definition at line 170 of file ToolConstants.cxx.

171 {
172  return m_version;
173 }

◆ version() [2/2]

void CaloRec::ToolConstants::version ( int  version)

Set the version of the C++ class that operates on these constants.

Definition at line 179 of file ToolConstants.cxx.

180 {
181  m_version = version;
182 }

◆ writeConstants()

void CaloRec::ToolConstants::writeConstants ( std::ostream &  stream,
const std::string &  name 
) const

Writes out constants in a python-like format.

Parameters
streamStream to which to write (file or cout)
nameName of the Maker-Algorithm (used only for output)
streamStream to wirte to (file or cout)
nameName of the Maker-Algorithm (used only for output)

Definition at line 126 of file ToolConstants.cxx.

128 {
129  for (const std::pair<const std::string, CxxUtils::Arrayrep>& p : m_map) {
130  stream << name << "." << p.first << " = ";
131  p.second.write_array(stream);
132  }
133  stream << std::endl;
134 }

Member Data Documentation

◆ m_clsname

std::string CaloRec::ToolConstants::m_clsname
private

Name of the C++ class that operates on these constants.

Definition at line 151 of file ToolConstants.h.

◆ m_map

Maptype CaloRec::ToolConstants::m_map
private

The map of keys to values.

Definition at line 148 of file ToolConstants.h.

◆ m_version

int CaloRec::ToolConstants::m_version
private

Version number of the C++ class that operates on these constants.

Definition at line 154 of file ToolConstants.h.


The documentation for this class was generated from the following files:
CaloRec::ToolConstants::m_clsname
std::string m_clsname
Name of the C++ class that operates on these constants.
Definition: ToolConstants.h:151
CaloRec::ToolConstants::writeConstants
void writeConstants(std::ostream &stream, const std::string &name) const
Writes out constants in a python-like format.
Definition: ToolConstants.cxx:126
CaloRec::ToolConstants::version
int version() const
Return the version of the C++ class that operates on these constants.
Definition: ToolConstants.cxx:170
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
make_hlt_rep.rep
rep
Definition: make_hlt_rep.py:32
CaloRec::ToolConstants::m_version
int m_version
Version number of the C++ class that operates on these constants.
Definition: ToolConstants.h:154
CaloRec::ToolConstants::error
static void error(const std::string &context, const std::string &key, const std::string &msg)
Report an error.
Definition: ToolConstants.cxx:114
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CaloRec::ToolConstants::m_map
Maptype m_map
The map of keys to values.
Definition: ToolConstants.h:148
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
CaloRec::Arrayrep
Representation class for Array's.
Definition: Control/CxxUtils/CxxUtils/Arrayrep.h:62
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37