CMS 3D CMS Logo

FWViewManagerManager.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWViewManagerManager
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Jan 15 10:27:12 EST 2008
11 //
12 
13 // system include files
14 #include <iostream>
15 #include <functional>
16 
17 // user include files
23 
24 //
25 // constants, enums and typedefs
26 //
27 
28 //
29 // static data member definitions
30 //
31 
32 //
33 // constructors and destructor
34 //
36  : m_changeManager(iCM), m_colorManager(iColorM) {}
37 
38 // FWViewManagerManager::FWViewManagerManager(const FWViewManagerManager& rhs)
39 // {
40 // // do actual copying here;
41 // }
42 
44 
45 //
46 // assignment operators
47 //
48 // const FWViewManagerManager& FWViewManagerManager::operator=(const FWViewManagerManager& rhs)
49 // {
50 // //An exception safe implementation is
51 // FWViewManagerManager temp(rhs);
52 // swap(rhs);
53 //
54 // return *this;
55 // }
56 
57 //
58 // member functions
59 //
60 void FWViewManagerManager::add(std::shared_ptr<FWViewManagerBase> iManager) {
61  m_viewManagers.push_back(iManager);
62  iManager->setChangeManager(m_changeManager);
63  iManager->setColorManager(m_colorManager);
64 
65  for (std::map<std::string, const FWEventItem*>::iterator it = m_typeToItems.begin(), itEnd = m_typeToItems.end();
66  it != itEnd;
67  ++it) {
68  iManager->newItem(it->second);
69  }
70 }
71 
73  if (m_typeToItems.find(iItem->name()) != m_typeToItems.end()) {
74  fwLog(fwlog::kWarning) << "WARNING: item " << iItem->name() << " was already registered. Request ignored.\n";
75  return;
76  }
77  m_typeToItems[iItem->name()] = iItem;
78  iItem->goingToBeDestroyed_.connect(std::bind(&FWViewManagerManager::removeEventItem, this, std::placeholders::_1));
79 
80  //std::map<std::string, std::vector<std::string> >::iterator itFind = m_typeToBuilders.find(iItem->name());
81  for (std::vector<std::shared_ptr<FWViewManagerBase> >::iterator itVM = m_viewManagers.begin();
82  itVM != m_viewManagers.end();
83  ++itVM) {
84  (*itVM)->newItem(iItem);
85  }
86 }
87 
89  std::map<std::string, const FWEventItem*>::iterator itr = m_typeToItems.find(iItem->name());
90  if (itr != m_typeToItems.end())
91  m_typeToItems.erase(itr);
92 }
93 
94 //
95 // const member functions
96 //
98  FWTypeToRepresentations returnValue;
99  for (std::vector<std::shared_ptr<FWViewManagerBase> >::const_iterator itVM = m_viewManagers.begin();
100  itVM != m_viewManagers.end();
101  ++itVM) {
102  FWTypeToRepresentations v = (*itVM)->supportedTypesAndRepresentations();
103  returnValue.insert(v);
104  }
105  return returnValue;
106 }
107 
109  for (auto i = m_viewManagers.begin(); i != m_viewManagers.end(); ++i)
110  (*i)->eventBegin();
111 }
112 
114  for (auto i = m_viewManagers.begin(); i != m_viewManagers.end(); ++i)
115  (*i)->eventEnd();
116 }
117 
118 //
119 // static member functions
120 //
void registerEventItem(const FWEventItem *iItem)
void removeEventItem(const FWEventItem *iItem)
FWTypeToRepresentations supportedTypesAndRepresentations() const
FWItemChangeSignal goingToBeDestroyed_
Definition: FWEventItem.h:197
void insert(const FWTypeToRepresentations &)
FWModelChangeManager * m_changeManager
FWViewManagerManager(FWModelChangeManager *, FWColorManager *)
std::map< std::string, const FWEventItem * > m_typeToItems
std::vector< std::shared_ptr< FWViewManagerBase > > m_viewManagers
void add(std::shared_ptr< FWViewManagerBase >)
#define fwLog(_level_)
Definition: fwLog.h:45
const std::string & name() const
Definition: FWEventItem.cc:435
FWColorManager * m_colorManager