Skip to content

Commit 0bf713c

Browse files
committed
update documentation
1 parent 2869667 commit 0bf713c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+396
-146
lines changed

Docs/advanced-guides.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ Advanced Guides
66
:titlesonly:
77

88
advanced-guides/using-factories
9+
advanced-guides/using-aliases
910
advanced-guides/external-singleton
1011
advanced-guides/building-library
11-
12-
13-
14-
15-

Docs/advanced-guides/building-library.rst

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ Using this command several cache variables can be set:
2020
* <variable cache name>: [possible values] (default value) - Description
2121
* _7BIT_DI_LIBRARY_TYPE: ["Shared", "Static", "HeaderOnly"] ("Static") - Library build type
2222
* _7BIT_DI_BUILD_DOCS: ["ON", "OFF"] ("OFF") - Turn on to build documentation (requires Sphinx_, Breathe_ and Doxygen_ to be installed)
23-
* _7BIT_DI_BUILD_TESTS: ["ON", "OFF"] ("OFF") - Turn on to build tests (requires Gtest_ to be installed, see `Build Library With Conan`_)
23+
* _7BIT_DI_BUILD_TESTS: ["ON", "OFF"] ("OFF") - Turn on to build tests
2424
* _7BIT_DI_BUILD_EXAMPLES: ["ON", "OFF"] ("OFF") - Turn on to build examples
25+
* _7BIT_DI_BUILD_BENCHMARKS: ["ON", "OFF"] ("OFF") - Turn on to build benchmarks
2526
* _7BIT_DI_BUILD_SINGLE_HEADER: ["ON", "OFF"] ("OFF") - Turn on to build single header SevenBitDI.hpp (requires Quom_ to be installed)
2627
* _7BIT_DI_INSTALL: ["ON", "OFF"] ("OFF") - Turn on to install the library
2728

@@ -39,45 +40,10 @@ Build the library using the command:
3940
cmake --build .
4041
4142
42-
Build Library With Conan
43-
^^^^^^^^^^^^^^^^^^^^^^^^^
44-
45-
Gtest_ library is added to project using Conan_ package manager (`Conan Installation`_),
46-
If Conan was freshly installed run detect command:
47-
48-
.. code-block:: sh
49-
50-
conan profile detect
51-
52-
To install Conan packages run this command in the library root folder:
53-
54-
.. code-block:: sh
55-
56-
conan install . --output-folder=build --build=missing
57-
58-
Navigate to the build directory:
59-
60-
.. code-block:: sh
61-
62-
cd build
63-
64-
Configure the CMake project, and add also toolchain file as a CMAKE_TOOLCHAIN_FILE cache variable:
65-
66-
.. code-block:: sh
67-
68-
cmake .. -DCMAKE_TOOLCHAIN_FILE:PATH="./conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release -D_7BIT_DI_BUILD_TESTS=ON
69-
70-
Build the library using the command:
71-
72-
.. code-block:: sh
73-
74-
cmake --build .
75-
76-
7743
Install Library
7844
^^^^^^^^^^^^^^^^^^^^^^^^^
7945

80-
To install the library set additional cache variables _7BIT_DI_BUILD_TESTS=ON and specify installation dir with CMAKE_INSTALL_PREFIX, then run the command
46+
To install the library set additional cache variables _7BIT_DI_INSTALL=ON and specify installation dir with CMAKE_INSTALL_PREFIX, then run the command
8147

8248
.. code-block:: sh
8349
@@ -91,4 +57,4 @@ To install the library set additional cache variables _7BIT_DI_BUILD_TESTS=ON an
9157
.. _Gtest: https://google.github.io/googletest/
9258
.. _Conan: https://conan.io/
9359
.. _Quom: https://pypi.org/project/quom/
94-
.. _`Conan Installation`: https://conan.io/downloads.html
60+
.. _`Conan Installation`: https://conan.io/downloads.html
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Using Aliases
2+
========================================
3+
4+
With the use of aliases, one service can be injected through its multiple base classes, also aliases can be chained.
5+
If multiple aliases are registered with the same base class only last will be used.
6+
7+
8+
.. literalinclude:: ../../Examples/Guides/ServiceAliases.cpp
9+
:caption: Examples/Guides/ServiceAliases
10+
:language: C++
11+
12+
.. code-block:: console
13+
:caption: Output
14+
15+
actionA from top service, actionB from top service executed.

Docs/advanced-guides/using-factories.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ Using Factories
22
========================================
33

44
Factory functor can be provided to manually create a service.
5-
Functor should return unique_ptr or T if object is movable/copyable and should optionally take other services as arguments.
5+
Functor should return unique_ptr or raw object if the type is movable/copyable and should optionally take other services as arguments.
6+
67
Functor scheme (Services...) -> std::unique_ptr< T> | T
7-
Where Services are pointers, in place objects (if object is movable or copyable), unique pointers, references, vectors with pointers or unique pointers
8+
Where Services are pointers, in-place objects (if an object is movable or copyable), unique pointers, references, vectors with pointers or unique pointers
89

910
.. literalinclude:: ../../Examples/Guides/FactoryFunctions.cpp
1011
:caption: Examples/Guides/FactoryFunctions

Docs/basic-guides/injecting-multiple-services.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Multiple services can inherit one interface and can be injected using a vector.
55

66
.. Note::
77
Service objects are ordered in vectors using registration order.
8-
The last registered service of base type is used when resolving one service
8+
The last registered service with the same base type is used when resolving one service
99

1010
Injection rules are simple:
1111

Docs/basic-guides/injecting-services.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This example shows the main purpose of this library, injecting services into ser
88

99
* Service should have one constructor
1010
* Singleton/scoped service should be injected using pointers or references
11-
* Transient services should be injected using std::unique_ptr
11+
* Transient services should be injected using std::unique_ptr or directly by type if an object is movable or copyable
1212

1313
.. literalinclude:: ../../Examples/Guides/InjectingServices.cpp
1414
:caption: Examples/Guides/InjectingServices

Docs/basic-guides/injection-rules.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ Injecting Services
1414
---------------------
1515
* Singleton/scoped services can be injected using one of:
1616
* References: (T&)
17-
* Const references: (const T&)
1817
* Pointers: (T*)
19-
* Const pointer: (T* const)
20-
* Pointer to const object: (const T*)
21-
* Const pointer to const object: (const T* const)
2218
* Transient services can be injected using one of:
2319
* std::unique_ptr: (unique_ptr<T>)
24-
* In place object if type is movable or copyable: T
25-
* Multiple services implementing specified interface can be injected using std::vector:
20+
* In-place object if type is movable or copyable: T
21+
* Multiple services implementing the same interface can be injected using std::vector:
2622
* Transient (std::vector<std::unique_ptr<T>>)
2723
* Singleton/scoped (std::vector<T*>)
2824

Docs/basic-guides/services-lifetime.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ Service providers can create scoped service providers:
99
1010
ServiceProvider scoped = provider.createScope()
1111
12+
.. warning::
13+
Root/main service provider cannot be destroyed before its children scoped providers this can lead to undefined behavior
14+
1215
Service can be registered as a singleton, scoped, or transient.
1316

1417
* Singleton: service provider will create only one instance of this service (accessible via the getService method)
1518
* Scoped: instance provider will create only one instance of this instance for each scope (accessible via the getService method)
16-
* Transient: services are always unique, a new service is provided every time it is requested, and the service provider returns, in this case, std::unique_ptr (accessible via createService method)
19+
* Transient: services are always unique, a new service is provided every time it is requested (accessible via createService or createInstanceInPlace method)
1720

1821
.. warning::
19-
Only transient services can be created using createInstance method otherwise the method will throw an exception
22+
Only transient services can be created using createInstance/createInstanceInPlace method otherwise the method will throw an exception
2023

2124
Only singleton/scoped services can be accessed using the getService method otherwise the method will throw an exception
2225

Docs/getting-started.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ Installation
4848
.. code-block:: Txt
4949
5050
[requires]
51-
7bitdi/2.0.0
51+
7bitdi/2.1.0
5252
5353
change the version to newer if available, then run the command:
5454

5555
.. code-block:: sh
5656
5757
conan install . --output-folder=build --build=missing
5858
59-
Follow in detail instructions available at `Conan Tutorial`_
59+
Follow in detailed instructions available at `Conan Tutorial`_
6060

6161
#. Header only
6262
Download source code from the most recent release,

Docs/reference/di.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ sb::di
1313
di/servicecollection
1414
di/servicedescriber
1515
di/servicedescriptor
16+
di/serviceinstance
1617
di/servicelifetime
18+
di/servicelifetimes
1719
di/serviceprovider
1820
di/serviceprovideroptions
1921
di/typeid

0 commit comments

Comments
 (0)