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