CMS 3D CMS Logo

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 FWEventItem *)
 
void changed (const FWModelId &)
 
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 &)=delete
 
const FWModelChangeManageroperator= (const FWModelChangeManager &)=delete
 

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() [1/2]

FWModelChangeManager::FWModelChangeManager ( )

Definition at line 35 of file FWModelChangeManager.cc.

35 : m_depth(0) {}

◆ ~FWModelChangeManager()

FWModelChangeManager::~FWModelChangeManager ( )
virtual

Definition at line 42 of file FWModelChangeManager.cc.

42 {}

◆ FWModelChangeManager() [2/2]

FWModelChangeManager::FWModelChangeManager ( const FWModelChangeManager )
privatedelete

Member Function Documentation

◆ beginChanges()

void FWModelChangeManager::beginChanges ( )

Definition at line 59 of file FWModelChangeManager.cc.

59 { ++m_depth; }

References m_depth.

Referenced by FWChangeSentry::FWChangeSentry().

◆ changed() [1/2]

void FWModelChangeManager::changed ( const FWEventItem iItem)

Definition at line 68 of file FWModelChangeManager.cc.

68  {
69  FWChangeSentry sentry(*this);
70  assert(nullptr != iItem);
71  m_itemChanges.insert(iItem);
72  //remove any pending changes on models owned by this item
73  assert(iItem->id() < m_changes.size());
74  m_changes[iItem->id()].clear();
75 }

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

◆ changed() [2/2]

void FWModelChangeManager::changed ( const FWModelId iID)

◆ endChanges()

void FWModelChangeManager::endChanges ( )

Definition at line 83 of file FWModelChangeManager.cc.

83  {
84  assert(m_depth != 0);
85  //makes sure that 'changeSignalsAreDone is called if changeSignalsAreComing_ is sent
86  bool guard(false);
87  if (0 == --m_depth) {
88  unsigned int index = 0;
89  for (std::set<const FWEventItem*>::iterator itChanges = m_itemChanges.begin(); itChanges != m_itemChanges.end();
90  ++itChanges, ++index) {
91  if (!guard) {
92  // std::shared_ptr<FWModelChangeManager> done(this, &sendChangeSignalsAreDone);
93  guard = true;
95  }
96  FWItemChangeSignal& signal = m_itemChangeSignals[(*itChanges)->id()];
97  //loop over the slots ourself so we can control the behavior in case of a failure
98  FWItemChangeSignal::slot_list_type slots = signal.slots();
99  for (FWItemChangeSignal::slot_list_type::iterator itSlot = slots.begin(), itEnd = slots.end(); itSlot != itEnd;
100  ++itSlot) {
101  try {
102  (*itSlot)(*itChanges);
103  } catch (const cms::Exception& iE) {
104  fwLog(fwlog::kError) << (*itChanges)->name() << " had the failure in process FWItemChanged signals\n"
105  << iE.what() << std::endl;
106  } catch (const std::bad_alloc& iE) {
107  std::cerr << "Ran out of memory while processing " << (*itChanges)->name() << std::endl;
108  exit(1);
109  } catch (const std::exception& iE) {
110  fwLog(fwlog::kError) << (*itChanges)->name() << " had the failure in process FWItemChanged signals (2) \n"
111  << iE.what() << std::endl;
112  }
113  }
114  }
115  m_itemChanges.clear();
116 
117  for (size_t ci = 0, ce = m_changes.size(), si = 0; ci != ce; ++ci, ++si) {
118  FWModelIds& changes = m_changes[ci];
119  FWModelChangeSignal& signal = m_changeSignals[si];
120 
121  if (not changes.empty()) {
122  if (!guard) {
123  // std::shared_ptr<FWModelChangeManager> done(this, &sendChangeSignalsAreDone);
124  guard = true;
126  }
127  //loop over the slots ourself so we can control the behavior in case of a failure
128  FWModelChangeSignal::slot_list_type slots = signal.slots();
129  for (FWModelChangeSignal::slot_list_type::iterator itSlot = slots.begin(), itEnd = slots.end(); itSlot != itEnd;
130  ++itSlot) {
131  try {
132  (*itSlot)(changes);
133  } catch (const cms::Exception& iE) {
134  fwLog(fwlog::kError) << changes.begin()->item()->name()
135  << " had the failure in process FWModelChangeSignals\n"
136  << iE.what() << "\n";
137  } catch (const std::bad_alloc& iE) {
138  // GE: if we run out of memory why do we assume that we will be able to print?
139  fwLog(fwlog::kError) << "Ran out of memory while processing " << changes.begin()->item()->name() << "\n";
140  exit(1);
141  } catch (const std::exception& iE) {
142  fwLog(fwlog::kError) << changes.begin()->item()->name()
143  << " had the failure in process FWModelChangeSignals (2)\n"
144  << iE.what() << "\n";
145  }
146  }
147  changes.clear();
148  }
149  }
150  }
151  if (guard)
153 }

References cms::cuda::assert(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, changeSignalsAreComing_, cppFunctionSkipper::exception, beamvalidation::exit(), fwLog, fwlog::kError, m_changes, m_changeSignals, m_depth, m_itemChanges, m_itemChangeSignals, sendChangeSignalsAreDone(), and cms::Exception::what().

Referenced by FWChangeSentry::~FWChangeSentry().

◆ itemsGoingToBeClearedSlot()

void FWModelChangeManager::itemsGoingToBeClearedSlot ( void  )

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

Definition at line 170 of file FWModelChangeManager.cc.

170  {
171  m_changes.clear();
172  m_changeSignals.clear();
173 
174  m_itemChangeSignals.clear();
175  m_itemChanges.clear();
176 }

References m_changes, m_changeSignals, m_itemChanges, and m_itemChangeSignals.

Referenced by FWSummaryManager::FWSummaryManager().

◆ newItemSlot()

void FWModelChangeManager::newItemSlot ( FWEventItem iItem)

Definition at line 155 of file FWModelChangeManager.cc.

155  {
156  assert(nullptr != iItem);
157  assert(iItem->id() == m_changes.size());
158  assert(iItem->id() == m_changeSignals.size());
159  m_changes.push_back(FWModelIds());
162  //propagate our signal to the item
163  m_changeSignals.back().connect(iItem->changed_);
164  m_itemChangeSignals.back().connect(iItem->itemChanged_);
165 }

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

Referenced by CmsShowMainBase::setup().

◆ operator=()

const FWModelChangeManager& FWModelChangeManager::operator= ( const FWModelChangeManager )
privatedelete

Member Data Documentation

◆ changeSignalsAreComing_

sigc::signal<void> FWModelChangeManager::changeSignalsAreComing_

Definition at line 49 of file FWModelChangeManager.h.

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

◆ changeSignalsAreDone_

sigc::signal<void> FWModelChangeManager::changeSignalsAreDone_

◆ m_changes

std::vector<FWModelIds> FWModelChangeManager::m_changes
private

Definition at line 62 of file FWModelChangeManager.h.

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

◆ m_changeSignals

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

Definition at line 64 of file FWModelChangeManager.h.

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

◆ m_depth

unsigned int FWModelChangeManager::m_depth
private

Definition at line 61 of file FWModelChangeManager.h.

Referenced by beginChanges(), and endChanges().

◆ m_itemChanges

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

Definition at line 63 of file FWModelChangeManager.h.

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

◆ m_itemChangeSignals

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

Definition at line 65 of file FWModelChangeManager.h.

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

fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
FWModelChangeManager::m_changeSignals
std::vector< FWModelChangeSignal > m_changeSignals
Definition: FWModelChangeManager.h:64
cms::cuda::assert
assert(be >=bs)
FWModelChangeManager::m_changes
std::vector< FWModelIds > m_changes
Definition: FWModelChangeManager.h:62
FWEventItem::id
unsigned int id() const
Definition: FWEventItem.cc:433
FWModelId::item
const FWEventItem * item() const
Definition: FWModelId.h:39
FWModelChangeManager::m_itemChanges
std::set< const FWEventItem * > m_itemChanges
Definition: FWModelChangeManager.h:63
cms::Exception::what
char const * what() const noexcept override
Definition: Exception.cc:103
FWItemChangeSignal
FWChangeSentry
Definition: FWModelChangeManager.h:68
FWModelChangeManager::changeSignalsAreComing_
sigc::signal< void > changeSignalsAreComing_
Definition: FWModelChangeManager.h:49
FWModelChangeSignal
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
FWEventItem::itemChanged_
FWItemChangeSignal itemChanged_
Definition: FWEventItem.h:181
FWModelChangeSignal
sigc::signal< void, const FWModelIds & > FWModelChangeSignal
Definition: FWModelChangeSignal.h:31
FWModelChangeManager::m_depth
unsigned int m_depth
Definition: FWModelChangeManager.h:61
sendChangeSignalsAreDone
static void sendChangeSignalsAreDone(FWModelChangeManager *iCM)
Definition: FWModelChangeManager.cc:77
FWModelChangeManager::m_itemChangeSignals
std::vector< FWItemChangeSignal > m_itemChangeSignals
Definition: FWModelChangeManager.h:65
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
fwlog::kError
Definition: fwLog.h:35
FWItemChangeSignal
sigc::signal< void, const FWEventItem * > FWItemChangeSignal
Definition: FWItemChangeSignal.h:29
cms::Exception
Definition: Exception.h:70
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
FWModelIds
std::set< FWModelId > FWModelIds
Definition: FWEveViewManager.h:40
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
FWEventItem::changed_
FWModelChangeSignal changed_
Definition: FWEventItem.h:178