File indexing completed on 2025-01-18 10:17:43
0001
0002
0003
0004
0005 #ifndef JANA2_JSERVICELOCATORTESTS_H
0006 #define JANA2_JSERVICELOCATORTESTS_H
0007 #pragma once
0008
0009 #include <map>
0010 #include <JANA/Services/JServiceLocator.h>
0011
0012 struct ParameterSvc : public JService {
0013
0014 std::map<std::string, std::string> underlying;
0015
0016 void acquire_services(JServiceLocator*) {}
0017 void set(std::string name, std::string value) {
0018 underlying[name] = value;
0019
0020 }
0021 std::string get(std::string name) {
0022 return underlying[name];
0023 }
0024 };
0025
0026
0027 struct LoggerSvc : public JService {
0028
0029 std::string level = "INFO";
0030
0031 void acquire_services(JServiceLocator *sl) {
0032 level = sl->get<ParameterSvc>()->get("JANA:LogLevel");
0033 }
0034
0035 };
0036
0037 struct MagneticFieldSvc : public JService {
0038
0039 std::shared_ptr<LoggerSvc> logger;
0040 std::string url = "NO_URL";
0041
0042 void acquire_services(JServiceLocator *sl) {
0043 logger = sl->get<LoggerSvc>();
0044 url = sl->get<ParameterSvc>()->get("EIC:MagneticFieldDatabaseURL");
0045 if (url == "") {
0046 sl->get<ParameterSvc>()->set("EIC:MagneticFieldDatabaseURL", "mysql://127.0.0.1");
0047 }
0048
0049
0050 }
0051
0052 bool connect() {
0053 return url != "NO_URL";
0054 }
0055 };
0056
0057 #endif