11 return this->
_registry->ctx().insert_or_assign<TResource>(std::forward<TResource>(resource));
16 if (!this->
_registry->ctx().contains<TResource>())
19 fmt::format(
"Resource not found in the core registry: {}",
typeid(TResource).name()));
21 return this->
_registry->ctx().get<TResource>();
26 return this->
_registry->ctx().contains<TResource>();
33 return this->
_registry->ctx().get<TResource>();
38 this->
_schedulers.AddScheduler<TScheduler>(*
this, std::forward<Args>(args)...);
39 return this->
_schedulers.GetScheduler<TScheduler>();
49 return this->
_schedulers.GetScheduler<TScheduler>();
63 return this->
_schedulers.GetScheduler<TScheduler>().AddSystems(systems...);
70 Log::Warning(fmt::format(
"Trying to register systems with a default scheduler that does not exist: {}",
76template <CScheduler TScheduler,
typename System,
typename ErrorCallback>
82template <
typename System,
typename ErrorCallback>
92 if (this->
_plugins.contains(std::type_index(
typeid(TPlugin))))
94 Log::Warning(fmt::format(
"Plugin {} already added",
typeid(TPlugin).name()));
96 this->
_plugins.emplace(std::type_index(
typeid(TPlugin)), std::make_unique<TPlugin>(*
this));
97 this->
_plugins.at(std::type_index(
typeid(TPlugin)))->Bind();
102 return this->
_plugins.contains(std::type_index(
typeid(TPlugin)));
109 Log::Warning(fmt::format(
"Trying to set a default scheduler that does not exist: {}", scheduler.name()));
void AddPlugin()
Adds a plugin.
Definition Core.inl:90
std::unique_ptr< Registry > _registry
The registry that contains all components (and by definition, the entities).
Definition Core.hpp:249
TResource & GetResource()
Get a reference of a resource.
Definition Core.inl:14
TScheduler & RegisterScheduler(Args &&...args)
Add a new scheduler to the registry.
Definition Core.inl:36
bool HasResource() const
Check if a resource is registered in the core.
Definition Core.inl:24
TScheduler & GetScheduler()
Get a scheduler from the registry by its type.
Definition Core.inl:47
Engine::SchedulerContainer _schedulers
The container that contains all the schedulers.
Definition Core.hpp:251
decltype(auto) RegisterSystemWithErrorHandler(System system, ErrorCallback callback)
Add a system to a specific scheduler, associated with a callback that should run if the system fails ...
Definition Core.inl:77
void SetDefaultScheduler()
Sets the default scheduler.
Definition Core.hpp:228
decltype(auto) RegisterSystem(Systems... systems)
Add one or multiple systems associated with a specific scheduler.
Definition Core.inl:61
std::type_index _defaultScheduler
The default scheduler type index. It is used when adding systems without specifying a scheduler.
Definition Core.hpp:253
bool HasPlugin() const
Checks if a plugin is present.
Definition Core.inl:100
void AddPlugins()
Adds multiple plugins that will be call instantly through the Bind method to agregate their systems a...
Definition Core.inl:88
std::vector< std::type_index > _schedulersToDelete
The list of schedulers to delete at the end of the current loop.
Definition Core.hpp:255
std::unordered_map< std::type_index, std::unique_ptr< IPlugin > > _plugins
The plugins added to the core.
Definition Core.hpp:257
void DeleteScheduler()
Deletes a scheduler.
Definition Core.inl:42
void DeleteResource()
Delete a resource from the core.
Definition Core.inl:29
TResource & RegisterResource(TResource &&resource)
Store a resource instance.
Definition Core.inl:9
Exception thrown when a requested resource is not found in the Core.
Definition MissingResourceError.hpp:8
Exception thrown when a requested scheduler is not found in the Core.
Definition MissingSchedulerError.hpp:8
AScheduler is an abstract class that implements the IScheduler interface. It provides common function...
Definition AScheduler.hpp:15
Wrapper around a system that allows to add an error callback to it.
Definition WrappedSystem.hpp:14
FunctionUtils::CallableFunction< TCallable, void, Core & > System
Definition System.hpp:19
void Warning(const T &msg) noexcept
Definition Logger.hpp:49