File indexing completed on 2024-04-06 12:11:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "Fireworks/Core/interface/FWTypeToRepresentations.h"
0017 #include "Fireworks/Core/interface/FWRepresentationCheckerBase.h"
0018
0019
0020
0021
0022 typedef std::map<std::string, std::vector<FWRepresentationInfo> > TypeToReps;
0023
0024
0025
0026
0027
0028
0029
0030
0031 FWTypeToRepresentations::FWTypeToRepresentations() {}
0032
0033
0034
0035
0036
0037
0038 FWTypeToRepresentations::~FWTypeToRepresentations() {}
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 void FWTypeToRepresentations::add(std::shared_ptr<FWRepresentationCheckerBase> iChecker) {
0056 m_checkers.push_back(iChecker);
0057 if (!m_typeToReps.empty()) {
0058
0059 for (TypeToReps::iterator it = m_typeToReps.begin(), itEnd = m_typeToReps.end(); it != itEnd; ++it) {
0060 FWRepresentationInfo info = iChecker->infoFor(it->first);
0061 if (info.isValid()) {
0062
0063 it->second.push_back(info);
0064 }
0065 }
0066 }
0067 }
0068 void FWTypeToRepresentations::insert(const FWTypeToRepresentations& iOther) {
0069 m_typeToReps.clear();
0070 for (std::vector<std::shared_ptr<FWRepresentationCheckerBase> >::const_iterator it = iOther.m_checkers.begin(),
0071 itEnd = iOther.m_checkers.end();
0072 it != itEnd;
0073 ++it) {
0074 m_checkers.push_back(*it);
0075 }
0076 }
0077
0078
0079
0080
0081 const std::vector<FWRepresentationInfo>& FWTypeToRepresentations::representationsForType(
0082 const std::string& iTypeName) const {
0083 TypeToReps::const_iterator itFound = m_typeToReps.find(iTypeName);
0084 if (itFound == m_typeToReps.end()) {
0085 std::vector<FWRepresentationInfo> reps;
0086
0087 for (std::vector<std::shared_ptr<FWRepresentationCheckerBase> >::const_iterator it = m_checkers.begin(),
0088 itEnd = m_checkers.end();
0089 it != itEnd;
0090 ++it) {
0091 FWRepresentationInfo info = (*it)->infoFor(iTypeName);
0092 if (info.isValid())
0093 reps.push_back(info);
0094 }
0095
0096 m_typeToReps.insert(std::make_pair(iTypeName, reps));
0097 itFound = m_typeToReps.find(iTypeName);
0098 }
0099
0100 return itFound->second;
0101 }
0102
0103
0104
0105