aboutsummaryrefslogtreecommitdiff
path: root/src/DI
diff options
context:
space:
mode:
Diffstat (limited to 'src/DI')
-rw-r--r--src/DI/auto_wirable.hpp6
-rw-r--r--src/DI/auto_wirable.tpp4
-rw-r--r--src/DI/container.hpp14
-rw-r--r--src/DI/container.tpp13
-rw-r--r--src/DI/function_wrapper.hpp2
-rw-r--r--src/DI/function_wrapper.tpp2
-rw-r--r--src/DI/interfaces/wrapper.hpp4
-rw-r--r--src/DI/object_type.cpp2
-rw-r--r--src/DI/object_type.hpp6
-rw-r--r--src/DI/object_wrapper.hpp2
-rw-r--r--src/DI/object_wrapper.tpp2
11 files changed, 29 insertions, 28 deletions
diff --git a/src/DI/auto_wirable.hpp b/src/DI/auto_wirable.hpp
index 13d252e..a903242 100644
--- a/src/DI/auto_wirable.hpp
+++ b/src/DI/auto_wirable.hpp
@@ -8,21 +8,21 @@
class IGenericAutoWirable
{
public:
- virtual ~IGenericAutoWirable() = default;
+ virtual ~IGenericAutoWirable() noexcept = default;
};
template <class Interface>
class IAutoWirable : public IGenericAutoWirable
{
public:
- static Interface resolve();
+ static Interface resolve() noexcept;
};
template <class Interface, class ObjectImpl, class... Dependencies>
class AutoWirable : public IAutoWirable<Interface>
{
public:
- static std::shared_ptr<Interface> resolve(const Container &container);
+ static std::shared_ptr<Interface> resolve(const Container &container) noexcept;
};
#include "auto_wirable.tpp"
diff --git a/src/DI/auto_wirable.tpp b/src/DI/auto_wirable.tpp
index 6c0d111..a99d82b 100644
--- a/src/DI/auto_wirable.tpp
+++ b/src/DI/auto_wirable.tpp
@@ -3,8 +3,8 @@
#include "auto_wirable.hpp"
template <class Interface, class ObjectImpl, class... Dependencies>
-std::shared_ptr<Interface>
-AutoWirable<Interface, ObjectImpl, Dependencies...>::resolve(const Container &container)
+std::shared_ptr<Interface> AutoWirable<Interface, ObjectImpl, Dependencies...>::resolve(
+ const Container &container) noexcept
{
return std::make_shared<ObjectImpl>(container.get<Dependencies>()...);
}
diff --git a/src/DI/container.hpp b/src/DI/container.hpp
index 93722b6..974780a 100644
--- a/src/DI/container.hpp
+++ b/src/DI/container.hpp
@@ -14,13 +14,13 @@ template <typename Interface>
class BindingBuilder
{
public:
- explicit BindingBuilder(Container *container);
+ explicit BindingBuilder(Container *container) noexcept;
template <class ObjectImpl,
class = std::enable_if_t<std::is_base_of_v<Interface, ObjectImpl>>>
- void to();
+ void to() noexcept;
- void to_factory(Interface func);
+ void to_factory(Interface func) noexcept;
private:
Container *_container;
@@ -29,16 +29,16 @@ private:
class Container
{
public:
- Container() = default;
+ Container() noexcept = default;
template <class Interface>
- BindingBuilder<Interface> bind();
+ BindingBuilder<Interface> bind() noexcept;
template <class Interface, class = std::enable_if_t<std::is_class_v<Interface>>>
- std::shared_ptr<Interface> get() const;
+ std::shared_ptr<Interface> get() const noexcept;
template <typename Interface, typename = std::enable_if_t<is_func_v<Interface>>>
- Interface get() const;
+ Interface get() const noexcept;
std::unordered_map<BaseObjectType, std::shared_ptr<IGenericWrapper>, ObjectTypeHasher>
bindings;
diff --git a/src/DI/container.tpp b/src/DI/container.tpp
index e5bf7f7..ed7f34f 100644
--- a/src/DI/container.tpp
+++ b/src/DI/container.tpp
@@ -8,13 +8,14 @@
#include <iostream>
template <class Interface>
-BindingBuilder<Interface>::BindingBuilder(Container *container) : _container(container)
+BindingBuilder<Interface>::BindingBuilder(Container *container) noexcept
+ : _container(container)
{
}
template <class Interface>
template <class ObjectImpl, class>
-void BindingBuilder<Interface>::to()
+void BindingBuilder<Interface>::to() noexcept
{
_container->bindings.emplace(
ObjectType<Interface>(),
@@ -23,7 +24,7 @@ void BindingBuilder<Interface>::to()
}
template <class Interface>
-void BindingBuilder<Interface>::to_factory(Interface func)
+void BindingBuilder<Interface>::to_factory(Interface func) noexcept
{
_container->bindings.emplace(ObjectType<Interface>(),
std::dynamic_pointer_cast<IGenericWrapper>(
@@ -31,13 +32,13 @@ void BindingBuilder<Interface>::to_factory(Interface func)
}
template <class Interface>
-BindingBuilder<Interface> Container::bind()
+BindingBuilder<Interface> Container::bind() noexcept
{
return BindingBuilder<Interface>(this);
}
template <class Interface, class>
-std::shared_ptr<Interface> Container::get() const
+std::shared_ptr<Interface> Container::get() const noexcept
{
ObjectType<Interface> interface_type;
@@ -56,7 +57,7 @@ std::shared_ptr<Interface> Container::get() const
}
template <typename Interface, typename>
-Interface Container::get() const
+Interface Container::get() const noexcept
{
auto wrapper = std::dynamic_pointer_cast<IWrapper<Interface>>(
bindings.at(ObjectType<Interface>()));
diff --git a/src/DI/function_wrapper.hpp b/src/DI/function_wrapper.hpp
index f135e7f..e6468f2 100644
--- a/src/DI/function_wrapper.hpp
+++ b/src/DI/function_wrapper.hpp
@@ -11,7 +11,7 @@ class FunctionWrapper : public IWrapper<Interface>
public:
explicit FunctionWrapper(Interface func) noexcept;
- [[nodiscard]] Interface get() const override;
+ [[nodiscard]] Interface get() const noexcept override;
private:
const Interface _func;
diff --git a/src/DI/function_wrapper.tpp b/src/DI/function_wrapper.tpp
index 920c7f2..540a7aa 100644
--- a/src/DI/function_wrapper.tpp
+++ b/src/DI/function_wrapper.tpp
@@ -8,7 +8,7 @@ FunctionWrapper<Interface>::FunctionWrapper(Interface func) noexcept : _func(fun
}
template <class Interface>
-Interface FunctionWrapper<Interface>::get() const
+Interface FunctionWrapper<Interface>::get() const noexcept
{
return _func;
}
diff --git a/src/DI/interfaces/wrapper.hpp b/src/DI/interfaces/wrapper.hpp
index 3cc75a0..cde555f 100644
--- a/src/DI/interfaces/wrapper.hpp
+++ b/src/DI/interfaces/wrapper.hpp
@@ -6,12 +6,12 @@
class IGenericWrapper
{
public:
- virtual ~IGenericWrapper() = default;
+ virtual ~IGenericWrapper() noexcept = default;
};
template <class Interface>
class IWrapper : public IGenericWrapper
{
public:
- [[nodiscard]] virtual Interface get() const = 0;
+ [[nodiscard]] virtual Interface get() const noexcept = 0;
};
diff --git a/src/DI/object_type.cpp b/src/DI/object_type.cpp
index f6004cb..008c4a4 100644
--- a/src/DI/object_type.cpp
+++ b/src/DI/object_type.cpp
@@ -20,7 +20,7 @@ std::string_view BaseObjectType::name() const noexcept
return std::string_view(_type_info.name());
}
-std::size_t ObjectTypeHasher::operator()(const BaseObjectType &object_type) const
+std::size_t ObjectTypeHasher::operator()(const BaseObjectType &object_type) const noexcept
{
return object_type.hash();
}
diff --git a/src/DI/object_type.hpp b/src/DI/object_type.hpp
index 3910c03..84bb287 100644
--- a/src/DI/object_type.hpp
+++ b/src/DI/object_type.hpp
@@ -22,17 +22,17 @@ template <class Object>
class ObjectType : public BaseObjectType
{
public:
- ObjectType() : BaseObjectType(typeid(Object)) {}
+ ObjectType() noexcept : BaseObjectType(typeid(Object)) {}
};
class IObjectTypeHasher
{
public:
- virtual std::size_t operator()(const BaseObjectType &object_type) const = 0;
+ virtual std::size_t operator()(const BaseObjectType &object_type) const noexcept = 0;
};
class ObjectTypeHasher : public IObjectTypeHasher
{
public:
- std::size_t operator()(const BaseObjectType &object_type) const override;
+ std::size_t operator()(const BaseObjectType &object_type) const noexcept override;
};
diff --git a/src/DI/object_wrapper.hpp b/src/DI/object_wrapper.hpp
index 6fe3997..4aee9af 100644
--- a/src/DI/object_wrapper.hpp
+++ b/src/DI/object_wrapper.hpp
@@ -11,7 +11,7 @@ class ObjectWrapper : public IWrapper<std::shared_ptr<Interface>>
public:
explicit ObjectWrapper(const Container &container) noexcept : _container(container) {}
- [[nodiscard]] std::shared_ptr<Interface> get() const override;
+ [[nodiscard]] std::shared_ptr<Interface> get() const noexcept override;
private:
const Container &_container;
diff --git a/src/DI/object_wrapper.tpp b/src/DI/object_wrapper.tpp
index 7efefc4..bbb7bee 100644
--- a/src/DI/object_wrapper.tpp
+++ b/src/DI/object_wrapper.tpp
@@ -3,7 +3,7 @@
#include "object_wrapper.hpp"
template <class Interface, class ObjectImpl>
-std::shared_ptr<Interface> ObjectWrapper<Interface, ObjectImpl>::get() const
+std::shared_ptr<Interface> ObjectWrapper<Interface, ObjectImpl>::get() const noexcept
{
return ObjectImpl::resolve(_container);
}