CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 (unsigned int iVersion=1)
 
 FWConfiguration (const std::string &iValue)
 
 FWConfiguration (const FWConfiguration &)
 
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

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

Definition at line 40 of file FWConfiguration.h.

typedef KeyValues::const_iterator FWConfiguration::KeyValuesIt

Definition at line 41 of file FWConfiguration.h.

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

Definition at line 43 of file FWConfiguration.h.

typedef StringValues::const_iterator FWConfiguration::StringValuesIt

Definition at line 44 of file FWConfiguration.h.

Constructor & Destructor Documentation

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

Definition at line 33 of file FWConfiguration.h.

Referenced by addKeyValue().

33 : m_version(iVersion) {}
unsigned int m_version
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) {}
unsigned int m_version
std::unique_ptr< std::vector< std::string > > m_stringValues
FWConfiguration::~FWConfiguration ( )
virtual

Definition at line 42 of file FWConfiguration.cc.

42 {}
FWConfiguration::FWConfiguration ( const FWConfiguration rhs)

Definition at line 37 of file FWConfiguration.cc.

38  : m_stringValues(rhs.m_stringValues ? new std::vector<std::string>(*(rhs.m_stringValues)) : nullptr),
39  m_keyValues(rhs.m_keyValues ? new KeyValues(*(rhs.m_keyValues)) : nullptr),
40  m_version(rhs.m_version) {}
std::unique_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
unsigned int m_version
std::unique_ptr< std::vector< std::string > > m_stringValues

Member Function Documentation

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

Definition at line 58 of file FWConfiguration.cc.

References m_keyValues, and m_stringValues.

Referenced by addAreaInfoTo(), FWEventAnnotation::addTo(), CmsAnnotation::addTo(), FWCompositeParameter::addTo(), FWTriggerTableView::addTo(), FWLegoViewBase::addTo(), FWGenericParameter< T >::addTo(), FWEventItemsManager::addTo(), FWProxyBuilderConfiguration::addTo(), FWTableView::addTo(), CmsShowNavigator::addTo(), FWGeometryTableViewBase::addTo(), FWGUIManager::addTo(), FWTableViewManager::addToImpl(), FWEveView::addToOrthoCamera(), FWEveView::addToPerspectiveCamera(), addWindowInfoTo(), FWEventItemsManager::setFrom(), FWConfigurationManager::to(), and FWPartialConfigSaveGUI::WriteConfig().

58  {
59  if (m_stringValues) {
60  throw std::runtime_error("adding key/value to configuration containing string values");
61  }
62  if (not m_keyValues) {
63  m_keyValues = std::make_unique<KeyValues>(1, std::make_pair(iKey, iConfig));
64  } else {
65  m_keyValues->push_back(std::make_pair(iKey, iConfig));
66  }
67  return *this;
68 }
std::unique_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
std::unique_ptr< std::vector< std::string > > m_stringValues
FWConfiguration & FWConfiguration::addKeyValue ( const std::string &  iKey,
FWConfiguration iConfig,
bool  iDoSwap = false 
)

Definition at line 69 of file FWConfiguration.cc.

References FWConfiguration(), m_keyValues, and m_stringValues.

69  {
70  if (m_stringValues) {
71  throw std::runtime_error("adding key/value to configuration containing string values");
72  }
73  if (m_stringValues) {
74  throw std::runtime_error("adding key/value to configuration containing string values");
75  }
76  if (not m_keyValues) {
77  if (not iDoSwap) {
78  m_keyValues = std::make_unique<KeyValues>(1, std::make_pair(iKey, iConfig));
79  } else {
80  m_keyValues = std::make_unique<KeyValues>(1, std::make_pair(iKey, FWConfiguration()));
81  m_keyValues->back().second.swap(iConfig);
82  }
83  } else {
84  if (not iDoSwap) {
85  m_keyValues->push_back(std::make_pair(iKey, iConfig));
86  } else {
87  m_keyValues->push_back(std::make_pair(iKey, FWConfiguration()));
88  m_keyValues->back().second.swap(iConfig);
89  }
90  }
91  return *this;
92 }
FWConfiguration(unsigned int iVersion=1)
std::unique_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
std::unique_ptr< std::vector< std::string > > m_stringValues
FWConfiguration & FWConfiguration::addValue ( const std::string &  iValue)

Definition at line 94 of file FWConfiguration.cc.

References m_keyValues, and m_stringValues.

Referenced by FWTableViewManager::addToImpl().

94  {
95  if (m_keyValues) {
96  throw std::runtime_error("adding string value to configuration containing key/value pairs");
97  }
98  if (not m_stringValues) {
99  m_stringValues = std::make_unique<std::vector<std::string>>(1, iValue);
100  } else {
101  m_stringValues->push_back(iValue);
102  }
103  return *this;
104 }
std::unique_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
std::unique_ptr< std::vector< std::string > > m_stringValues
const KeyValues* FWConfiguration::keyValues ( ) const
inline
FWConfiguration & FWConfiguration::operator= ( const FWConfiguration rhs)

Definition at line 47 of file FWConfiguration.cc.

References swap(), and groupFilesInBlocks::temp.

47  {
48  //An exception safe implementation is
49  FWConfiguration temp(rhs);
50  swap(temp);
51 
52  return *this;
53 }
void swap(FWConfiguration &)
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 196 of file FWConfiguration.cc.

References attrEscape(), keyValues(), AlCaHLTBitMon_QueryRunRegistry::string, stringValues(), and version().

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

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

Definition at line 52 of file FWConfiguration.h.

References m_stringValues.

Referenced by FWTableViewManager::setFrom(), and streamTo().

52 { return m_stringValues.get(); }
std::unique_ptr< std::vector< std::string > > m_stringValues
void FWConfiguration::swap ( FWConfiguration iRHS)

Definition at line 106 of file FWConfiguration.cc.

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

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

106  {
108  m_stringValues.swap(iRHS.m_stringValues);
109  m_keyValues.swap(iRHS.m_keyValues);
110 }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::unique_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
unsigned int m_version
std::unique_ptr< std::vector< std::string > > m_stringValues
const std::string & FWConfiguration::value ( unsigned int  iIndex = 0) const

Definition at line 115 of file FWConfiguration.cc.

References m_stringValues.

Referenced by Types.int32::__nonzero__(), Types.uint32::__nonzero__(), Types.int64::__nonzero__(), Types.uint64::__nonzero__(), Types.double::__nonzero__(), Types.bool::__nonzero__(), Types.string::__nonzero__(), average.Average::average(), Types.string::configValue(), Types.FileInPath::configValue(), Mixins.UsingBlock::dumpPython(), Mixins.UsingBlock::insertInto(), Types.int32::insertInto(), Types.uint32::insertInto(), Types.int64::insertInto(), Types.uint64::insertInto(), Types.double::insertInto(), Types.bool::insertInto(), Types.string::insertInto(), Types.FileInPath::insertInto(), Types.vint32::insertInto(), Types.vuint32::insertInto(), Types.vint64::insertInto(), Types.vuint64::insertInto(), Types.vdouble::insertInto(), Types.vbool::insertInto(), Types.vstring::insertInto(), FWEventAnnotation::setFrom(), CmsAnnotation::setFrom(), FWLegoViewBase::setFrom(), FWTriggerTableView::setFrom(), FWRPZView::setFrom(), CmsShowCommon::setFrom(), FW3DViewBase::setFrom(), FWTableView::setFrom(), CmsShowNavigator::setFrom(), FWGUIManager::setFrom(), FWEveView::setFromOrthoCamera(), FWEveView::setFromPerspectiveCamera(), FWGeometryTableViewBase::setTopNodePathFromConfig(), and FWGUIManager::setWindowInfoFrom().

115  {
116  if (not m_stringValues) {
117  throw std::runtime_error("no string values set");
118  }
119  return m_stringValues->at(iIndex);
120 }
std::unique_ptr< std::vector< std::string > > m_stringValues
const FWConfiguration * FWConfiguration::valueForKey ( const std::string &  iKey) const

Definition at line 122 of file FWConfiguration.cc.

References first, m_keyValues, and m_stringValues.

Referenced by FWProxyBuilderConfiguration::assertParam(), FWEventAnnotation::setFrom(), CmsAnnotation::setFrom(), FWCompositeParameter::setFrom(), FWOverlapTableView::setFrom(), FWLegoViewBase::setFrom(), FWTriggerTableView::setFrom(), FWRPZView::setFrom(), FWEventItemsManager::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().

122  {
123  if (m_stringValues) {
124  throw std::runtime_error("valueFoKey fails because configuration containing string values");
125  }
126  if (not m_keyValues) {
127  throw std::runtime_error("valueForKey fails becuase no key/values set");
128  }
129  KeyValues::iterator itFind =
130  std::find_if(m_keyValues->begin(),
131  m_keyValues->end(),
132  std::bind(std::equal_to<void>(),
133  std::bind(&std::pair<std::string, FWConfiguration>::first, std::placeholders::_1),
134  iKey));
135  if (itFind == m_keyValues->end()) {
136  return nullptr;
137  }
138  return &(itFind->second);
139 }
std::unique_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
std::unique_ptr< std::vector< std::string > > m_stringValues
unsigned int FWConfiguration::version ( ) const
inline

Member Data Documentation

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().

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().

unsigned int FWConfiguration::m_version
private

Definition at line 69 of file FWConfiguration.h.

Referenced by swap(), and version().