CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | 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 ()
 
 FWModelChangeManager (const FWModelChangeManager &)=delete
 
void itemsGoingToBeClearedSlot (void)
 
void newItemSlot (FWEventItem *)
 
const FWModelChangeManageroperator= (const FWModelChangeManager &)=delete
 
virtual ~FWModelChangeManager ()
 

Public Attributes

sigc::signal< void()> changeSignalsAreComing_
 
sigc::signal< void()> changeSignalsAreDone_
 

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 )
delete

Member Function Documentation

◆ beginChanges()

void FWModelChangeManager::beginChanges ( )

Definition at line 59 of file FWModelChangeManager.cc.

References m_depth.

Referenced by FWChangeSentry::FWChangeSentry().

59 { ++m_depth; }

◆ changed() [1/2]

void FWModelChangeManager::changed ( const FWModelId iID)

◆ changed() [2/2]

void FWModelChangeManager::changed ( const FWEventItem iItem)

Definition at line 68 of file FWModelChangeManager.cc.

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

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 }
unsigned int id() const
Definition: FWEventItem.cc:433
std::vector< FWModelIds > m_changes
assert(be >=bs)
std::set< const FWEventItem * > m_itemChanges

◆ endChanges()

void FWModelChangeManager::endChanges ( )

Definition at line 83 of file FWModelChangeManager.cc.

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

Referenced by FWChangeSentry::~FWChangeSentry().

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  try {
97  const FWEventItem* item = (*itChanges);
98  item->itemChanged_.emit(item);
99  } catch (const cms::Exception& iE) {
100  fwLog(fwlog::kError) << (*itChanges)->name() << " had the failure in process FWItemChanged signals\n"
101  << iE.what() << std::endl;
102  } catch (const std::bad_alloc& iE) {
103  std::cerr << "Ran out of memory while processing " << (*itChanges)->name() << std::endl;
104  exit(1);
105  } catch (const std::exception& iE) {
106  fwLog(fwlog::kError) << (*itChanges)->name() << " had the failure in process FWItemChanged signals (2) \n"
107  << iE.what() << std::endl;
108  }
109  }
110  m_itemChanges.clear();
111 
112  for (size_t ci = 0, ce = m_changes.size(), si = 0; ci != ce; ++ci, ++si) {
113  FWModelIds& changes = m_changes[ci];
114  if (not changes.empty()) {
115  if (!guard) {
116  // std::shared_ptr<FWModelChangeManager> done(this, &sendChangeSignalsAreDone);
117  guard = true;
119  try {
120  const FWEventItem* item = changes.begin()->item();
121  item->changed_.emit(changes);
122  } catch (const cms::Exception& iE) {
123  fwLog(fwlog::kError) << changes.begin()->item()->name()
124  << " had the failure in process FWModelChangeSignals\n"
125  << iE.what() << "\n";
126  } catch (const std::bad_alloc& iE) {
127  // GE: if we run out of memory why do we assume that we will be able to print?
128  fwLog(fwlog::kError) << "Ran out of memory while processing " << changes.begin()->item()->name() << "\n";
129  exit(1);
130  } catch (const std::exception& iE) {
131  fwLog(fwlog::kError) << changes.begin()->item()->name()
132  << " had the failure in process FWModelChangeSignals (2)\n"
133  << iE.what() << "\n";
134  }
135  }
136  }
137  changes.clear();
138  }
139  }
140 
141  if (guard)
143 }
std::vector< FWModelIds > m_changes
static void sendChangeSignalsAreDone(FWModelChangeManager *iCM)
assert(be >=bs)
std::set< const FWEventItem * > m_itemChanges
std::set< FWModelId > FWModelIds
#define fwLog(_level_)
Definition: fwLog.h:45
sigc::signal< void()> changeSignalsAreComing_
char const * what() const noexcept override
Definition: Exception.cc:107
def exit(msg="")

◆ itemsGoingToBeClearedSlot()

void FWModelChangeManager::itemsGoingToBeClearedSlot ( void  )

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

Definition at line 160 of file FWModelChangeManager.cc.

References m_changes, m_changeSignals, m_itemChanges, and m_itemChangeSignals.

Referenced by FWSummaryManager::FWSummaryManager().

160  {
161  m_changes.clear();
162  m_changeSignals.clear();
163 
164  m_itemChangeSignals.clear();
165  m_itemChanges.clear();
166 }
std::vector< FWModelChangeSignal > m_changeSignals
std::vector< FWModelIds > m_changes
std::set< const FWEventItem * > m_itemChanges
std::vector< FWItemChangeSignal > m_itemChangeSignals

◆ newItemSlot()

void FWModelChangeManager::newItemSlot ( FWEventItem iItem)

Definition at line 145 of file FWModelChangeManager.cc.

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

Referenced by CmsShowMainBase::setup().

145  {
146  assert(nullptr != iItem);
147  assert(iItem->id() == m_changes.size());
148  assert(iItem->id() == m_changeSignals.size());
149  m_changes.push_back(FWModelIds());
152  //propagate our signal to the item
153  m_changeSignals.back().connect(iItem->changed_);
154  m_itemChangeSignals.back().connect(iItem->itemChanged_);
155 }
std::vector< FWModelChangeSignal > m_changeSignals
unsigned int id() const
Definition: FWEventItem.cc:433
std::vector< FWModelIds > m_changes
assert(be >=bs)
std::set< FWModelId > FWModelIds
sigc::signal< void(const FWModelIds &)> FWModelChangeSignal
FWItemChangeSignal itemChanged_
Definition: FWEventItem.h:181
sigc::signal< void(const FWEventItem *)> FWItemChangeSignal
std::vector< FWItemChangeSignal > m_itemChangeSignals
FWModelChangeSignal changed_
Definition: FWEventItem.h:178

◆ operator=()

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

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 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 itemsGoingToBeClearedSlot(), and newItemSlot().