Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/CodeCoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Code Coverage

on:
push:
branches: [ "dev", "main" ]
paths-ignore:
- "Docs/**"
- ".readthedocs.yaml"
- "README.md"

jobs:
code-coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure
run: cmake -B ${{runner.workspace}}/build -D_7BIT_DI_LIBRARY_TYPE=Static -D_7BIT_DI_BUILD_ALL_TESTS=ON -DCMAKE_CXX_FLAGS="-coverage"

- name: Build
run: cmake --build ${{runner.workspace}}/build -j

- name: Test
working-directory: ${{runner.workspace}}/build
run: ctest --output-on-failure

- name: Upload Code Coverage
working-directory: ${{runner.workspace}}/build
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
4 changes: 1 addition & 3 deletions .github/workflows/DevCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ jobs:

- name: Test
working-directory: ${{runner.workspace}}/build
run: ctest -C ${{matrix.build_type}}
env:
CTEST_OUTPUT_ON_FAILURE: True
run: ctest -C ${{matrix.build_type}} --output-on-failure
4 changes: 1 addition & 3 deletions .github/workflows/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,4 @@ jobs:

- name: Test
working-directory: ${{runner.workspace}}/build
run: ctest -C ${{matrix.build_type}}
env:
CTEST_OUTPUT_ON_FAILURE: True
run: ctest -C ${{matrix.build_type}} --output-on-failure
4 changes: 1 addition & 3 deletions .github/workflows/MacOs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,4 @@ jobs:

- name: Test
working-directory: ${{runner.workspace}}/build
run: ctest -C ${{matrix.build_type}}
env:
CTEST_OUTPUT_ON_FAILURE: True
run: ctest -C ${{matrix.build_type}} --output-on-failure
4 changes: 1 addition & 3 deletions .github/workflows/Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,4 @@ jobs:

- name: Test
working-directory: ${{runner.workspace}}/build
run: ctest -C ${{matrix.build_type}}
env:
CTEST_OUTPUT_ON_FAILURE: True
run: ctest -C ${{matrix.build_type}} --output-on-failure
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.15.0)
set(_7BIT_DI_LIBRARY 7bitDI)

set(_7BIT_DI_VERSION_MAJOR 3)
set(_7BIT_DI_VERSION_MINOR 1)
set(_7BIT_DI_VERSION_MINOR 2)
set(_7BIT_DI_VERSION_PATCH 0)

set(_7BIT_DI_VERSION ${_7BIT_DI_VERSION_MAJOR}.${_7BIT_DI_VERSION_MINOR}.${_7BIT_DI_VERSION_PATCH})
Expand Down
18 changes: 0 additions & 18 deletions Cmake/Setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,6 @@ set(_7BIT_DI_DI_DIR "${_7BIT_DI_INCLUDE_DIR}/SevenBit/DI")
set(_7BIT_DI_DETAILS_DIR "${_7BIT_DI_DI_DIR}/Details")

set(_7BIT_DI_MAIN_HEADER "${_7BIT_DI_INCLUDE_DIR}/SevenBit/DI.hpp")
file(GLOB _7BIT_DI_TOP_HEADERS "${_7BIT_DI_DI_DIR}/*.hpp")
file(GLOB _7BIT_DI_DETAILS_HEADERS
"${_7BIT_DI_DETAILS_DIR}/Containers/*.hpp"
"${_7BIT_DI_DETAILS_DIR}/Core/*.hpp"
"${_7BIT_DI_DETAILS_DIR}/Factories/*.hpp"
"${_7BIT_DI_DETAILS_DIR}/Helpers/*.hpp"
"${_7BIT_DI_DETAILS_DIR}/Services/*.hpp"
"${_7BIT_DI_DETAILS_DIR}/Utils/*.hpp"
)
file(GLOB _7BIT_DI_IMPL_HEADERS
"${_7BIT_DI_DI_DIR}/Impl/*.hpp"
"${_7BIT_DI_DETAILS_DIR}/Containers/Impl/*.hpp"
"${_7BIT_DI_DETAILS_DIR}/Core/Impl/*.hpp"
"${_7BIT_DI_DETAILS_DIR}/Factories/Impl/*.hpp"
"${_7BIT_DI_DETAILS_DIR}/Helpers/Impl/*.hpp"
"${_7BIT_DI_DETAILS_DIR}/Utils/Impl/*.hpp"
)
set(_7BIT_DI_ALL_HEADERS ${_7BIT_DI_MAIN_HEADER} ${_7BIT_DI_TOP_HEADERS} ${_7BIT_DI_DETAILS_HEADERS} ${_7BIT_DI_IMPL_HEADERS})

set(_7BIT_DI_LIBRARY_TYPE "Static" CACHE STRING "Library build type: Shared;Static;HeaderOnly")
set(_7BIT_DI_LIBRARY_TYPE_VALUES "Shared;Static;HeaderOnly" CACHE STRING "List of possible _7BIT_DI_LIBRARY_TYPE values")
Expand Down
6 changes: 5 additions & 1 deletion Docs/advanced-guides/using-aliases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ Using Aliases
========================================

With the use of aliases, one service can be injected through its multiple base classes, also aliases can be chained.
If multiple aliases are registered with the same base class only last will be used.
In case of injecting multiple aliases all real services will be fetched.

.. warning::
Using aliases is resource intensive, especially for injecting transient and multiple services, provider recursively
traverses through aliases chain to find proper service. Mixing scoped and singleton aliases for same base type will
lead to undefined behavior

.. literalinclude:: ../../Examples/Guides/ServiceAliases.cpp
:caption: Examples/Guides/ServiceAliases
Expand Down
2 changes: 1 addition & 1 deletion Docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def createIfNotExists(path):
project = "7bitDI"
copyright = "2023, 7BitCoder Sylwester Dawida"
author = "Sylwester Dawida"
version = "3.1.0"
version = "3.2.0"

extensions = [
"sphinx.ext.autodoc",
Expand Down
4 changes: 2 additions & 2 deletions Docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Installation
FetchContent_Declare(
7bitDI
GIT_REPOSITORY https://github.com/7bitcoder/7bitDI.git
GIT_TAG v3.1.0
GIT_TAG v3.2.0
)
FetchContent_MakeAvailable(7bitDI)

Expand All @@ -48,7 +48,7 @@ Installation
.. code-block:: Txt

[requires]
7bitdi/3.1.0
7bitdi/3.2.0

change the version to newer if available, then run the command:

Expand Down
4 changes: 2 additions & 2 deletions Docs/reference/di/details/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sb::di::details - Core
:titlesonly:

core/iserviceinstanceproviderroot.rst
core/serviceinstancecreator.rst
core/servicealiasescreator.rst
core/serviceinstanceprovider.rst
core/serviceinstanceproviderroot.rst
core/serviceinstancesresolver.rst
core/serviceinstancescreator.rst
6 changes: 6 additions & 0 deletions Docs/reference/di/details/core/servicealiasescreator.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ServiceAliasesCreator
========================================

.. doxygenclass:: sb::di::details::ServiceAliasesCreator
:members:
:undoc-members:
6 changes: 0 additions & 6 deletions Docs/reference/di/details/core/serviceinstancecreator.rst

This file was deleted.

6 changes: 6 additions & 0 deletions Docs/reference/di/details/core/serviceinstancescreator.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ServiceInstancesCreator
========================================

.. doxygenclass:: sb::di::details::ServiceInstancesCreator
:members:
:undoc-members:
6 changes: 0 additions & 6 deletions Docs/reference/di/details/core/serviceinstancesresolver.rst

This file was deleted.

2 changes: 1 addition & 1 deletion Include/SevenBit/DI/CmakeDef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
#endif

#define _7BIT_DI_VERSION_MAJOR 3
#define _7BIT_DI_VERSION_MINOR 1
#define _7BIT_DI_VERSION_MINOR 2
/* #undef _7BIT_DI_VERSION_PATCH */
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@

namespace sb::di::details
{

INLINE ServiceDescriptorList::ServiceDescriptorList(ServiceDescriptor &&descriptor)
: _oneOrList(std::move(descriptor))
{
}

INLINE void ServiceDescriptorList::add(ServiceDescriptor &&descriptor)
{
if (!empty())
Expand All @@ -22,20 +16,9 @@ namespace sb::di::details
checkAlias(descriptor);
checkLifeTime(descriptor);
}
_oneOrList.add(std::move(descriptor));
OneOrList::add(std::move(descriptor));
}

INLINE OneOrList<ServiceDescriptor> &ServiceDescriptorList::getInnerList() { return _oneOrList; }
INLINE const OneOrList<ServiceDescriptor> &ServiceDescriptorList::getInnerList() const { return _oneOrList; }

INLINE const ServiceDescriptor &ServiceDescriptorList::first() const { return _oneOrList.first(); }

INLINE const ServiceDescriptor &ServiceDescriptorList::last() const { return _oneOrList.last(); }

INLINE bool ServiceDescriptorList::empty() const { return _oneOrList.empty(); }

INLINE std::size_t ServiceDescriptorList::size() const { return _oneOrList.size(); }

INLINE ServiceLifeTime ServiceDescriptorList::getLifeTime() const { return first().getLifeTime(); }

INLINE TypeId ServiceDescriptorList::getServiceTypeId() const { return first().getServiceTypeId(); }
Expand Down Expand Up @@ -76,7 +59,4 @@ namespace sb::di::details
throw ServiceLifeTimeMismatchException{descriptor.getImplementationTypeId(), getServiceTypeId()};
}
}

INLINE void ServiceDescriptorList::seal() { _oneOrList.shrink(); }

} // namespace sb::di::details

This file was deleted.

22 changes: 2 additions & 20 deletions Include/SevenBit/DI/Details/Containers/ServiceDescriptorList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,19 @@

namespace sb::di::details
{
class EXPORT ServiceDescriptorList
class EXPORT ServiceDescriptorList : public OneOrList<ServiceDescriptor>
{
OneOrList<ServiceDescriptor> _oneOrList;

public:
explicit ServiceDescriptorList(ServiceDescriptor &&descriptor);
using OneOrList::OneOrList;

ServiceDescriptorList(const ServiceDescriptorList &) = delete;
ServiceDescriptorList(ServiceDescriptorList &&) = default;

ServiceDescriptorList &operator=(const ServiceDescriptorList &) = delete;
ServiceDescriptorList &operator=(ServiceDescriptorList &&) = default;

OneOrList<ServiceDescriptor> &getInnerList();
[[nodiscard]] const OneOrList<ServiceDescriptor> &getInnerList() const;

void add(ServiceDescriptor &&descriptor);

[[nodiscard]] auto begin() const { return _oneOrList.getAsList().begin(); }
[[nodiscard]] auto end() const { return _oneOrList.getAsList().end(); }

[[nodiscard]] const ServiceDescriptor &first() const;

[[nodiscard]] const ServiceDescriptor &last() const;

[[nodiscard]] bool empty() const;

[[nodiscard]] std::size_t size() const;

[[nodiscard]] ServiceLifeTime getLifeTime() const;

[[nodiscard]] TypeId getServiceTypeId() const;
Expand All @@ -46,8 +30,6 @@ namespace sb::di::details

[[nodiscard]] bool isAlias() const;

void seal();

private:
void checkBaseType(const ServiceDescriptor &descriptor) const;
void checkKey(const ServiceDescriptor &descriptor) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ namespace sb::di::details
}

ServiceDescriptorsMap(const ServiceDescriptorsMap &) = delete;
ServiceDescriptorsMap(ServiceDescriptorsMap &&) noexcept = default;
ServiceDescriptorsMap(ServiceDescriptorsMap &&) = default;

ServiceDescriptorsMap &operator=(const ServiceDescriptorsMap &) = delete;
ServiceDescriptorsMap &operator=(ServiceDescriptorsMap &&) = delete;

void add(ServiceDescriptor descriptor);

Expand Down
Loading