Consolix
Loading...
Searching...
No Matches
service_utils.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef _CONSOLIX_SERVICE_UTILS_HPP_INCLUDED
3#define _CONSOLIX_SERVICE_UTILS_HPP_INCLUDED
4
26
27namespace consolix {
28
33 template <typename T>
34 inline void register_service(std::function<std::shared_ptr<T>()> creator) {
35 ServiceLocator::get_instance().register_service<T>(std::move(creator));
36 }
37
41 template <typename T>
45
50 template <typename T>
51 inline T& get_service() {
53 }
54
58 template <typename T>
59 inline bool has_service() {
61 }
62
65 inline void clear_all() {
67 }
68
69}; // namespace consolix
70
71#endif // _CONSOLIX_SERVICE_UTILS_HPP_INCLUDED
static ServiceLocator & get_instance()
Retrieves the singleton instance of the ServiceLocator.
void clear_all()
Clears all registered resources.
void register_service(std::function< std::shared_ptr< T >()> creator)
Registers a resource or service.
bool has_service()
Checks if a resource is registered.
T & get_service()
Retrieves a resource from the locator.
< Utility modules and helpers.
void clear_all()
Clears all registered resources globally. Clears all resources and services registered in the Service...
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.