-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: ecstasy::ResourceReference now use std::reference_wr…
…apper when not thread safe Also removed the templated ecstasy::Resource and base ecstasy::ResourceBase classes, both replaced by the simplier IResource base class. Close #170
- Loading branch information
1 parent
fb60b28
commit 8bd8928
Showing
24 changed files
with
196 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
#define ECSTASY_INTEGRATIONS_EVENT_INPUTS_GAMEPADS_HPP_ | ||
|
||
#include "Gamepad.hpp" | ||
#include "ecstasy/resources/Resource.hpp" | ||
#include "ecstasy/resources/IResource.hpp" | ||
|
||
namespace ecstasy::integration::event | ||
{ | ||
|
@@ -23,7 +23,7 @@ namespace ecstasy::integration::event | |
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2022-11-18) | ||
/// | ||
class Gamepads : public ecstasy::Resource<Gamepads> { | ||
class Gamepads : public ecstasy::IResource { | ||
public: | ||
/// @brief Number of supported gamepads. | ||
static const size_t GamepadCount = 4; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
#include <iostream> | ||
#include <unordered_map> | ||
|
||
#include "ecstasy/resources/Resource.hpp" | ||
#include "ecstasy/resources/IResource.hpp" | ||
#include "util/serialization/SerializableEnum.hpp" | ||
|
||
namespace ecstasy::integration::event | ||
|
@@ -27,7 +27,7 @@ namespace ecstasy::integration::event | |
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2022-11-16) | ||
/// | ||
class Keyboard : public Resource<Keyboard> { | ||
class Keyboard : public IResource { | ||
public: | ||
// LCOV_EXCL_START | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
#include <iostream> | ||
#include <utility> | ||
|
||
#include "ecstasy/resources/Resource.hpp" | ||
#include "ecstasy/resources/IResource.hpp" | ||
#include "util/serialization/SerializableEnum.hpp" | ||
|
||
namespace ecstasy::integration::event | ||
|
@@ -27,7 +27,7 @@ namespace ecstasy::integration::event | |
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2022-11-04) | ||
/// | ||
class Mouse : public Resource<Mouse> { | ||
class Mouse : public IResource { | ||
public: | ||
// LCOV_EXCL_START | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
#include "ecstasy/integrations/event/inputs/Keyboard.hpp" | ||
#include "ecstasy/integrations/event/inputs/Mouse.hpp" | ||
#include "ecstasy/registry/Registry.hpp" | ||
#include "ecstasy/resources/Resource.hpp" | ||
#include "ecstasy/resources/IResource.hpp" | ||
#include "ecstasy/storages/MapStorage.hpp" | ||
#include <unordered_map> | ||
|
||
|
@@ -37,7 +37,7 @@ namespace ecstasy::integration::user_action | |
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2022-12-02) | ||
/// | ||
class Users : public ecstasy::Resource<Users> { | ||
class Users : public ecstasy::IResource { | ||
private: | ||
/// @brief Helper type instead of using @ref std::pair. | ||
/// Describe a link between an action and a user. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,8 @@ namespace ecstasy | |
/// @brief Resource reference type. | ||
/// This type is used to reference a resource in a thread-safe way depending on the AutoLock parameter. | ||
/// | ||
/// @note Consider this as a thread_safe @ref std::reference_wrapper. | ||
/// | ||
/// @tparam R Resource type. | ||
/// @tparam AutoLock Whether the resource should be locked automatically. | ||
/// | ||
|
@@ -95,7 +97,7 @@ namespace ecstasy | |
} | ||
|
||
/// @copydoc getQueryable() | ||
template <std::derived_from<ResourceBase> R> | ||
template <std::derived_from<IResource> R> | ||
requires query::Queryable<R> | ||
[[nodiscard]] constexpr R &getQueryable() | ||
{ | ||
|
@@ -137,7 +139,7 @@ namespace ecstasy | |
} | ||
|
||
/// @copydoc getFromType() | ||
template <std::derived_from<ResourceBase> R> | ||
template <std::derived_from<IResource> R> | ||
[[nodiscard]] constexpr R &getFromType() | ||
{ | ||
return getResource<R, false>(); | ||
|
@@ -847,7 +849,7 @@ namespace ecstasy | |
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2022-10-18) | ||
/// | ||
template <std::derived_from<ResourceBase> R, typename... Args> | ||
template <std::derived_from<IResource> R, typename... Args> | ||
R &addResource(Args &&...args) | ||
{ | ||
return _resources.emplace<R>(std::forward<Args>(args)...); | ||
|
@@ -881,7 +883,7 @@ namespace ecstasy | |
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2022-11-06) | ||
/// | ||
template <std::derived_from<ResourceBase> R> | ||
template <std::derived_from<IResource> R> | ||
[[nodiscard]] bool hasResource() const | ||
{ | ||
return _resources.contains<R>(); | ||
|
@@ -900,7 +902,7 @@ namespace ecstasy | |
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2022-10-18) | ||
/// | ||
template <std::derived_from<ResourceBase> R, bool Locked = thread::AUTO_LOCK_RESOURCES_DEFAULT> | ||
template <std::derived_from<IResource> R, bool Locked = thread::AUTO_LOCK_RESOURCES_DEFAULT> | ||
[[nodiscard]] ResourceReference<const R, Locked> getResource() const | ||
{ | ||
return _resources.get<R>(); | ||
|
@@ -918,7 +920,7 @@ namespace ecstasy | |
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2022-10-18) | ||
/// | ||
template <std::derived_from<ResourceBase> R, bool Locked = thread::AUTO_LOCK_RESOURCES_DEFAULT> | ||
template <std::derived_from<IResource> R, bool Locked = thread::AUTO_LOCK_RESOURCES_DEFAULT> | ||
[[nodiscard]] ResourceReference<R, Locked> getResource() | ||
{ | ||
return _resources.get<R>(); | ||
|
@@ -1223,7 +1225,7 @@ namespace ecstasy | |
|
||
private: | ||
/// @brief Registry resources. | ||
Instances<ResourceBase> _resources; | ||
Instances<IResource> _resources; | ||
/// @brief Registry storages. | ||
Instances<IStorage> _storages; | ||
/// @brief Registry systems. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.