Consolix
Loading...
Searching...
No Matches
service_utils.hpp File Reference

Utility functions for working with the ServiceLocator. More...

Go to the source code of this file.

Namespaces

namespace  consolix
 < Utility modules and helpers.
 

Macros

#define _CONSOLIX_SERVICE_UTILS_HPP_INCLUDED
 

Functions

template<typename T>
void consolix::register_service (std::function< std::shared_ptr< T >()> creator)
 Registers a resource or service globally. Registers a resource or service with the ServiceLocator using the provided creator function.
 
template<typename T>
void consolix::register_service ()
 Registers a resource with default construction globally. Registers a resource or service using default construction.
 
template<typename T>
T & consolix::get_service ()
 Retrieves a resource globally. Retrieves a reference to a globally registered resource from the ServiceLocator.
 
template<typename T>
bool consolix::has_service ()
 Checks if a resource is registered globally.
 
void consolix::clear_all ()
 Clears all registered resources globally. Clears all resources and services registered in the ServiceLocator
 

Detailed Description

Utility functions for working with the ServiceLocator.

Example usage of the ServiceLocator.

return std::make_shared<CliOptions>("AppName", "Description");
});
options.add_options()("debug", "Enable debugging", cxxopts::value<bool>()->default_value("false"));
return std::make_shared<std::string>("Hello, World!");
});
std::cout << message << std::endl;
}
void register_service()
Registers a resource with default construction globally. Registers a resource or service using defaul...
T & get_service()
Retrieves a resource globally. Retrieves a reference to a globally registered resource from the Servi...
bool has_service()
Checks if a resource is registered globally.

Definition in file service_utils.hpp.

Macro Definition Documentation

◆ _CONSOLIX_SERVICE_UTILS_HPP_INCLUDED

#define _CONSOLIX_SERVICE_UTILS_HPP_INCLUDED

Definition at line 3 of file service_utils.hpp.