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 <boost/bind.hpp>
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  FWColorManager* iColorM) :
37  m_changeManager(iCM),
38  m_colorManager(iColorM)
39 {
40 }
41 
42 // FWViewManagerManager::FWViewManagerManager(const FWViewManagerManager& rhs)
43 // {
44 // // do actual copying here;
45 // }
46 
48 {
49 }
50 
51 //
52 // assignment operators
53 //
54 // const FWViewManagerManager& FWViewManagerManager::operator=(const FWViewManagerManager& rhs)
55 // {
56 // //An exception safe implementation is
57 // FWViewManagerManager temp(rhs);
58 // swap(rhs);
59 //
60 // return *this;
61 // }
62 
63 //
64 // member functions
65 //
66 void
67 FWViewManagerManager::add( std::shared_ptr<FWViewManagerBase> iManager)
68 {
69  m_viewManagers.push_back(iManager);
70  iManager->setChangeManager(m_changeManager);
71  iManager->setColorManager(m_colorManager);
72 
73  for(std::map<std::string,const FWEventItem*>::iterator it=m_typeToItems.begin(), itEnd=m_typeToItems.end();
74  it != itEnd;
75  ++it) {
76  iManager->newItem(it->second);
77  }
78 }
79 
80 void
82 {
83  if ( m_typeToItems.find(iItem->name()) != m_typeToItems.end() ) {
84  fwLog(fwlog::kWarning) << "WARNING: item "<< iItem->name() <<" was already registered. Request ignored.\n";
85  return;
86  }
87  m_typeToItems[iItem->name()]=iItem;
88  iItem->goingToBeDestroyed_.connect(boost::bind(&FWViewManagerManager::removeEventItem,this,_1));
89 
90  //std::map<std::string, std::vector<std::string> >::iterator itFind = m_typeToBuilders.find(iItem->name());
91  for(std::vector<std::shared_ptr<FWViewManagerBase> >::iterator itVM = m_viewManagers.begin();
92  itVM != m_viewManagers.end();
93  ++itVM) {
94  (*itVM)->newItem(iItem);
95  }
96 }
97 
98 void
100 {
101  std::map<std::string, const FWEventItem*>::iterator itr =
102  m_typeToItems.find(iItem->name());
103  if ( itr != m_typeToItems.end() ) m_typeToItems.erase( itr );
104 }
105 
106 
107 //
108 // const member functions
109 //
112 {
113  FWTypeToRepresentations returnValue;
114  for(std::vector<std::shared_ptr<FWViewManagerBase> >::const_iterator itVM = m_viewManagers.begin();
115  itVM != m_viewManagers.end();
116  ++itVM) {
117  FWTypeToRepresentations v = (*itVM)->supportedTypesAndRepresentations();
118  returnValue.insert(v);
119  }
120  return returnValue;
121 }
122 
123 void
125 {
126  for (auto i = m_viewManagers.begin(); i != m_viewManagers.end(); ++i)
127  (*i)->eventBegin();
128 }
129 
130 void
132 {
133  for (auto i = m_viewManagers.begin(); i != m_viewManagers.end(); ++i)
134  (*i)->eventEnd();
135 }
136 
137 //
138 // static member functions
139 //
void registerEventItem(const FWEventItem *iItem)
void removeEventItem(const FWEventItem *iItem)
const std::string & name() const
Definition: FWEventItem.cc:502
FWItemChangeSignal goingToBeDestroyed_
Definition: FWEventItem.h:219
void insert(const FWTypeToRepresentations &)
FWTypeToRepresentations supportedTypesAndRepresentations() const
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:50
FWColorManager * m_colorManager