Consolix
Toggle main menu visibility
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
27
namespace
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>
42
inline
void
register_service
() {
43
ServiceLocator::get_instance
().
register_service
<T>();
44
}
45
50
template
<
typename
T>
51
inline
T&
get_service
() {
52
return
ServiceLocator::get_instance
().
get_service
<T>();
53
}
54
58
template
<
typename
T>
59
inline
bool
has_service
() {
60
return
ServiceLocator::get_instance
().
has_service
<T>();
61
}
62
65
inline
void
clear_all
() {
66
ServiceLocator::get_instance
().
clear_all
();
67
}
68
69
};
// namespace consolix
70
71
#endif
// _CONSOLIX_SERVICE_UTILS_HPP_INCLUDED
consolix::ServiceLocator::get_instance
static ServiceLocator & get_instance()
Retrieves the singleton instance of the ServiceLocator.
Definition
ServiceLocator.hpp:34
consolix::ServiceLocator::clear_all
void clear_all()
Clears all registered resources.
Definition
ServiceLocator.hpp:103
consolix::ServiceLocator::register_service
void register_service(std::function< std::shared_ptr< T >()> creator)
Registers a resource or service.
Definition
ServiceLocator.hpp:44
consolix::ServiceLocator::has_service
bool has_service()
Checks if a resource is registered.
Definition
ServiceLocator.hpp:96
consolix::ServiceLocator::get_service
T & get_service()
Retrieves a resource from the locator.
Definition
ServiceLocator.hpp:79
consolix
< Utility modules and helpers.
Definition
BaseLoopComponent.hpp:13
consolix::clear_all
void clear_all()
Clears all registered resources globally. Clears all resources and services registered in the Service...
Definition
service_utils.hpp:65
consolix::register_service
void register_service()
Registers a resource with default construction globally. Registers a resource or service using defaul...
Definition
service_utils.hpp:42
consolix::get_service
T & get_service()
Retrieves a resource globally. Retrieves a reference to a globally registered resource from the Servi...
Definition
service_utils.hpp:51
consolix::has_service
bool has_service()
Checks if a resource is registered globally.
Definition
service_utils.hpp:59
include
consolix
core
service_utils.hpp
Generated by
1.17.0