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 34 of file FWModelChangeManager.h.

Constructor & Destructor Documentation

FWModelChangeManager::FWModelChangeManager ( )

Definition at line 37 of file FWModelChangeManager.cc.

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

Definition at line 47 of file FWModelChangeManager.cc.

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

Member Function Documentation

void FWModelChangeManager::beginChanges ( )

Definition at line 67 of file FWModelChangeManager.cc.

References m_depth.

Referenced by FWChangeSentry::FWChangeSentry().

68 {
69  ++m_depth;
70 }
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().

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

Definition at line 82 of file FWModelChangeManager.cc.

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

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

Definition at line 101 of file FWModelChangeManager.cc.

References dtNoiseDBValidation_cfg::cerr, changeSignalsAreComing_, cppFunctionSkipper::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().

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

References m_changes, m_changeSignals, m_itemChanges, and m_itemChangeSignals.

Referenced by FWSummaryManager::FWSummaryManager().

203 {
204  m_changes.clear();
205  m_changeSignals.clear();
206 
207  m_itemChangeSignals.clear();
208  m_itemChanges.clear();
209 }
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 185 of file FWModelChangeManager.cc.

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

Referenced by CmsShowMainBase::setup().

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

Member Data Documentation

sigc::signal<void> FWModelChangeManager::changeSignalsAreComing_

Definition at line 52 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 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().