#include <Fireworks/Core/interface/FWModelChangeManager.h>
Public Member Functions | |
void | beginChanges () |
void | changed (const FWModelId &) |
void | changed (const FWEventItem *) |
void | endChanges () |
FWModelChangeManager () | |
void | itemsGoingToBeClearedSlot (void) |
void | newItemSlot (FWEventItem *) |
virtual | ~FWModelChangeManager () |
Public Attributes | |
sigc::signal< void > | changeSignalsAreComing_ |
sigc::signal< void > | changeSignalsAreDone_ |
Private Member Functions | |
FWModelChangeManager (const FWModelChangeManager &) | |
const FWModelChangeManager & | operator= (const FWModelChangeManager &) |
Private Attributes | |
std::vector< FWModelIds > | m_changes |
std::vector< FWModelChangeSignal > | m_changeSignals |
unsigned int | m_depth |
std::set< const FWEventItem * > | m_itemChanges |
std::vector< FWItemChangeSignal > | m_itemChangeSignals |
Description: Manages propagating announcements of changes to Models to any interested party
Usage: <usage>
Definition at line 34 of file FWModelChangeManager.h.
FWModelChangeManager::FWModelChangeManager | ( | ) |
Definition at line 37 of file FWModelChangeManager.cc.
: m_depth(0) { }
FWModelChangeManager::~FWModelChangeManager | ( | ) | [virtual] |
Definition at line 47 of file FWModelChangeManager.cc.
{ }
FWModelChangeManager::FWModelChangeManager | ( | const FWModelChangeManager & | ) | [private] |
void FWModelChangeManager::beginChanges | ( | ) |
Definition at line 67 of file FWModelChangeManager.cc.
References m_depth.
Referenced by FWChangeSentry::FWChangeSentry().
{ ++m_depth; }
void FWModelChangeManager::changed | ( | const FWModelId & | iID | ) |
Definition at line 73 of file FWModelChangeManager.cc.
References FWEventItem::id(), FWModelId::item(), and m_changes.
Referenced by FWEventItem::destroy(), FWEventItem::handleChange(), FWEventItem::runFilter(), FWEventItem::select(), FWEventItem::setDefaultDisplayProperties(), FWEventItem::setDisplayProperties(), FWEventItem::toggleSelect(), and FWEventItem::unselect().
void FWModelChangeManager::changed | ( | const FWEventItem * | iItem | ) |
Definition at line 82 of file FWModelChangeManager.cc.
References FWEventItem::id(), m_changes, and m_itemChanges.
{ FWChangeSentry sentry(*this); assert(0!= iItem); m_itemChanges.insert(iItem); //remove any pending changes on models owned by this item assert(iItem->id() <m_changes.size()); m_changes[iItem->id()].clear(); }
void FWModelChangeManager::endChanges | ( | ) |
Definition at line 101 of file FWModelChangeManager.cc.
References dtNoiseDBValidation_cfg::cerr, changeSignalsAreComing_, exception, cmsRelvalreport::exit, fwLog, getHLTprescales::index, fwlog::kError, m_changes, m_changeSignals, m_depth, m_itemChanges, m_itemChangeSignals, sendChangeSignalsAreDone(), and cms::Exception::what().
Referenced by FWChangeSentry::~FWChangeSentry().
{ assert(m_depth !=0); //makes sure that 'changeSignalsAreDone is called if changeSignalsAreComing_ is sent bool guard(false); if(0 == --m_depth) { unsigned int index = 0; for(std::set<const FWEventItem*>::iterator itChanges = m_itemChanges.begin(); itChanges != m_itemChanges.end(); ++itChanges,++index) { if( !guard ) { // boost::shared_ptr<FWModelChangeManager> done(this, &sendChangeSignalsAreDone); guard = true; changeSignalsAreComing_(); } FWItemChangeSignal& signal = m_itemChangeSignals[(*itChanges)->id()]; //loop over the slots ourself so we can control the behavior in case of a failure FWItemChangeSignal::slot_list_type slots = signal.slots(); for(FWItemChangeSignal::slot_list_type::iterator itSlot=slots.begin(), itEnd = slots.end(); itSlot != itEnd; ++itSlot) { try { (*itSlot)(*itChanges); } catch(const cms::Exception& iE) { fwLog(fwlog::kError) <<(*itChanges)->name()<<" had the failure in process FWItemChanged signals\n"<<iE.what()<<std::endl; } catch(const std::bad_alloc& iE) { std::cerr <<"Ran out of memory while processing "<<(*itChanges)->name()<<std::endl; exit(1); } catch(const std::exception& iE) { fwLog(fwlog::kError) <<(*itChanges)->name()<<" had the failure in process FWItemChanged signals (2) \n"<<iE.what()<<std::endl; } } } m_itemChanges.clear(); for (size_t ci = 0, ce = m_changes.size(), si = 0; ci != ce; ++ci, ++si) { FWModelIds &changes = m_changes[ci]; FWModelChangeSignal &signal = m_changeSignals[si]; if (not changes.empty()) { if (!guard) { // boost::shared_ptr<FWModelChangeManager> done(this, &sendChangeSignalsAreDone); guard = true; changeSignalsAreComing_(); } //loop over the slots ourself so we can control the behavior in case of a failure FWModelChangeSignal::slot_list_type slots = signal.slots(); for(FWModelChangeSignal::slot_list_type::iterator itSlot = slots.begin(), itEnd = slots.end(); itSlot != itEnd; ++itSlot) { try { (*itSlot)(changes); } catch(const cms::Exception& iE) { fwLog(fwlog::kError) << changes.begin()->item()->name()<<" had the failure in process FWModelChangeSignals\n" << iE.what() << "\n"; } catch(const std::bad_alloc& iE) { // GE: if we run out of memory why do we assume that we will be able to print? fwLog(fwlog::kError) << "Ran out of memory while processing " << changes.begin()->item()->name() << "\n"; exit(1); } catch(const std::exception& iE) { fwLog(fwlog::kError) << changes.begin()->item()->name() << " had the failure in process FWModelChangeSignals (2)\n" << iE.what() << "\n"; } } changes.clear(); } } } if (guard) sendChangeSignalsAreDone(this); }
void FWModelChangeManager::itemsGoingToBeClearedSlot | ( | void | ) |
Whenever all the items are removed from the FWItemsManager clean also the associated vectors here.
Definition at line 202 of file FWModelChangeManager.cc.
References m_changes, m_changeSignals, m_itemChanges, and m_itemChangeSignals.
Referenced by FWSummaryManager::FWSummaryManager().
{ m_changes.clear(); m_changeSignals.clear(); m_itemChangeSignals.clear(); m_itemChanges.clear(); }
void FWModelChangeManager::newItemSlot | ( | FWEventItem * | iItem | ) |
Definition at line 185 of file FWModelChangeManager.cc.
References FWEventItem::changed_, FWEventItem::id(), FWEventItem::itemChanged_, m_changes, m_changeSignals, and m_itemChangeSignals.
Referenced by CmsShowMainBase::setup().
{ assert(0!=iItem); assert(iItem->id() == m_changes.size()); assert(iItem->id() == m_changeSignals.size()); m_changes.push_back(FWModelIds()); m_changeSignals.push_back(FWModelChangeSignal()); m_itemChangeSignals.push_back(FWItemChangeSignal()); //propagate our signal to the item m_changeSignals.back().connect(iItem->changed_); m_itemChangeSignals.back().connect(iItem->itemChanged_); }
const FWModelChangeManager& FWModelChangeManager::operator= | ( | const FWModelChangeManager & | ) | [private] |
sigc::signal<void> FWModelChangeManager::changeSignalsAreComing_ |
Definition at line 52 of file FWModelChangeManager.h.
Referenced by endChanges(), and FWViewManagerBase::setChangeManager().
sigc::signal<void> FWModelChangeManager::changeSignalsAreDone_ |
Definition at line 53 of file FWModelChangeManager.h.
Referenced by FWSelectionManager::FWSelectionManager(), FWSummaryManager::FWSummaryManager(), sendChangeSignalsAreDone(), and FWViewManagerBase::setChangeManager().
std::vector<FWModelIds> FWModelChangeManager::m_changes [private] |
Definition at line 65 of file FWModelChangeManager.h.
Referenced by changed(), endChanges(), itemsGoingToBeClearedSlot(), and newItemSlot().
std::vector<FWModelChangeSignal> FWModelChangeManager::m_changeSignals [private] |
Definition at line 67 of file FWModelChangeManager.h.
Referenced by endChanges(), itemsGoingToBeClearedSlot(), and newItemSlot().
unsigned int FWModelChangeManager::m_depth [private] |
Definition at line 64 of file FWModelChangeManager.h.
Referenced by beginChanges(), and endChanges().
std::set<const FWEventItem*> FWModelChangeManager::m_itemChanges [private] |
Definition at line 66 of file FWModelChangeManager.h.
Referenced by changed(), endChanges(), and itemsGoingToBeClearedSlot().
std::vector<FWItemChangeSignal> FWModelChangeManager::m_itemChangeSignals [private] |
Definition at line 68 of file FWModelChangeManager.h.
Referenced by endChanges(), itemsGoingToBeClearedSlot(), and newItemSlot().