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

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

References m_items.

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

322 {
323  return m_items.begin();
324 }
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 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:608
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 334 of file FWEventItemsManager.cc.

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

Referenced by FWGUIEventDataAdder::addNewItem().

335 {
336  for (size_t i = 0, e = m_items.size(); i != e; ++i)
337  {
338  const FWEventItem *item = m_items[i];
339  if (item && item->name() == iName)
340  return item;
341  }
342  return 0;
343 }
int i
Definition: DBlmapReader.cc:9
const std::string & name() const
Definition: FWEventItem.cc:500
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:120
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 305 of file FWEventItemsManager.cc.

References FWEventItem::id(), and m_items.

Referenced by add().

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

Definition at line 312 of file FWEventItemsManager.cc.

References m_context.

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

313 {
314  m_context = iContext;
315 }
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 204 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().

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