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, bool showFilteredInTable=true, 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 44 of file FWEventItemsManager.h.

Member Typedef Documentation

Definition at line 51 of file FWEventItemsManager.h.

Constructor & Destructor Documentation

FWEventItemsManager::FWEventItemsManager ( FWModelChangeManager iManager)

Definition at line 41 of file FWEventItemsManager.cc.

41  :
42  m_changeManager(iManager),
43  m_context(0),
44  m_event(0),
46 {
47 }
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 60 of file FWEventItemsManager.cc.

References alignCSCRings::e, i, and m_items.

61 {
62  for (size_t i = 0, e = m_items.size(); i != e; ++i)
63  delete m_items[i];
64 
65  m_items.clear();
66 }
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,
bool  showFilteredInTable = true,
const FWConfiguration pbConf = 0 
)

Definition at line 84 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(), counter.Counter::register(), and setFrom().

85 {
87 
88  if(! m_context->colorManager()->colorHasIndex(temp.displayProperties().color())) {
89  FWDisplayProperties prop(temp.displayProperties());
90  fwLog(fwlog::kWarning) << Form("FWEventItemsManager::add(const FWPhysicsObjectDesc& iItem), color index not valid. Set Color idex to %d\n", FWColorManager::getDefaultStartColorIndex());
92  temp.setDisplayProperties(prop);
93  }
94 
95  m_items.push_back(new FWEventItem(m_context,m_items.size(),m_accessorFactory->accessorFor(temp.type()),
96  temp, showFilteredInTable, pbc));
97  newItem_(m_items.back());
98  m_items.back()->goingToBeDestroyed_.connect(boost::bind(&FWEventItemsManager::removeItem,this,_1));
99  if(m_event) {
101  m_items.back()->setEvent(m_event);
102  }
103  return m_items.back();
104 }
FWModelChangeManager * m_changeManager
void removeItem(const FWEventItem *)
boost::shared_ptr< FWItemAccessorFactory > m_accessorFactory
FWColorManager * colorManager() const
Definition: Context.h:65
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:50
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(), assert(), fireworks::Context::colorManager(), dbtoconf::conf, dtTPAnalyzer_cfg::dataType, kColor(), kFalse(), kFilterExpression(), kIsVisible(), kLayer(), kModuleLabel(), kProcessName(), kProductInstanceLabel(), kPurpose(), kShowFilteredEntriesInTable(), 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())));
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  conf.addKeyValue(kShowFilteredEntriesInTable, FWConfiguration((*it)->showFilteredEntries() ? kTrue : kFalse));
195 
196  FWConfiguration pbTmp;
197  (*it)->getConfig()->addTo(pbTmp);
198  conf.addKeyValue("PBConfig",pbTmp, true);
199 
200  iTo.addKeyValue((*it)->name(), conf, true);
201  }
202 }
static const std::string kModuleLabel("moduleLabel")
FWColorManager * colorManager() const
Definition: Context.h:65
assert(m_qm.get())
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")
static const std::string kShowFilteredEntriesInTable("showFilteredEntriesInTable")
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 329 of file FWEventItemsManager.cc.

References m_items.

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

330 {
331  return m_items.begin();
332 }
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 128 of file FWEventItemsManager.cc.

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

Referenced by FWPartialConfigLoadGUI::Load(), and setFrom().

129 {
130  for (size_t i = 0, e = m_items.size(); i != e; ++i)
131  {
132  FWEventItem *item = m_items[i];
133  if (item) {
134  item->destroy();
135  }
136  m_items[i]=0;
137  }
139 
140  m_items.clear();
141 }
int i
Definition: DBlmapReader.cc:9
void destroy() const
Definition: FWEventItem.cc:622
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 342 of file FWEventItemsManager.cc.

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

Referenced by FWGUIEventDataAdder::addNewItem().

343 {
344  for (size_t i = 0, e = m_items.size(); i != e; ++i)
345  {
346  const FWEventItem *item = m_items[i];
347  if (item && item->name() == iName)
348  return item;
349  }
350  return 0;
351 }
int i
Definition: DBlmapReader.cc:9
const std::string & name() const
Definition: FWEventItem.cc:513
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 110 of file FWEventItemsManager.cc.

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

111 {
113  m_event = iEvent;
114  for(size_t i = 0, e = m_items.size(); i != e; ++i)
115  {
116  FWEventItem *item = m_items[i];
117  if(item)
118  item->setEvent(iEvent);
119  }
120 }
FWModelChangeManager * m_changeManager
int i
Definition: DBlmapReader.cc:9
void setEvent(const edm::EventBase *iEvent)
Definition: FWEventItem.cc:121
int iEvent
Definition: GenABIO.cc:230
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 313 of file FWEventItemsManager.cc.

References assert(), FWEventItem::id(), and m_items.

Referenced by add().

314 {
315  assert(iItem->id() < m_items.size());
316  m_items[iItem->id()] = 0;
317 }
assert(m_qm.get())
unsigned int id() const
Definition: FWEventItem.cc:507
std::vector< FWEventItem * > m_items
void FWEventItemsManager::setContext ( fireworks::Context iContext)

Definition at line 320 of file FWEventItemsManager.cc.

References m_context.

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

321 {
322  m_context = iContext;
323 }
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 207 of file FWEventItemsManager.cc.

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

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

Member Data Documentation

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

Definition at line 89 of file FWEventItemsManager.h.

Referenced by add().

FWModelChangeManager* FWEventItemsManager::m_changeManager
private

Definition at line 85 of file FWEventItemsManager.h.

Referenced by add(), and newEvent().

fireworks::Context* FWEventItemsManager::m_context
private

Definition at line 86 of file FWEventItemsManager.h.

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

const edm::EventBase* FWEventItemsManager::m_event
private

Definition at line 88 of file FWEventItemsManager.h.

Referenced by add(), and newEvent().

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