File indexing completed on 2024-04-06 12:05:26
0001 #include "DetectorDescription/Core/interface/DDSpecifics.h"
0002
0003 #include <ostream>
0004
0005 #include "DetectorDescription/Core/interface/DDExpandedView.h"
0006 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0007 #include "DetectorDescription/Core/interface/Specific.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include "FWCore/Utilities/interface/Exception.h"
0010
0011 using DDI::Specific;
0012
0013 DDSpecifics::DDSpecifics() : DDBase<DDName, std::unique_ptr<Specific>>() {}
0014
0015 DDSpecifics::DDSpecifics(const DDName& name) : DDBase<DDName, std::unique_ptr<Specific>>() { create(name); }
0016
0017 DDSpecifics::DDSpecifics(const DDName& name,
0018 const std::vector<std::string>& partSelections,
0019 const DDsvalues_type& svalues,
0020 bool doRegex)
0021 : DDBase<DDName, std::unique_ptr<Specific>>() {
0022 create(name, std::make_unique<Specific>(partSelections, svalues, doRegex));
0023 std::vector<std::pair<DDLogicalPart, std::pair<const DDPartSelection*, const DDsvalues_type*>>> v;
0024 rep().updateLogicalPart(v);
0025 for (auto& it : v) {
0026 if (it.first.isDefined().second) {
0027 it.first.addSpecifics(it.second);
0028 } else {
0029 throw cms::Exception("DDException") << "Definition of LogicalPart missing! name=" << it.first.ddname().fullname();
0030 }
0031 }
0032 }
0033
0034 const std::vector<DDPartSelection>& DDSpecifics::selection() const { return rep().selection(); }
0035
0036 const DDsvalues_type& DDSpecifics::specifics() const { return rep().specifics(); }
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 std::pair<bool, DDExpandedView> DDSpecifics::node() const { return rep().node(); }
0047
0048 std::ostream& operator<<(std::ostream& os, const DDSpecifics& sp) {
0049 DDBase<DDName, std::unique_ptr<DDI::Specific>>::def_type defined(sp.isDefined());
0050 if (defined.first) {
0051 os << *(defined.first) << " ";
0052 if (defined.second) {
0053 sp.rep().stream(os);
0054 } else {
0055 os << "* specific not defined * ";
0056 }
0057 } else {
0058 os << "* specific not declared * ";
0059 }
0060 return os;
0061 }
0062
0063 std::ostream& operator<<(std::ostream& os, const std::vector<std::string>& v) {
0064 for (const auto& it : v) {
0065 os << it << std::endl;
0066 }
0067 return os;
0068 }