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

boost::scoped_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
 
boost::scoped_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(), and FWConfiguration().

33 : m_version(iVersion) {}
unsigned int m_version
FWConfiguration::FWConfiguration ( const std::string &  iValue)
inline

Definition at line 34 of file FWConfiguration.h.

References FWConfiguration(), operator=(), and ~FWConfiguration().

34 : m_stringValues(new std::vector<std::string>(1, iValue)), m_version(0) {}
boost::scoped_ptr< std::vector< std::string > > m_stringValues
unsigned int m_version
FWConfiguration::~FWConfiguration ( )
virtual

Definition at line 41 of file FWConfiguration.cc.

Referenced by FWConfiguration().

41 {}
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) {}
boost::scoped_ptr< std::vector< std::string > > m_stringValues
boost::scoped_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
unsigned int m_version

Member Function Documentation

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

Definition at line 57 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(), CmsShowCommon::setGeomTransparency(), stringValues(), FWConfigurationManager::to(), and FWPartialConfigSaveGUI::WriteConfig().

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

Definition at line 68 of file FWConfiguration.cc.

References FWConfiguration(), m_keyValues, and m_stringValues.

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 }
FWConfiguration(unsigned int iVersion=1)
boost::scoped_ptr< std::vector< std::string > > m_stringValues
boost::scoped_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
FWConfiguration & FWConfiguration::addValue ( const std::string &  iValue)

Definition at line 93 of file FWConfiguration.cc.

References m_keyValues, and m_stringValues.

Referenced by FWTableViewManager::addToImpl(), and stringValues().

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 }
boost::scoped_ptr< std::vector< std::string > > m_stringValues
boost::scoped_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
const KeyValues* FWConfiguration::keyValues ( ) const
inline
FWConfiguration & FWConfiguration::operator= ( const FWConfiguration rhs)

Definition at line 46 of file FWConfiguration.cc.

References swap(), and groupFilesInBlocks::temp.

Referenced by FWConfiguration().

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

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

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

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 }
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 addKeyValue(), addValue(), m_stringValues, Skims_PA_cff::name, streamTo(), AlCaHLTBitMon_QueryRunRegistry::string, and swap().

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

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

Definition at line 105 of file FWConfiguration.cc.

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

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

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

Definition at line 114 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__(), attrEscape(), average.Average::average(), Vispa.Views.PropertyView.FileProperty::buttonClicked(), 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(), Vispa.Views.PropertyView.FileProperty::labelDoubleClicked(), FWEventAnnotation::setFrom(), CmsAnnotation::setFrom(), FWLegoViewBase::setFrom(), FWRPZView::setFrom(), FWTriggerTableView::setFrom(), FW3DViewBase::setFrom(), CmsShowCommon::setFrom(), FWTableView::setFrom(), CmsShowNavigator::setFrom(), FWGUIManager::setFrom(), FWEveView::setFromOrthoCamera(), FWEveView::setFromPerspectiveCamera(), CmsShowCommon::setGeomTransparency(), FWGeometryTableViewBase::setTopNodePathFromConfig(), and FWGUIManager::setWindowInfoFrom().

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

Definition at line 121 of file FWConfiguration.cc.

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(), CmsShowCommon::setFrom(), FW3DViewBase::setFrom(), FWGenericParameter< T >::setFrom(), FWTableView::setFrom(), FWTableViewManager::setFrom(), CmsShowNavigator::setFrom(), FWGUIManager::setFrom(), FWEveView::setFromOrthoCamera(), FWEveView::setFromPerspectiveCamera(), CmsShowCommon::setGeomTransparency(), FWGeometryTableViewBase::setTopNodePathFromConfig(), and FWGUIManager::setWindowInfoFrom().

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 }
boost::scoped_ptr< std::vector< std::string > > m_stringValues
boost::scoped_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
unsigned int FWConfiguration::version ( ) const
inline

Member Data Documentation

boost::scoped_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().

boost::scoped_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().