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)
 
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 40 of file FWEventItemsManager.cc.

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

References ExpressReco_HICollisions_FallBack::e, i, and m_items.

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

Definition at line 83 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(), cond::rpcobtemp::temp, and FWPhysicsObjectDesc::type().

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

84 {
86 
87  if(! m_context->colorManager()->colorHasIndex(temp.displayProperties().color())) {
88  FWDisplayProperties prop(temp.displayProperties());
89  fwLog(fwlog::kWarning) << Form("FWEventItemsManager::add(const FWPhysicsObjectDesc& iItem), color index not valid. Set Color idex to %d\n", FWColorManager::getDefaultStartColorIndex());
91  temp.setDisplayProperties(prop);
92  }
93 
94  m_items.push_back(new FWEventItem(m_context,m_items.size(),m_accessorFactory->accessorFor(temp.type()),
95  temp) );
96  newItem_(m_items.back());
97  m_items.back()->goingToBeDestroyed_.connect(boost::bind(&FWEventItemsManager::removeItem,this,_1));
98  if(m_event) {
100  m_items.back()->setEvent(m_event);
101  }
102  return m_items.back();
103 }
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 156 of file FWEventItemsManager.cc.

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

157 {
159  assert(0!=cm);
160  for(std::vector<FWEventItem*>::const_iterator it = m_items.begin();
161  it != m_items.end();
162  ++it)
163  {
164  if(!*it) continue;
166  ROOT::Reflex::Type dataType( ROOT::Reflex::Type::ByTypeInfo(*((*it)->type()->GetTypeInfo())));
167  assert(dataType != ROOT::Reflex::Type() );
168 
169  conf.addKeyValue(kType,FWConfiguration(dataType.Name(ROOT::Reflex::SCOPED)));
170  conf.addKeyValue(kModuleLabel,FWConfiguration((*it)->moduleLabel()));
171  conf.addKeyValue(kProductInstanceLabel, FWConfiguration((*it)->productInstanceLabel()));
172  conf.addKeyValue(kProcessName, FWConfiguration((*it)->processName()));
173  conf.addKeyValue(kFilterExpression, FWConfiguration((*it)->filterExpression()));
174  {
175  std::ostringstream os;
176  os << (*it)->defaultDisplayProperties().color();
177  conf.addKeyValue(kColor, FWConfiguration(os.str()));
178  }
179  conf.addKeyValue(kIsVisible, FWConfiguration((*it)->defaultDisplayProperties().isVisible() ? kTrue : kFalse));
180  {
181  std::ostringstream os;
182  os << (*it)->layer();
183  conf.addKeyValue(kLayer,FWConfiguration(os.str()));
184  }
185  conf.addKeyValue(kPurpose,(*it)->purpose());
186  {
187  std::ostringstream os;
188  os << static_cast<int>((*it)->defaultDisplayProperties().transparency());
189  conf.addKeyValue(kTransparency, FWConfiguration(os.str()));
190  }
191  iTo.addKeyValue((*it)->name(), conf, true);
192  }
193 }
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 297 of file FWEventItemsManager.cc.

References m_items.

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

298 {
299  return m_items.begin();
300 }
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 127 of file FWEventItemsManager.cc.

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

Referenced by setFrom().

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

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

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

311 {
312  for (size_t i = 0, e = m_items.size(); i != e; ++i)
313  {
314  const FWEventItem *item = m_items[i];
315  if (item && item->name() == iName)
316  return item;
317  }
318  return 0;
319 }
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 109 of file FWEventItemsManager.cc.

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

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

References FWEventItem::id(), and m_items.

Referenced by add().

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

Definition at line 288 of file FWEventItemsManager.cc.

References m_context.

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

289 {
290  m_context = iContext;
291 }
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 198 of file FWEventItemsManager.cc.

References add(), clearItems(), fireworks::Context::colorManager(), dbtoconf::conf, FWConfiguration::keyValues(), kTrue(), m_context, moduleLabel(), AlCaRecoCosmics_cfg::name, FWColorManager::oldColorToIndex(), edm::second(), and FWConfiguration::version().

199 {
200 
202  assert(0!=cm);
203 
204  clearItems();
205  const FWConfiguration::KeyValues* keyValues = iFrom.keyValues();
206  assert(0!=keyValues);
207  for (FWConfiguration::KeyValues::const_iterator it = keyValues->begin();
208  it != keyValues->end();
209  ++it)
210  {
211  const std::string& name = it->first;
212  const FWConfiguration& conf = it->second;
213  const FWConfiguration::KeyValues* keyValues = conf.keyValues();
214  assert(0!=keyValues);
215  const std::string& type = (*keyValues)[0].second.value();
216  const std::string& moduleLabel = (*keyValues)[1].second.value();
217  const std::string& productInstanceLabel = (*keyValues)[2].second.value();
218  const std::string& processName = (*keyValues)[3].second.value();
219  const std::string& filterExpression = (*keyValues)[4].second.value();
220  const std::string& sColor = (*keyValues)[5].second.value();
221  const bool isVisible = (*keyValues)[6].second.value() == kTrue;
222 
223  unsigned int colorIndex;
224  if(conf.version() < 5)
225  {
226  std::istringstream is(sColor);
227  Color_t color;
228  is >> color;
229  colorIndex = cm->oldColorToIndex(color, conf.version());
230  }
231  else
232  {
233  // In version 4 we assume:
234  // fireworks colors start at ROOT index 1000
235  // geometry colors start at ROOT index 1100
236  // We save them as such -- no conversions needed.
237  std::istringstream is(sColor);
238  is >> colorIndex;
239  }
240 
241  int transparency = 0;
242 
243  // Read transparency from file. We don't care about checking errors
244  // because strtol returns 0 in that case.
245  if (conf.version() > 3)
246  transparency = strtol((*keyValues)[9].second.value().c_str(), 0, 10);
247 
248  FWDisplayProperties dp(colorIndex, isVisible, transparency);
249 
250  unsigned int layer = strtol((*keyValues)[7].second.value().c_str(), 0, 10);
251 
252  //For older configs assume name is the same as purpose
253  std::string purpose(name);
254  if (conf.version() > 1)
255  purpose = (*keyValues)[8].second.value();
256 
257  FWPhysicsObjectDesc desc(name,
258  TClass::GetClass(type.c_str()),
259  purpose,
260  dp,
261  moduleLabel,
262  productInstanceLabel,
263  processName,
264  filterExpression,
265  layer);
266  add(desc);
267  }
268 }
type
Definition: HCALResponse.h:22
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
const FWEventItem * add(const FWPhysicsObjectDesc &iItem)
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
fireworks::Context * m_context
const std::string * moduleLabel() const
Definition: HLTadd.h:40

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_