CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
FWConfiguration Class Reference

#include <Fireworks/Core/interface/FWConfiguration.h>

Public Types

typedef std::vector< std::pair< std::string, FWConfiguration > > KeyValues
 
typedef KeyValues::const_iterator KeyValuesIt
 
typedef std::vector< std::string > StringValues
 
typedef StringValues::const_iterator StringValuesIt
 

Public Member Functions

FWConfigurationaddKeyValue (const std::string &, const FWConfiguration &)
 
FWConfigurationaddKeyValue (const std::string &, FWConfiguration &, bool iDoSwap=false)
 
FWConfigurationaddValue (const std::string &)
 
 FWConfiguration (const FWConfiguration &)
 
 FWConfiguration (const std::string &iValue)
 
 FWConfiguration (unsigned int iVersion=1)
 
const KeyValueskeyValues () const
 
FWConfigurationoperator= (const FWConfiguration &)
 
const StringValuesstringValues () const
 
void swap (FWConfiguration &)
 
const std::string & value (unsigned int iIndex=0) const
 
const FWConfigurationvalueForKey (const std::string &iKey) const
 
unsigned int version () const
 
virtual ~FWConfiguration ()
 

Static Public Member Functions

static void streamTo (std::ostream &oTo, const FWConfiguration &iConfig, const std::string &name)
 

Private Attributes

std::unique_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
 
std::unique_ptr< std::vector< std::string > > m_stringValues
 
unsigned int m_version
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 31 of file FWConfiguration.h.

Member Typedef Documentation

◆ KeyValues

typedef std::vector<std::pair<std::string, FWConfiguration> > FWConfiguration::KeyValues

Definition at line 40 of file FWConfiguration.h.

◆ KeyValuesIt

typedef KeyValues::const_iterator FWConfiguration::KeyValuesIt

Definition at line 41 of file FWConfiguration.h.

◆ StringValues

typedef std::vector<std::string> FWConfiguration::StringValues

Definition at line 43 of file FWConfiguration.h.

◆ StringValuesIt

typedef StringValues::const_iterator FWConfiguration::StringValuesIt

Definition at line 44 of file FWConfiguration.h.

Constructor & Destructor Documentation

◆ FWConfiguration() [1/3]

FWConfiguration::FWConfiguration ( unsigned int  iVersion = 1)
inline

Definition at line 33 of file FWConfiguration.h.

33 : m_version(iVersion) {}

Referenced by addKeyValue().

◆ FWConfiguration() [2/3]

FWConfiguration::FWConfiguration ( const std::string &  iValue)
inline

Definition at line 34 of file FWConfiguration.h.

34 : m_stringValues(new std::vector<std::string>(1, iValue)), m_version(0) {}

◆ ~FWConfiguration()

FWConfiguration::~FWConfiguration ( )
virtual

Definition at line 41 of file FWConfiguration.cc.

41 {}

◆ FWConfiguration() [3/3]

FWConfiguration::FWConfiguration ( const FWConfiguration rhs)

Definition at line 36 of file FWConfiguration.cc.

37  : m_stringValues(rhs.m_stringValues ? new std::vector<std::string>(*(rhs.m_stringValues)) : nullptr),
38  m_keyValues(rhs.m_keyValues ? new KeyValues(*(rhs.m_keyValues)) : nullptr),
39  m_version(rhs.m_version) {}

Member Function Documentation

◆ addKeyValue() [1/2]

FWConfiguration & FWConfiguration::addKeyValue ( const std::string &  iKey,
const FWConfiguration iConfig 
)

◆ addKeyValue() [2/2]

FWConfiguration & FWConfiguration::addKeyValue ( const std::string &  iKey,
FWConfiguration iConfig,
bool  iDoSwap = false 
)

Definition at line 68 of file FWConfiguration.cc.

68  {
69  if (m_stringValues) {
70  throw std::runtime_error("adding key/value to configuration containing string values");
71  }
72  if (m_stringValues) {
73  throw std::runtime_error("adding key/value to configuration containing string values");
74  }
75  if (not m_keyValues) {
76  if (not iDoSwap) {
77  m_keyValues.reset(new KeyValues(1, std::make_pair(iKey, iConfig)));
78  } else {
79  m_keyValues.reset(new KeyValues(1, std::make_pair(iKey, FWConfiguration())));
80  m_keyValues->back().second.swap(iConfig);
81  }
82  } else {
83  if (not iDoSwap) {
84  m_keyValues->push_back(std::make_pair(iKey, iConfig));
85  } else {
86  m_keyValues->push_back(std::make_pair(iKey, FWConfiguration()));
87  m_keyValues->back().second.swap(iConfig);
88  }
89  }
90  return *this;
91 }

References FWConfiguration(), m_keyValues, and m_stringValues.

◆ addValue()

FWConfiguration & FWConfiguration::addValue ( const std::string &  iValue)

Definition at line 93 of file FWConfiguration.cc.

93  {
94  if (m_keyValues) {
95  throw std::runtime_error("adding string value to configuration containing key/value pairs");
96  }
97  if (not m_stringValues) {
98  m_stringValues.reset(new std::vector<std::string>(1, iValue));
99  } else {
100  m_stringValues->push_back(iValue);
101  }
102  return *this;
103 }

References m_keyValues, and m_stringValues.

◆ keyValues()

const KeyValues* FWConfiguration::keyValues ( ) const
inline

◆ operator=()

FWConfiguration & FWConfiguration::operator= ( const FWConfiguration rhs)

Definition at line 46 of file FWConfiguration.cc.

46  {
47  //An exception safe implementation is
48  FWConfiguration temp(rhs);
49  swap(temp);
50 
51  return *this;
52 }

References swap(), and groupFilesInBlocks::temp.

◆ streamTo()

void FWConfiguration::streamTo ( std::ostream &  oTo,
const FWConfiguration iConfig,
const std::string &  name 
)
static

Streaming FWConfiguration objects to xml.

Example of dump is:

<config name="top" version="1"> <string value="S1"> <string value="S2"> ... <string value="SN"> <config name="c1"> ... </configuration> <config name="c2"> ... </config> ... </config>

Streaming the top level configuration item will stream all its children.

Definition at line 192 of file FWConfiguration.cc.

192  {
193  static int recursionLevel = -1;
194  recursionLevel += 1;
195  std::string indentation(recursionLevel, ' ');
196  oTo << indentation << "<config name=\"" << name << "\" version=\"" << iConfig.version() << "\">\n";
197  if (iConfig.stringValues()) {
198  for (FWConfiguration::StringValues::const_iterator it = iConfig.stringValues()->begin();
199  it != iConfig.stringValues()->end();
200  ++it) {
201  oTo << indentation << " <string>" << attrEscape(*it) << "</string>\n";
202  }
203  }
204  if (iConfig.keyValues()) {
205  for (FWConfiguration::KeyValues::const_iterator it = iConfig.keyValues()->begin(); it != iConfig.keyValues()->end();
206  ++it) {
207  FWConfiguration::streamTo(oTo, it->second, attrEscape(it->first));
208  }
209  }
210  oTo << indentation << "</config>" << std::endl;
211  recursionLevel -= 1;
212 }

References attrEscape(), printContent_cfi::indentation, keyValues(), Skims_PA_cff::name, AlCaHLTBitMon_QueryRunRegistry::string, stringValues(), and version().

Referenced by FWPartialConfigSaveGUI::WriteConfig(), and FWConfigurationManager::writeToFile().

◆ stringValues()

const StringValues* FWConfiguration::stringValues ( ) const
inline

Definition at line 52 of file FWConfiguration.h.

52 { return m_stringValues.get(); }

References m_stringValues.

Referenced by streamTo().

◆ swap()

void FWConfiguration::swap ( FWConfiguration iRHS)

Definition at line 105 of file FWConfiguration.cc.

105  {
107  m_stringValues.swap(iRHS.m_stringValues);
108  m_keyValues.swap(iRHS.m_keyValues);
109 }

References m_keyValues, m_stringValues, m_version, and std::swap().

Referenced by FWPartialConfigGUI::FWPartialConfigGUI(), and operator=().

◆ value()

const std::string & FWConfiguration::value ( unsigned int  iIndex = 0) const

◆ valueForKey()

const FWConfiguration * FWConfiguration::valueForKey ( const std::string &  iKey) const

Definition at line 121 of file FWConfiguration.cc.

121  {
122  if (m_stringValues) {
123  throw std::runtime_error("valueFoKey fails because configuration containing string values");
124  }
125  if (not m_keyValues) {
126  throw std::runtime_error("valueForKey fails becuase no key/values set");
127  }
128  KeyValues::iterator itFind = std::find_if(m_keyValues->begin(),
129  m_keyValues->end(),
130  boost::bind(&std::pair<std::string, FWConfiguration>::first, _1) == iKey);
131  if (itFind == m_keyValues->end()) {
132  return nullptr;
133  }
134  return &(itFind->second);
135 }

References dqmdumpme::first, m_keyValues, and m_stringValues.

Referenced by FWProxyBuilderConfiguration::assertParam(), FWEventAnnotation::setFrom(), CmsAnnotation::setFrom(), FWCompositeParameter::setFrom(), FWOverlapTableView::setFrom(), FWLegoViewBase::setFrom(), FWRPZView::setFrom(), FWEventItemsManager::setFrom(), FWTriggerTableView::setFrom(), FWGeometryTableView::setFrom(), FW3DViewBase::setFrom(), CmsShowCommon::setFrom(), FWGenericParameter< T >::setFrom(), FWTableView::setFrom(), FWTableViewManager::setFrom(), CmsShowNavigator::setFrom(), FWGUIManager::setFrom(), FWEveView::setFromOrthoCamera(), FWEveView::setFromPerspectiveCamera(), FWGeometryTableViewBase::setTopNodePathFromConfig(), and FWGUIManager::setWindowInfoFrom().

◆ version()

unsigned int FWConfiguration::version ( ) const
inline

Member Data Documentation

◆ m_keyValues

std::unique_ptr<std::vector<std::pair<std::string, FWConfiguration> > > FWConfiguration::m_keyValues
private

Definition at line 68 of file FWConfiguration.h.

Referenced by addKeyValue(), addValue(), keyValues(), swap(), and valueForKey().

◆ m_stringValues

std::unique_ptr<std::vector<std::string> > FWConfiguration::m_stringValues
private

Definition at line 67 of file FWConfiguration.h.

Referenced by addKeyValue(), addValue(), stringValues(), swap(), value(), and valueForKey().

◆ m_version

unsigned int FWConfiguration::m_version
private

Definition at line 69 of file FWConfiguration.h.

Referenced by swap(), and version().

FWConfiguration::streamTo
static void streamTo(std::ostream &oTo, const FWConfiguration &iConfig, const std::string &name)
Definition: FWConfiguration.cc:192
FWConfiguration::swap
void swap(FWConfiguration &)
Definition: FWConfiguration.cc:105
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
FWConfiguration::KeyValues
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
Definition: FWConfiguration.h:40
dqmdumpme.first
first
Definition: dqmdumpme.py:55
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
FWConfiguration::m_version
unsigned int m_version
Definition: FWConfiguration.h:69
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWConfiguration::version
unsigned int version() const
Definition: FWConfiguration.h:49
FWConfiguration::FWConfiguration
FWConfiguration(unsigned int iVersion=1)
Definition: FWConfiguration.h:33
FWConfiguration::keyValues
const KeyValues * keyValues() const
Definition: FWConfiguration.h:51
FWConfiguration::m_keyValues
std::unique_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
Definition: FWConfiguration.h:68
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
printContent_cfi.indentation
indentation
Definition: printContent_cfi.py:10
FWConfiguration::m_stringValues
std::unique_ptr< std::vector< std::string > > m_stringValues
Definition: FWConfiguration.h:67
FWConfiguration::stringValues
const StringValues * stringValues() const
Definition: FWConfiguration.h:52
FWConfiguration
Definition: FWConfiguration.h:31
attrEscape
std::string attrEscape(std::string value)
Definition: FWConfiguration.cc:140