1 #ifndef EXATN_SERVICE_HPP_
2 #define EXATN_SERVICE_HPP_
4 #include "ServiceRegistry.hpp"
13 extern bool exatnFrameworkInitialized;
14 extern std::shared_ptr<ServiceRegistry> serviceRegistry;
16 template <
typename Service>
17 std::shared_ptr<Service> getService(
const std::string &serviceName) {
18 if(!exatn::exatnFrameworkInitialized) {
19 std::cerr <<
"#FATAL(exatn::service): Unable to get service " << serviceName << std::endl
20 <<
"ExaTN is not initialized: Please execute "
21 "exatn::initialize() before using its API.\n";
24 auto service = serviceRegistry->getService<Service>(serviceName);
26 std::cerr <<
"#ERROR(exatn::service): Invalid ExaTN service: " << serviceName
27 <<
" in the Service Registry.\n";
33 template <
typename Service>
34 bool hasService(
const std::string &serviceName) {
35 if(!exatn::exatnFrameworkInitialized) {
36 std::cerr <<
"#FATAL(exatn::service): Unable to check service "+serviceName << std::endl <<
37 "ExaTN is not initialized: Please execute "
38 "exatn::initialize() before using its API.\n";
41 return serviceRegistry->hasService<Service>(serviceName);
46 #endif //EXATN_SERVICE_HPP_