Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:20

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWViewManagerManager
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Tue Jan 15 10:27:12 EST 2008
0011 //
0012 
0013 // system include files
0014 #include <iostream>
0015 #include <functional>
0016 
0017 // user include files
0018 #include "Fireworks/Core/interface/FWViewManagerManager.h"
0019 #include "Fireworks/Core/interface/FWViewManagerBase.h"
0020 #include "Fireworks/Core/interface/FWEventItem.h"
0021 #include "Fireworks/Core/interface/fwLog.h"
0022 #include "Fireworks/Core/interface/FWTypeToRepresentations.h"
0023 
0024 //
0025 // constants, enums and typedefs
0026 //
0027 
0028 //
0029 // static data member definitions
0030 //
0031 
0032 //
0033 // constructors and destructor
0034 //
0035 FWViewManagerManager::FWViewManagerManager(FWModelChangeManager* iCM, FWColorManager* iColorM)
0036     : m_changeManager(iCM), m_colorManager(iColorM) {}
0037 
0038 // FWViewManagerManager::FWViewManagerManager(const FWViewManagerManager& rhs)
0039 // {
0040 //    // do actual copying here;
0041 // }
0042 
0043 FWViewManagerManager::~FWViewManagerManager() {}
0044 
0045 //
0046 // assignment operators
0047 //
0048 // const FWViewManagerManager& FWViewManagerManager::operator=(const FWViewManagerManager& rhs)
0049 // {
0050 //   //An exception safe implementation is
0051 //   FWViewManagerManager temp(rhs);
0052 //   swap(rhs);
0053 //
0054 //   return *this;
0055 // }
0056 
0057 //
0058 // member functions
0059 //
0060 void FWViewManagerManager::add(std::shared_ptr<FWViewManagerBase> iManager) {
0061   m_viewManagers.push_back(iManager);
0062   iManager->setChangeManager(m_changeManager);
0063   iManager->setColorManager(m_colorManager);
0064 
0065   for (std::map<std::string, const FWEventItem*>::iterator it = m_typeToItems.begin(), itEnd = m_typeToItems.end();
0066        it != itEnd;
0067        ++it) {
0068     iManager->newItem(it->second);
0069   }
0070 }
0071 
0072 void FWViewManagerManager::registerEventItem(const FWEventItem* iItem) {
0073   if (m_typeToItems.find(iItem->name()) != m_typeToItems.end()) {
0074     fwLog(fwlog::kWarning) << "WARNING: item " << iItem->name() << " was already registered. Request ignored.\n";
0075     return;
0076   }
0077   m_typeToItems[iItem->name()] = iItem;
0078   iItem->goingToBeDestroyed_.connect(std::bind(&FWViewManagerManager::removeEventItem, this, std::placeholders::_1));
0079 
0080   //std::map<std::string, std::vector<std::string> >::iterator itFind = m_typeToBuilders.find(iItem->name());
0081   for (std::vector<std::shared_ptr<FWViewManagerBase> >::iterator itVM = m_viewManagers.begin();
0082        itVM != m_viewManagers.end();
0083        ++itVM) {
0084     (*itVM)->newItem(iItem);
0085   }
0086 }
0087 
0088 void FWViewManagerManager::removeEventItem(const FWEventItem* iItem) {
0089   std::map<std::string, const FWEventItem*>::iterator itr = m_typeToItems.find(iItem->name());
0090   if (itr != m_typeToItems.end())
0091     m_typeToItems.erase(itr);
0092 }
0093 
0094 //
0095 // const member functions
0096 //
0097 FWTypeToRepresentations FWViewManagerManager::supportedTypesAndRepresentations() const {
0098   FWTypeToRepresentations returnValue;
0099   for (std::vector<std::shared_ptr<FWViewManagerBase> >::const_iterator itVM = m_viewManagers.begin();
0100        itVM != m_viewManagers.end();
0101        ++itVM) {
0102     FWTypeToRepresentations v = (*itVM)->supportedTypesAndRepresentations();
0103     returnValue.insert(v);
0104   }
0105   return returnValue;
0106 }
0107 
0108 void FWViewManagerManager::eventBegin() {
0109   for (auto i = m_viewManagers.begin(); i != m_viewManagers.end(); ++i)
0110     (*i)->eventBegin();
0111 }
0112 
0113 void FWViewManagerManager::eventEnd() {
0114   for (auto i = m_viewManagers.begin(); i != m_viewManagers.end(); ++i)
0115     (*i)->eventEnd();
0116 }
0117 
0118 //
0119 // static member functions
0120 //