File indexing completed on 2025-01-18 10:17:38
0001
0002
0003
0004
0005 #pragma once
0006 #include <JANA/JApplicationFwd.h>
0007
0008 #include <JANA/Services/JServiceLocator.h>
0009 #include <JANA/Services/JParameterManager.h>
0010
0011
0012
0013 template<typename T>
0014 T JApplication::GetParameterValue(std::string name) {
0015 return m_params->GetParameterValue<T>(name);
0016 }
0017
0018
0019 template<typename T>
0020 JParameter* JApplication::SetParameterValue(std::string name, T val) {
0021 if (m_initialized) {
0022 throw JException("SetParameterValue() must be called before Initialize(), as otherwise the parameter value won't be used!");
0023 }
0024 return m_params->SetParameter(name, val);
0025 }
0026
0027 template <typename T>
0028 JParameter* JApplication::SetDefaultParameter(std::string name, T& val, std::string description) {
0029 return m_params->SetDefaultParameter(name.c_str(), val, description);
0030 }
0031
0032 template <typename T>
0033 T JApplication::RegisterParameter(std::string name, const T default_val, std::string description) {
0034 return m_params->RegisterParameter(name.c_str(), default_val, description);
0035 }
0036
0037 template <typename T>
0038 JParameter* JApplication::GetParameter(std::string name, T& result) {
0039 return m_params->GetParameter(name, result);
0040 }
0041
0042
0043 template <typename T>
0044 std::shared_ptr<T> JApplication::GetService() {
0045 if (!m_services_available) {
0046 LOG_WARN(m_logger) << "GetService() called before Initialize(): Any parameter values set after this point won't be used!" << LOG_END;
0047
0048
0049
0050
0051 }
0052 return m_service_locator->get<T>();
0053 }
0054
0055
0056 template <typename T>
0057 void JApplication::ProvideService(std::shared_ptr<T> service) {
0058 if (m_initialized) {
0059 throw JException("Services need to be provided before JApplication::Initialize(), or inside InitPlugin()");
0060 }
0061 service->SetApplication(this);
0062 m_service_locator->provide(service);
0063 }
0064
0065
0066