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 45 of file FWConfiguration.h.

typedef KeyValues::const_iterator FWConfiguration::KeyValuesIt

Definition at line 46 of file FWConfiguration.h.

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

Definition at line 48 of file FWConfiguration.h.

typedef StringValues::const_iterator FWConfiguration::StringValuesIt

Definition at line 49 of file FWConfiguration.h.

Constructor & Destructor Documentation

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

Definition at line 35 of file FWConfiguration.h.

Referenced by addKeyValue(), and FWConfiguration().

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

Definition at line 37 of file FWConfiguration.h.

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

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

Definition at line 44 of file FWConfiguration.cc.

Referenced by FWConfiguration().

45 {
46 }
FWConfiguration::FWConfiguration ( const FWConfiguration rhs)

Definition at line 37 of file FWConfiguration.cc.

37  :
38  m_stringValues( rhs.m_stringValues ? new std::vector<std::string>(*(rhs.m_stringValues)) : 0),
39  m_keyValues( rhs.m_keyValues ? new KeyValues(*(rhs.m_keyValues)) : 0),
40  m_version(rhs.m_version)
41 {
42 }
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
boost::scoped_ptr< std::vector< std::string > > m_stringValues
unsigned int m_version
boost::scoped_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues

Member Function Documentation

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

Definition at line 64 of file FWConfiguration.cc.

References m_keyValues, and m_stringValues.

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

65 {
66  if( m_stringValues ) {
67  throw std::runtime_error("adding key/value to configuration containing string values");
68  }
69  if(not m_keyValues) {
70  m_keyValues.reset(new KeyValues(1, std::make_pair(iKey,iConfig) ) );
71  } else {
72  m_keyValues->push_back(std::make_pair(iKey,iConfig));
73  }
74  return *this;
75 }
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
boost::scoped_ptr< std::vector< std::string > > m_stringValues
boost::scoped_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
FWConfiguration & FWConfiguration::addKeyValue ( const std::string &  iKey,
FWConfiguration iConfig,
bool  iDoSwap = false 
)

Definition at line 77 of file FWConfiguration.cc.

References FWConfiguration(), m_keyValues, and m_stringValues.

78 {
79  if( m_stringValues ) {
80  throw std::runtime_error("adding key/value to configuration containing string values");
81  }
82  if( m_stringValues ) {
83  throw std::runtime_error("adding key/value to configuration containing string values");
84  }
85  if(not m_keyValues) {
86  if(not iDoSwap) {
87  m_keyValues.reset(new KeyValues(1, std::make_pair(iKey,iConfig) ) );
88  } else {
89  m_keyValues.reset(new KeyValues(1, std::make_pair(iKey,FWConfiguration()) ) );
90  m_keyValues->back().second.swap(iConfig);
91  }
92  } else {
93  if(not iDoSwap) {
94  m_keyValues->push_back(std::make_pair(iKey,iConfig));
95  } else {
96  m_keyValues->push_back(std::make_pair(iKey,FWConfiguration()));
97  m_keyValues->back().second.swap(iConfig);
98  }
99  }
100  return *this;
101 }
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
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
FWConfiguration & FWConfiguration::addValue ( const std::string &  iValue)

Definition at line 104 of file FWConfiguration.cc.

References m_keyValues, and m_stringValues.

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

105 {
106  if( m_keyValues ) {
107  throw std::runtime_error("adding string value to configuration containing key/value pairs");
108  }
109  if( not m_stringValues ) {
110  m_stringValues.reset( new std::vector<std::string>(1,iValue) );
111  } else {
112  m_stringValues->push_back(iValue);
113  }
114  return *this;
115 }
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 51 of file FWConfiguration.cc.

References swap(), and groupFilesInBlocks::temp.

Referenced by FWConfiguration().

52 {
53  //An exception safe implementation is
54  FWConfiguration temp(rhs);
55  swap(temp);
56 
57  return *this;
58 }
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 214 of file FWConfiguration.cc.

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

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

215 {
216  static int recursionLevel = -1;
217  recursionLevel += 1;
218  std::string indentation(recursionLevel, ' ');
219  oTo << indentation << "<config name=\"" << name
220  << "\" version=\"" << iConfig.version() << "\">\n";
221  if(iConfig.stringValues()) {
222  for(FWConfiguration::StringValues::const_iterator it = iConfig.stringValues()->begin();
223  it != iConfig.stringValues()->end();
224  ++it) {
225  oTo << indentation << " <string>" << attrEscape(*it) << "</string>\n";
226  }
227  }
228  if(iConfig.keyValues()) {
229  for(FWConfiguration::KeyValues::const_iterator it = iConfig.keyValues()->begin();
230  it != iConfig.keyValues()->end();
231  ++it) {
232  FWConfiguration::streamTo(oTo, it->second, attrEscape(it->first));
233  }
234  }
235  oTo << indentation << "</config>" << std::endl;
236  recursionLevel -= 1;
237 }
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 61 of file FWConfiguration.h.

References addKeyValue(), addValue(), m_stringValues, dataset::name, streamTo(), AlCaHLTBitMon_QueryRunRegistry::string, and swap().

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

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

Definition at line 118 of file FWConfiguration.cc.

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

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

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

Definition at line 129 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(), Types.int32::insertInto(), Types.uint32::insertInto(), Types.int64::insertInto(), Types.uint64::insertInto(), Types.double::insertInto(), Mixins.UsingBlock::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(), CmsAnnotation::setFrom(), FWEventAnnotation::setFrom(), FWLegoViewBase::setFrom(), FWRPZView::setFrom(), FW3DViewBase::setFrom(), CmsShowCommon::setFrom(), FWTriggerTableView::setFrom(), FWTableView::setFrom(), CmsShowNavigator::setFrom(), FWGUIManager::setFrom(), FWEveView::setFromOrthoCamera(), FWEveView::setFromPerspectiveCamera(), CmsShowCommon::setGeomTransparency(), FWGeometryTableViewBase::setTopNodePathFromConfig(), and FWGUIManager::setWindowInfoFrom().

130 {
131  if( not m_stringValues ) {
132  throw std::runtime_error("no string values set");
133  }
134  return m_stringValues->at(iIndex);
135 }
boost::scoped_ptr< std::vector< std::string > > m_stringValues
const FWConfiguration * FWConfiguration::valueForKey ( const std::string &  iKey) const

Definition at line 138 of file FWConfiguration.cc.

References plotBeamSpotDB::first, m_keyValues, m_stringValues, and AlCaHLTBitMon_QueryRunRegistry::string.

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

139 {
140  if( m_stringValues ) {
141  throw std::runtime_error("valueFoKey fails because configuration containing string values");
142  }
143  if(not m_keyValues) {
144  throw std::runtime_error("valueForKey fails becuase no key/values set");
145  }
146  KeyValues::iterator itFind = std::find_if(m_keyValues->begin(),
147  m_keyValues->end(),
148  boost::bind(&std::pair<std::string,FWConfiguration>::first,_1) == iKey);
149  if(itFind == m_keyValues->end()) {
150  return 0;
151  }
152  return &(itFind->second);
153 }
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 80 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 79 of file FWConfiguration.h.

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

unsigned int FWConfiguration::m_version
private

Definition at line 81 of file FWConfiguration.h.

Referenced by swap(), and version().