CMS 3D CMS Logo

Public Member Functions | Public Attributes | Private Member Functions | Private Attributes

FWModelChangeManager Class Reference

#include <Fireworks/Core/interface/FWModelChangeManager.h>

List of all members.

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 36 of file FWModelChangeManager.cc.

                                           :
   m_depth(0)
{
}
FWModelChangeManager::~FWModelChangeManager ( ) [virtual]

Definition at line 46 of file FWModelChangeManager.cc.

{
}
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().

{
   ++m_depth;
}
void FWModelChangeManager::changed ( const FWModelId iID)
void FWModelChangeManager::changed ( const FWEventItem iItem)

Definition at line 81 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 100 of file FWModelChangeManager.cc.

References benchmark_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 201 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 184 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]

Member Data Documentation

Definition at line 52 of file FWModelChangeManager.h.

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

Definition at line 65 of file FWModelChangeManager.h.

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

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().

Definition at line 66 of file FWModelChangeManager.h.

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

Definition at line 68 of file FWModelChangeManager.h.

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