CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
FWEventItemsManager Class Reference

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

Inheritance diagram for FWEventItemsManager:
FWConfigurable

Public Types

typedef std::vector
< FWEventItem * >
::const_iterator 
const_iterator
 

Public Member Functions

const FWEventItemadd (const FWPhysicsObjectDesc &iItem, const FWConfiguration *pbConf=0)
 
void addTo (FWConfiguration &) const
 
const_iterator begin () const
 NOTE: iterator is allowed to return a null object for items that have been removed. More...
 
void clearItems ()
 
const_iterator end () const
 
const FWEventItemfind (const std::string &iName) const
 
 FWEventItemsManager (FWModelChangeManager *)
 
void newEvent (const edm::EventBase *iEvent)
 
void setContext (fireworks::Context *)
 
void setFrom (const FWConfiguration &)
 
virtual ~FWEventItemsManager ()
 
- Public Member Functions inherited from FWConfigurable
 FWConfigurable ()
 
virtual ~FWConfigurable ()
 

Public Attributes

sigc::signal< void > goingToClearItems_
 
sigc::signal< void, FWEventItem * > newItem_
 

Private Member Functions

 FWEventItemsManager (const FWEventItemsManager &)
 
const FWEventItemsManageroperator= (const FWEventItemsManager &)
 
void removeItem (const FWEventItem *)
 

Private Attributes

boost::shared_ptr
< FWItemAccessorFactory
m_accessorFactory
 
FWModelChangeManagerm_changeManager
 
fireworks::Contextm_context
 
const edm::EventBasem_event
 
std::vector< FWEventItem * > m_items
 

Detailed Description

Description: Manages multiple FWEventItems

Usage: <usage>

Definition at line 45 of file FWEventItemsManager.h.

Member Typedef Documentation

Definition at line 52 of file FWEventItemsManager.h.

Constructor & Destructor Documentation

FWEventItemsManager::FWEventItemsManager ( FWModelChangeManager iManager)

Definition at line 42 of file FWEventItemsManager.cc.

42  :
43  m_changeManager(iManager),
44  m_context(0),
45  m_event(0),
47 {
48 }
FWModelChangeManager * m_changeManager
boost::shared_ptr< FWItemAccessorFactory > m_accessorFactory
const edm::EventBase * m_event
fireworks::Context * m_context
FWEventItemsManager::~FWEventItemsManager ( )
virtual

FWEventItemsManager has ownership of the items it contains.

Note that because of the way we keep track of removed items, m_items[i] could actually be 0 for indices corresponding to removed items.

Definition at line 61 of file FWEventItemsManager.cc.

References alignCSCRings::e, i, and m_items.

62 {
63  for (size_t i = 0, e = m_items.size(); i != e; ++i)
64  delete m_items[i];
65 
66  m_items.clear();
67 }
int i
Definition: DBlmapReader.cc:9
std::vector< FWEventItem * > m_items
FWEventItemsManager::FWEventItemsManager ( const FWEventItemsManager )
private

Member Function Documentation

const FWEventItem * FWEventItemsManager::add ( const FWPhysicsObjectDesc iItem,
const FWConfiguration pbConf = 0 
)

Definition at line 85 of file FWEventItemsManager.cc.

References FWDisplayProperties::color(), FWColorManager::colorHasIndex(), fireworks::Context::colorManager(), FWPhysicsObjectDesc::displayProperties(), fwLog, FWColorManager::getDefaultStartColorIndex(), fwlog::kWarning, m_accessorFactory, m_changeManager, m_context, m_event, m_items, newItem_, removeItem(), FWPhysicsObjectDesc::setDisplayProperties(), groupFilesInBlocks::temp, and FWPhysicsObjectDesc::type().

Referenced by FWGUIEventDataAdder::addNewItem(), and setFrom().

86 {
88 
89  if(! m_context->colorManager()->colorHasIndex(temp.displayProperties().color())) {
90  FWDisplayProperties prop(temp.displayProperties());
91  fwLog(fwlog::kWarning) << Form("FWEventItemsManager::add(const FWPhysicsObjectDesc& iItem), color index not valid. Set Color idex to %d\n", FWColorManager::getDefaultStartColorIndex());
93  temp.setDisplayProperties(prop);
94  }
95 
96  m_items.push_back(new FWEventItem(m_context,m_items.size(),m_accessorFactory->accessorFor(temp.type()),
97  temp, pbc));
98  newItem_(m_items.back());
99  m_items.back()->goingToBeDestroyed_.connect(boost::bind(&FWEventItemsManager::removeItem,this,_1));
100  if(m_event) {
102  m_items.back()->setEvent(m_event);
103  }
104  return m_items.back();
105 }
FWModelChangeManager * m_changeManager
void removeItem(const FWEventItem *)
boost::shared_ptr< FWItemAccessorFactory > m_accessorFactory
FWColorManager * colorManager() const
Definition: Context.h:66
static Color_t getDefaultStartColorIndex()
bool colorHasIndex(Color_t) const
sigc::signal< void, FWEventItem * > newItem_
const edm::EventBase * m_event
#define fwLog(_level_)
Definition: fwLog.h:51
fireworks::Context * m_context
std::vector< FWEventItem * > m_items
void FWEventItemsManager::addTo ( FWConfiguration iTo) const
virtual

Implements FWConfigurable.

Definition at line 158 of file FWEventItemsManager.cc.

References FWConfiguration::addKeyValue(), fireworks::Context::colorManager(), dbtoconf::conf, dtTPAnalyzer_cfg::dataType, kColor(), kFalse(), kFilterExpression(), kIsVisible(), kLayer(), kModuleLabel(), kProcessName(), kProductInstanceLabel(), kPurpose(), kTransparency(), kTrue(), kType(), m_context, and m_items.

159 {
161  assert(0!=cm);
162  for(std::vector<FWEventItem*>::const_iterator it = m_items.begin();
163  it != m_items.end();
164  ++it)
165  {
166  if(!*it) continue;
168  edm::TypeWithDict dataType((*((*it)->type()->GetTypeInfo())));
169  assert(dataType != edm::TypeWithDict() );
170 
171  conf.addKeyValue(kType,FWConfiguration(dataType.name()));
172  conf.addKeyValue(kModuleLabel,FWConfiguration((*it)->moduleLabel()));
173  conf.addKeyValue(kProductInstanceLabel, FWConfiguration((*it)->productInstanceLabel()));
174  conf.addKeyValue(kProcessName, FWConfiguration((*it)->processName()));
175  conf.addKeyValue(kFilterExpression, FWConfiguration((*it)->filterExpression()));
176  {
177  std::ostringstream os;
178  os << (*it)->defaultDisplayProperties().color();
179  conf.addKeyValue(kColor, FWConfiguration(os.str()));
180  }
181  conf.addKeyValue(kIsVisible, FWConfiguration((*it)->defaultDisplayProperties().isVisible() ? kTrue : kFalse));
182  {
183  std::ostringstream os;
184  os << (*it)->layer();
185  conf.addKeyValue(kLayer,FWConfiguration(os.str()));
186  }
187  conf.addKeyValue(kPurpose,(*it)->purpose());
188  {
189  std::ostringstream os;
190  os << static_cast<int>((*it)->defaultDisplayProperties().transparency());
191  conf.addKeyValue(kTransparency, FWConfiguration(os.str()));
192  }
193 
194  FWConfiguration pbTmp;
195  (*it)->getConfig()->addTo(pbTmp);
196  conf.addKeyValue("PBConfig",pbTmp, true);
197 
198  iTo.addKeyValue((*it)->name(), conf, true);
199  }
200 }
static const std::string kModuleLabel("moduleLabel")
FWColorManager * colorManager() const
Definition: Context.h:66
static const std::string kTrue("t")
static const std::string kType("type")
static const std::string kColor("color")
static const std::string kProductInstanceLabel("productInstanceLabel")
static const std::string kFilterExpression("filterExpression")
static const std::string kProcessName("processName")
static const std::string kFalse("f")
static const std::string kLayer("layer")
tuple conf
Definition: dbtoconf.py:185
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
static const std::string kTransparency("transparency")
static const std::string kIsVisible("isVisible")
static const std::string kPurpose("purpose")
fireworks::Context * m_context
std::vector< FWEventItem * > m_items
FWEventItemsManager::const_iterator FWEventItemsManager::begin ( void  ) const

NOTE: iterator is allowed to return a null object for items that have been removed.

Definition at line 322 of file FWEventItemsManager.cc.

References m_items.

Referenced by FWGUIEventDataAdder::addNewItem(), FWEventItem::isInBack(), FWEventItem::isInFront(), FWEventItem::moveToBack(), FWEventItem::moveToFront(), FWFileEntry::runFilter(), and CmsShowMain::setupDataHandling().

323 {
324  return m_items.begin();
325 }
std::vector< FWEventItem * > m_items
void FWEventItemsManager::clearItems ( void  )

Clear all the items in the model.

Notice that a previous implementation was setting all the items to 0, I guess to track accessing delete items.

Definition at line 129 of file FWEventItemsManager.cc.

References FWEventItem::destroy(), alignCSCRings::e, goingToClearItems_, i, and m_items.

Referenced by setFrom().

130 {
131  for (size_t i = 0, e = m_items.size(); i != e; ++i)
132  {
133  FWEventItem *item = m_items[i];
134  if (item) {
135  item->destroy();
136  }
137  m_items[i]=0;
138  }
140 
141  m_items.clear();
142 }
int i
Definition: DBlmapReader.cc:9
void destroy() const
Definition: FWEventItem.cc:609
std::vector< FWEventItem * > m_items
sigc::signal< void > goingToClearItems_
FWEventItemsManager::const_iterator FWEventItemsManager::end ( void  ) const
const FWEventItem * FWEventItemsManager::find ( const std::string &  iName) const

Look up an item by name.

Definition at line 335 of file FWEventItemsManager.cc.

References alignCSCRings::e, i, m_items, and FWEventItem::name().

Referenced by BeautifulSoup.Tag::_invert(), FWGUIEventDataAdder::addNewItem(), and BeautifulSoup.PageElement::insert().

336 {
337  for (size_t i = 0, e = m_items.size(); i != e; ++i)
338  {
339  const FWEventItem *item = m_items[i];
340  if (item && item->name() == iName)
341  return item;
342  }
343  return 0;
344 }
int i
Definition: DBlmapReader.cc:9
const std::string & name() const
Definition: FWEventItem.cc:501
std::vector< FWEventItem * > m_items
void FWEventItemsManager::newEvent ( const edm::EventBase iEvent)

Prepare to handle a new event by associating all the items to watch it.

Definition at line 111 of file FWEventItemsManager.cc.

References alignCSCRings::e, i, iEvent, m_changeManager, m_event, m_items, and FWEventItem::setEvent().

112 {
114  m_event = iEvent;
115  for(size_t i = 0, e = m_items.size(); i != e; ++i)
116  {
117  FWEventItem *item = m_items[i];
118  if(item)
119  item->setEvent(iEvent);
120  }
121 }
FWModelChangeManager * m_changeManager
int i
Definition: DBlmapReader.cc:9
void setEvent(const edm::EventBase *iEvent)
Definition: FWEventItem.cc:121
int iEvent
Definition: GenABIO.cc:243
const edm::EventBase * m_event
std::vector< FWEventItem * > m_items
const FWEventItemsManager& FWEventItemsManager::operator= ( const FWEventItemsManager )
private
void FWEventItemsManager::removeItem ( const FWEventItem iItem)
private

Remove one item.

Notice that rather than erasing the item from the list, it is preferred to set it to zero, I guess to catch accesses to remove items and to avoid having to recalculate the current selection.

GE: I think this is a broken way of handling removal of objects. The object should be properly deleted and the current selection should be updated accordingly.

Definition at line 306 of file FWEventItemsManager.cc.

References FWEventItem::id(), and m_items.

Referenced by add().

307 {
308  assert(iItem->id() < m_items.size());
309  m_items[iItem->id()] = 0;
310 }
unsigned int id() const
Definition: FWEventItem.cc:495
std::vector< FWEventItem * > m_items
void FWEventItemsManager::setContext ( fireworks::Context iContext)

Definition at line 313 of file FWEventItemsManager.cc.

References m_context.

Referenced by CmsShowMain::CmsShowMain(), FWFFLooper::FWFFLooper(), and FWFFService::FWFFService().

314 {
315  m_context = iContext;
316 }
fireworks::Context * m_context
void FWEventItemsManager::setFrom ( const FWConfiguration iFrom)
virtual

This is responsible for resetting the status of items from configuration

Implements FWConfigurable.

Definition at line 205 of file FWEventItemsManager.cc.

References add(), FWConfiguration::addKeyValue(), clearItems(), create_public_lumi_plots::color, fireworks::Context::colorManager(), dbtoconf::conf, reco::dp, FWConfiguration::keyValues(), kTrue(), m_context, mergeVDriftHistosByStation::name, FWColorManager::oldColorToIndex(), edm::second(), AlCaHLTBitMon_QueryRunRegistry::string, FWConfiguration::valueForKey(), and FWConfiguration::version().

206 {
207 
209  assert(0!=cm);
210 
211  clearItems();
212  const FWConfiguration::KeyValues* keyValues = iFrom.keyValues();
213 
214  if (keyValues == 0) return;
215 
216  for (FWConfiguration::KeyValues::const_iterator it = keyValues->begin();
217  it != keyValues->end();
218  ++it)
219  {
220  const std::string& name = it->first;
221  const FWConfiguration& conf = it->second;
222  const FWConfiguration::KeyValues* keyValues = conf.keyValues();
223  assert(0!=keyValues);
224  const std::string& type = (*keyValues)[0].second.value();
225  const std::string& moduleLabel = (*keyValues)[1].second.value();
226  const std::string& productInstanceLabel = (*keyValues)[2].second.value();
227  const std::string& processName = (*keyValues)[3].second.value();
228  const std::string& filterExpression = (*keyValues)[4].second.value();
229  const std::string& sColor = (*keyValues)[5].second.value();
230  const bool isVisible = (*keyValues)[6].second.value() == kTrue;
231 
232  unsigned int colorIndex;
233  if(conf.version() < 5)
234  {
235  std::istringstream is(sColor);
236  Color_t color;
237  is >> color;
238  colorIndex = cm->oldColorToIndex(color, conf.version());
239  }
240  else
241  {
242  // In version 4 we assume:
243  // fireworks colors start at ROOT index 1000
244  // geometry colors start at ROOT index 1100
245  // We save them as such -- no conversions needed.
246  std::istringstream is(sColor);
247  is >> colorIndex;
248  }
249 
250  int transparency = 0;
251 
252  // Read transparency from file. We don't care about checking errors
253  // because strtol returns 0 in that case.
254  if (conf.version() > 3)
255  transparency = strtol((*keyValues)[9].second.value().c_str(), 0, 10);
256 
257  FWDisplayProperties dp(colorIndex, isVisible, transparency);
258 
259  unsigned int layer = strtol((*keyValues)[7].second.value().c_str(), 0, 10);
260 
261  //For older configs assume name is the same as purpose
262  std::string purpose(name);
263  if (conf.version() > 1)
264  purpose = (*keyValues)[8].second.value();
265 
266  FWConfiguration* proxyConfig = (FWConfiguration*) conf.valueForKey("PBConfig") ? new FWConfiguration(*conf.valueForKey("PBConfig")) : 0;
267 
268  // beckward compatibilty for obsolete proxy builders
269  if (conf.version() < 6)
270  {
271  assert(proxyConfig == 0);
272  if (purpose == "VerticesWithTracks")
273  {
274  purpose = "Vertices";
275  proxyConfig = new FWConfiguration();
276  FWConfiguration vTmp; vTmp.addKeyValue("Draw Tracks", FWConfiguration("1"));
277  proxyConfig->addKeyValue("Var", vTmp,true);
278  }
279  }
280 
281  FWPhysicsObjectDesc desc(name,
282  TClass::GetClass(type.c_str()),
283  purpose,
284  dp,
285  moduleLabel,
286  productInstanceLabel,
287  processName,
288  filterExpression,
289  layer);
290 
291  add(desc, proxyConfig );
292  }
293 }
type
Definition: HCALResponse.h:21
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
const KeyValues * keyValues() const
FWColorManager * colorManager() const
Definition: Context.h:66
static const std::string kTrue("t")
unsigned int version() const
Color_t oldColorToIndex(Color_t, int version) const
U second(std::pair< T, U > const &p)
tuple conf
Definition: dbtoconf.py:185
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
auto dp
Definition: deltaR.h:24
const FWEventItem * add(const FWPhysicsObjectDesc &iItem, const FWConfiguration *pbConf=0)
fireworks::Context * m_context
const FWConfiguration * valueForKey(const std::string &iKey) const

Member Data Documentation

sigc::signal<void> FWEventItemsManager::goingToClearItems_
boost::shared_ptr<FWItemAccessorFactory> FWEventItemsManager::m_accessorFactory
private

Definition at line 90 of file FWEventItemsManager.h.

Referenced by add().

FWModelChangeManager* FWEventItemsManager::m_changeManager
private

Definition at line 86 of file FWEventItemsManager.h.

Referenced by add(), and newEvent().

fireworks::Context* FWEventItemsManager::m_context
private

Definition at line 87 of file FWEventItemsManager.h.

Referenced by add(), addTo(), setContext(), and setFrom().

const edm::EventBase* FWEventItemsManager::m_event
private

Definition at line 89 of file FWEventItemsManager.h.

Referenced by add(), and newEvent().

std::vector<FWEventItem*> FWEventItemsManager::m_items
private
sigc::signal<void, FWEventItem*> FWEventItemsManager::newItem_