CMS 3D CMS Logo

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

#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 FWModelChangeManageroperator= (const FWModelChangeManager &)
 

Private Attributes

std::vector< FWModelIdsm_changes
 
std::vector< FWModelChangeSignalm_changeSignals
 
unsigned int m_depth
 
std::set< const FWEventItem * > m_itemChanges
 
std::vector< FWItemChangeSignalm_itemChangeSignals
 

Detailed Description

Description: Manages propagating announcements of changes to Models to any interested party

Usage: <usage>

Definition at line 33 of file FWModelChangeManager.h.

Constructor & Destructor Documentation

FWModelChangeManager::FWModelChangeManager ( )

Definition at line 36 of file FWModelChangeManager.cc.

36  :
37  m_depth(0)
38 {
39 }
FWModelChangeManager::~FWModelChangeManager ( )
virtual

Definition at line 46 of file FWModelChangeManager.cc.

47 {
48 }
FWModelChangeManager::FWModelChangeManager ( const FWModelChangeManager )
private

Member Function Documentation

void FWModelChangeManager::beginChanges ( )

Definition at line 66 of file FWModelChangeManager.cc.

References m_depth.

Referenced by FWChangeSentry::FWChangeSentry().

67 {
68  ++m_depth;
69 }
void FWModelChangeManager::changed ( const FWModelId iID)

Definition at line 72 of file FWModelChangeManager.cc.

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

73 {
74  FWChangeSentry sentry(*this);
75  assert(iID.item());
76  assert(iID.item()->id() < m_changes.size());
77  m_changes[iID.item()->id()].insert(iID);
78 }
assert(m_qm.get())
std::vector< FWModelIds > m_changes
unsigned int id() const
Definition: FWEventItem.cc:494
const FWEventItem * item() const
Definition: FWModelId.h:44
void FWModelChangeManager::changed ( const FWEventItem iItem)

Definition at line 81 of file FWModelChangeManager.cc.

References assert(), FWEventItem::id(), m_changes, and m_itemChanges.

82 {
83  FWChangeSentry sentry(*this);
84  assert(0!= iItem);
85  m_itemChanges.insert(iItem);
86  //remove any pending changes on models owned by this item
87  assert(iItem->id() <m_changes.size());
88  m_changes[iItem->id()].clear();
89 }
assert(m_qm.get())
std::vector< FWModelIds > m_changes
std::set< const FWEventItem * > m_itemChanges
unsigned int id() const
Definition: FWEventItem.cc:494
void FWModelChangeManager::endChanges ( )

Definition at line 100 of file FWModelChangeManager.cc.

References assert(), dtNoiseDBValidation_cfg::cerr, changeSignalsAreComing_, cppFunctionSkipper::exception, cmsRelvalreport::exit, fwLog, cmsHarvester::index, fwlog::kError, m_changes, m_changeSignals, m_depth, m_itemChanges, m_itemChangeSignals, sendChangeSignalsAreDone(), and cms::Exception::what().

Referenced by FWChangeSentry::~FWChangeSentry().

101 {
102  assert(m_depth !=0);
103  //makes sure that 'changeSignalsAreDone is called if changeSignalsAreComing_ is sent
104  bool guard(false);
105  if(0 == --m_depth) {
106  unsigned int index = 0;
107  for(std::set<const FWEventItem*>::iterator itChanges = m_itemChanges.begin();
108  itChanges != m_itemChanges.end();
109  ++itChanges,++index) {
110  if( !guard ) {
111  // boost::shared_ptr<FWModelChangeManager> done(this, &sendChangeSignalsAreDone);
112  guard = true;
114  }
115  FWItemChangeSignal& signal = m_itemChangeSignals[(*itChanges)->id()];
116  //loop over the slots ourself so we can control the behavior in case of a failure
117  FWItemChangeSignal::slot_list_type slots = signal.slots();
118  for(FWItemChangeSignal::slot_list_type::iterator itSlot=slots.begin(), itEnd = slots.end();
119  itSlot != itEnd;
120  ++itSlot) {
121  try {
122  (*itSlot)(*itChanges);
123  } catch(const cms::Exception& iE) {
124  fwLog(fwlog::kError) <<(*itChanges)->name()<<" had the failure in process FWItemChanged signals\n"<<iE.what()<<std::endl;
125  } catch(const std::bad_alloc& iE) {
126  std::cerr <<"Ran out of memory while processing "<<(*itChanges)->name()<<std::endl;
127  exit(1);
128  } catch(const std::exception& iE) {
129  fwLog(fwlog::kError) <<(*itChanges)->name()<<" had the failure in process FWItemChanged signals (2) \n"<<iE.what()<<std::endl;
130  }
131  }
132  }
133  m_itemChanges.clear();
134 
135  for (size_t ci = 0, ce = m_changes.size(), si = 0; ci != ce; ++ci, ++si)
136  {
137  FWModelIds &changes = m_changes[ci];
138  FWModelChangeSignal &signal = m_changeSignals[si];
139 
140  if (not changes.empty())
141  {
142  if (!guard)
143  {
144  // boost::shared_ptr<FWModelChangeManager> done(this, &sendChangeSignalsAreDone);
145  guard = true;
147  }
148  //loop over the slots ourself so we can control the behavior in case of a failure
149  FWModelChangeSignal::slot_list_type slots = signal.slots();
150  for(FWModelChangeSignal::slot_list_type::iterator itSlot = slots.begin(), itEnd = slots.end();
151  itSlot != itEnd;
152  ++itSlot)
153  {
154  try
155  {
156  (*itSlot)(changes);
157  }
158  catch(const cms::Exception& iE)
159  {
160  fwLog(fwlog::kError) << changes.begin()->item()->name()<<" had the failure in process FWModelChangeSignals\n"
161  << iE.what() << "\n";
162  }
163  catch(const std::bad_alloc& iE)
164  {
165  // GE: if we run out of memory why do we assume that we will be able to print?
166  fwLog(fwlog::kError) << "Ran out of memory while processing " << changes.begin()->item()->name() << "\n";
167  exit(1);
168  }
169  catch(const std::exception& iE)
170  {
171  fwLog(fwlog::kError) << changes.begin()->item()->name()
172  << " had the failure in process FWModelChangeSignals (2)\n"
173  << iE.what() << "\n";
174  }
175  }
176  changes.clear();
177  }
178  }
179  }
180  if (guard) sendChangeSignalsAreDone(this);
181 }
virtual char const * what() const
Definition: Exception.cc:141
std::vector< FWModelChangeSignal > m_changeSignals
assert(m_qm.get())
std::vector< FWModelIds > m_changes
static void sendChangeSignalsAreDone(FWModelChangeManager *iCM)
std::set< const FWEventItem * > m_itemChanges
std::set< FWModelId > FWModelIds
#define fwLog(_level_)
Definition: fwLog.h:50
std::vector< FWItemChangeSignal > m_itemChangeSignals
sigc::signal< void > changeSignalsAreComing_
void FWModelChangeManager::itemsGoingToBeClearedSlot ( void  )

Whenever all the items are removed from the FWItemsManager clean also the associated vectors here.

Definition at line 201 of file FWModelChangeManager.cc.

References m_changes, m_changeSignals, m_itemChanges, and m_itemChangeSignals.

Referenced by FWSummaryManager::FWSummaryManager().

202 {
203  m_changes.clear();
204  m_changeSignals.clear();
205 
206  m_itemChangeSignals.clear();
207  m_itemChanges.clear();
208 }
std::vector< FWModelChangeSignal > m_changeSignals
std::vector< FWModelIds > m_changes
std::set< const FWEventItem * > m_itemChanges
std::vector< FWItemChangeSignal > m_itemChangeSignals
void FWModelChangeManager::newItemSlot ( FWEventItem iItem)

Definition at line 184 of file FWModelChangeManager.cc.

References assert(), FWEventItem::changed_, FWEventItem::id(), FWEventItem::itemChanged_, m_changes, m_changeSignals, and m_itemChangeSignals.

Referenced by CmsShowMainBase::setup().

185 {
186  assert(0!=iItem);
187  assert(iItem->id() == m_changes.size());
188  assert(iItem->id() == m_changeSignals.size());
189  m_changes.push_back(FWModelIds());
192  //propagate our signal to the item
193  m_changeSignals.back().connect(iItem->changed_);
194  m_itemChangeSignals.back().connect(iItem->itemChanged_);
195 }
sigc::signal< void, const FWEventItem * > FWItemChangeSignal
sigc::signal< void, const FWModelIds & > FWModelChangeSignal
std::vector< FWModelChangeSignal > m_changeSignals
assert(m_qm.get())
std::vector< FWModelIds > m_changes
std::set< FWModelId > FWModelIds
FWItemChangeSignal itemChanged_
Definition: FWEventItem.h:198
unsigned int id() const
Definition: FWEventItem.cc:494
std::vector< FWItemChangeSignal > m_itemChangeSignals
FWModelChangeSignal changed_
Definition: FWEventItem.h:195
const FWModelChangeManager& FWModelChangeManager::operator= ( const FWModelChangeManager )
private

Member Data Documentation

sigc::signal<void> FWModelChangeManager::changeSignalsAreComing_

Definition at line 51 of file FWModelChangeManager.h.

Referenced by endChanges(), and FWViewManagerBase::setChangeManager().

sigc::signal<void> FWModelChangeManager::changeSignalsAreDone_
std::vector<FWModelIds> FWModelChangeManager::m_changes
private

Definition at line 64 of file FWModelChangeManager.h.

Referenced by changed(), endChanges(), itemsGoingToBeClearedSlot(), and newItemSlot().

std::vector<FWModelChangeSignal> FWModelChangeManager::m_changeSignals
private

Definition at line 66 of file FWModelChangeManager.h.

Referenced by endChanges(), itemsGoingToBeClearedSlot(), and newItemSlot().

unsigned int FWModelChangeManager::m_depth
private

Definition at line 63 of file FWModelChangeManager.h.

Referenced by beginChanges(), and endChanges().

std::set<const FWEventItem*> FWModelChangeManager::m_itemChanges
private

Definition at line 65 of file FWModelChangeManager.h.

Referenced by changed(), endChanges(), and itemsGoingToBeClearedSlot().

std::vector<FWItemChangeSignal> FWModelChangeManager::m_itemChangeSignals
private

Definition at line 67 of file FWModelChangeManager.h.

Referenced by endChanges(), itemsGoingToBeClearedSlot(), and newItemSlot().