File indexing completed on 2024-04-06 12:13:03
0001
0002 #include "FWCore/PluginManager/interface/ProblemTracker.h"
0003 #include "FWCore/ServiceRegistry/test/stubs/DummyServiceE0.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/ServiceRegistry/interface/ServicesManager.h"
0006 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
0007 #include "FWCore/ServiceRegistry/interface/ServiceWrapper.h"
0008 #include "FWCore/Utilities/interface/Exception.h"
0009
0010 #include "FWCore/ServiceRegistry/interface/ServiceToken.h"
0011
0012 #include <cstdlib>
0013 #include <vector>
0014 #include <memory>
0015 #include <iostream>
0016
0017 class TestServicesManagerOrder {
0018 public:
0019 static edm::ServiceToken makeToken(std::shared_ptr<edm::serviceregistry::ServicesManager> iManager) {
0020 return edm::ServiceToken(iManager);
0021 }
0022 };
0023
0024 int main() try {
0025 using namespace edm::serviceregistry;
0026
0027
0028 edm::AssertHandler ah;
0029
0030
0031
0032
0033 typedef testserviceregistry::DummyServiceE0 Service0;
0034 typedef testserviceregistry::DummyServiceA1 Service1;
0035 typedef testserviceregistry::DummyServiceD2 Service2;
0036 typedef testserviceregistry::DummyServiceB3 Service3;
0037 typedef testserviceregistry::DummyServiceC4 Service4;
0038
0039
0040
0041
0042
0043
0044
0045 std::vector<edm::ParameterSet> vps;
0046 auto legacy = std::make_shared<ServicesManager>(vps);
0047
0048 edm::ActivityRegistry ar;
0049 edm::ParameterSet pset;
0050 legacy->put(std::make_shared<ServiceWrapper<Service0>>(std::make_unique<Service0>(pset, ar)));
0051 legacy->copySlotsFrom(ar);
0052 edm::ServiceToken legacyToken = TestServicesManagerOrder::makeToken(legacy);
0053
0054 std::vector<edm::ParameterSet> vps1;
0055
0056 edm::ParameterSet ps1;
0057 std::string typeName1("DummyServiceA1");
0058 ps1.addParameter("@service_type", typeName1);
0059 vps1.push_back(ps1);
0060
0061
0062
0063
0064
0065
0066 edm::ParameterSet ps3;
0067 std::string typeName3("DummyServiceB3");
0068 ps3.addParameter("@service_type", typeName3);
0069 vps1.push_back(ps3);
0070
0071 edm::ParameterSet ps2;
0072 std::string typeName2("DummyServiceD2");
0073 ps2.addParameter("@service_type", typeName2);
0074 vps1.push_back(ps2);
0075
0076 auto legacy2 = std::make_shared<ServicesManager>(legacyToken, kTokenOverrides, vps1);
0077 edm::ServiceToken legacyToken2 = TestServicesManagerOrder::makeToken(legacy2);
0078
0079 ServicesManager sm(legacyToken2, kOverlapIsError, vps);
0080
0081 edm::ActivityRegistry ar4;
0082 edm::ParameterSet pset4;
0083 sm.put(std::make_shared<ServiceWrapper<Service4>>(std::make_unique<Service4>(pset4, ar4)));
0084 sm.copySlotsFrom(ar4);
0085
0086 edm::ActivityRegistry actReg;
0087 sm.connectTo(actReg);
0088 actReg.postBeginJobSignal_();
0089 actReg.postEndJobSignal_();
0090
0091 return 0;
0092 } catch (cms::Exception const& e) {
0093 std::cerr << e.explainSelf() << std::endl;
0094 return 1;
0095 } catch (std::exception const& e) {
0096 std::cerr << e.what() << std::endl;
0097 return 1;
0098 }