aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-06-09 17:46:24 +0200
committerHampusM <hampus@hampusmat.com>2022-06-09 17:46:24 +0200
commit59d8202868364b6efeb92dbd694d961723b74cc0 (patch)
tree573aea529c556bb2b893f93ac6ffd85cfb02f4c9 /src
parentcb169dfac720de614821480a2633bb93b6be5245 (diff)
refactor: replace BaseObjectType with static ObjectType method
Diffstat (limited to 'src')
-rw-r--r--src/container.cpp8
-rw-r--r--src/object_type.cpp15
2 files changed, 11 insertions, 12 deletions
diff --git a/src/container.cpp b/src/container.cpp
index 00efc27..044d487 100644
--- a/src/container.cpp
+++ b/src/container.cpp
@@ -7,20 +7,20 @@ namespace yacppdic
{
void Container::add(
- const BaseObjectType &type,
+ const ObjectType &type,
const WrapperPtr<IGenericWrapper> &wrapper
) noexcept
{
_bindings.insert({ type, wrapper });
}
-void Container::remove(const BaseObjectType &type) noexcept
+void Container::remove(const ObjectType &type) noexcept
{
_bindings.erase(type);
}
-Container::WrapperPtr<IGenericWrapper> Container::at(const BaseObjectType &type
-) const noexcept
+auto Container::at(const ObjectType &type) const noexcept
+ -> Container::WrapperPtr<IGenericWrapper>
{
return _bindings.at(type);
}
diff --git a/src/object_type.cpp b/src/object_type.cpp
index bd61e09..15b798c 100644
--- a/src/object_type.cpp
+++ b/src/object_type.cpp
@@ -7,12 +7,11 @@
namespace yacppdic
{
-BaseObjectType::BaseObjectType(const std::type_info &type_info) noexcept
- : _type_info(type_info)
+ObjectType::ObjectType(const std::type_info &type_info) noexcept : _type_info(type_info)
{
}
-BaseObjectType::BaseObjectType(
+ObjectType::ObjectType(
const std::type_info &type_info,
const std::string_view tag
) noexcept
@@ -20,12 +19,12 @@ BaseObjectType::BaseObjectType(
{
}
-auto BaseObjectType::operator==(const BaseObjectType &object_type) const noexcept -> bool
+auto ObjectType::operator==(const ObjectType &object_type) const noexcept -> bool
{
return hash() == object_type.hash();
}
-auto BaseObjectType::hash() const noexcept -> std::size_t
+auto ObjectType::hash() const noexcept -> std::size_t
{
const auto type_hash = _type_info.hash_code();
@@ -33,17 +32,17 @@ auto BaseObjectType::hash() const noexcept -> std::size_t
: combine_hashes(type_hash, std::hash<std::string_view>()(_tag));
}
-auto BaseObjectType::name() const noexcept -> std::string_view
+auto ObjectType::name() const noexcept -> std::string_view
{
return { _type_info.name() };
}
-auto BaseObjectType::tag() const noexcept -> std::string_view
+auto ObjectType::tag() const noexcept -> std::string_view
{
return _tag;
}
-auto ObjectTypeHasher::operator()(const BaseObjectType &object_type) const noexcept
+auto ObjectTypeHasher::operator()(const ObjectType &object_type) const noexcept
-> std::size_t
{
return object_type.hash();