Skip to content

Commit 0309ebb

Browse files
committed
update examples and doc
1 parent 0a14e31 commit 0309ebb

25 files changed

+284
-30
lines changed

Docs/advanced-guides/building-library.rst

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,76 @@
1-
Building Library
1+
Build Library
22
==========================
33

4-
The library can be built locally using Cmake_ (`Cmake Installation`_), and several cache variables can be set:
4+
The library can be built locally using Cmake_ (`Cmake Installation`_)
5+
6+
Create build directory and navigate to it:
7+
8+
.. code-block:: sh
9+
10+
mkdir build && cd build
11+
12+
Configure cmake project
13+
14+
.. code-block:: sh
15+
16+
cmake .. -DCMAKE_BUILD_TYPE=Debug
17+
18+
Using this command several cache variables can be set:
519

620
* <variable cache name>: [possible values] (default value) - Description
721
* LIBRARY_TYPE: ["Shared", "Static", "HeaderOnly"] ("HeaderOnly") - Library build type
822
* BUILD_DOCS: [true, false] (false) - Turn on to build documentation (requires Sphinx_, Breathe_ and Doxygen_ installed)
9-
* BUILD_TESTS: [true, false] (false) - Turn on to build tests (requires Gtest_ to be installed, see `Conan Packages Installation`_)
23+
* BUILD_TESTS: [true, false] (false) - Turn on to build tests (requires Gtest_ to be installed, see `Build Library With Conan`_)
1024
* BUILD_EXAMPLES: [true, false] (false) - Turn on to build examples
1125

12-
build the library using the command:
26+
to set cache variable pass additional option: -D<variable cache name>=[value]
27+
for example this command will set library type to Static and will force examples built
1328

1429
.. code-block:: sh
1530
16-
cmake --build ./build
31+
cmake .. -DCMAKE_BUILD_TYPE=Release -DLIBRARY_TYPE=Static -DBUILD_EXAMPLES=true
32+
33+
Build the library using the command:
34+
35+
.. code-block:: sh
1736
37+
cmake --build .
1838
19-
Conan Packages Installation
39+
40+
Build Library With Conan
2041
^^^^^^^^^^^^^^^
2142

2243
Gtest_ library is added to project using Conan_ package manager (`Conan Installation`_),
23-
to install Conan packages run this command in the library root folder:
44+
If conan was fresh installed run detect command:
45+
46+
.. code-block:: sh
47+
48+
conan profile detect
49+
50+
To install Conan packages run this command in the library root folder:
2451

2552
.. code-block:: sh
2653
2754
conan install . --output-folder=build --build=missing
2855
56+
Navigate to build directory:
57+
58+
.. code-block:: sh
59+
60+
cd build
61+
62+
Configure cmake project, add also toolchain file as a CMAKE_TOOLCHAIN_FILE cache variable:
63+
64+
.. code-block:: sh
65+
66+
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=true -DCMAKE_TOOLCHAIN_FILE:STRING="conan_toolchain.cmake"
67+
68+
Build the library using the command:
69+
70+
.. code-block:: sh
71+
72+
cmake --build .
73+
2974
.. _Cmake: https://cmake.org/
3075
.. _`Cmake Installation`: https://cmake.org/download/
3176
.. _Sphinx: https://www.sphinx-doc.org/en/master/

Docs/advanced-guides/external-singleton.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ External Singleton
33

44
Singleton can be registered externally
55

6-
.. literalinclude:: ../../Examples/ExternalSingleton.cpp
7-
:caption: Examples/ExternalSingleton
6+
.. literalinclude:: ../../Examples/Guides/ExternalSingleton.cpp
7+
:caption: Examples/Guides/ExternalSingleton
88
:language: C++
99

1010
.. code-block:: console

Docs/advanced-guides/using-factories.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
Using Factories
22
========================================
33

4-
Factory functor can be provided to manually create a service. Functor should return unique_ptr and as an argument should optionally take reference to the service provider.
4+
Factory functor can be provided to manually create a service.
5+
Functor should return unique_ptr and as an argument should optionally take reference to the service provider.
56
Functor scheme (IServiceProvider &) -> std::unique_ptr or () -> std::unique_ptr
67

7-
.. literalinclude:: ../../Examples/FactoryFunctions.cpp
8-
:caption: Examples/FactoryFunctions
8+
.. literalinclude:: ../../Examples/Guides/FactoryFunctions.cpp
9+
:caption: Examples/Guides/FactoryFunctions
910
:language: C++
1011

1112
.. code-block:: console

Docs/basic-guides/core-classes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ The library relies on two core classes:
99
.. _ServiceCollection: ../reference/di/servicecollection.html
1010
.. _IServiceProvider: ../reference/di/iserviceprovider.html
1111

12-
.. literalinclude:: ../../Examples/CoreClasses.cpp
13-
:caption: Examples/Basic
12+
.. literalinclude:: ../../Examples/Guides/CoreClasses.cpp
13+
:caption: Examples/Guides/Basic
1414
:language: C++

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Multiple services can inherit one interface and can be injected using a vector.
1414
* Transient services should be injected using std::vector<std::unique_ptr>
1515

1616

17-
.. literalinclude:: ../../Examples/InjectingMultipleServices.cpp
18-
:caption: Examples/InjectingMultipleServices
17+
.. literalinclude:: ../../Examples/Guides/InjectingMultipleServices.cpp
18+
:caption: Examples/Guides/InjectingMultipleServices
1919
:language: C++
2020

2121
.. code-block:: console

Docs/basic-guides/injecting-service-provider.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Injecting Service Provider
33

44
Service Provider object can be injected and can be used to manually get (scoped/singletons) or create (transient) services.
55

6-
.. literalinclude:: ../../Examples/InjectingServiceProvider.cpp
7-
:caption: Examples/InjectingServiceProvider
6+
.. literalinclude:: ../../Examples/Guides/InjectingServiceProvider.cpp
7+
:caption: Examples/Guides/InjectingServiceProvider
88
:language: C++
99

1010
.. code-block:: console

Docs/basic-guides/injecting-services.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ This example shows the main purpose of this library, injecting services into ser
1111
* Singleton/scoped service should be injected using pointners (references are not allowed due to library limitations, it might be fixed in the future)
1212
* Transient services should be injected using std::unique_ptr
1313

14-
.. literalinclude:: ../../Examples/InjectingServices.cpp
15-
:caption: Examples/InjectingServices
14+
.. literalinclude:: ../../Examples/Guides/InjectingServices.cpp
15+
:caption: Examples/Guides/InjectingServices
1616
:language: C++
1717

1818
.. code-block:: console

Docs/basic-guides/injection-rules.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Injecting Services
2626
* Transient (std::vector<std::unique_ptr<T>>)
2727
* Singleton/scoped (std::vector<T*>)
2828

29-
.. literalinclude:: ../../Examples/InjectionRules.cpp
30-
:caption: Examples/InjectionRules
29+
.. literalinclude:: ../../Examples/Guides/InjectionRules.cpp
30+
:caption: Examples/Guides/InjectionRules
3131
:language: C++
3232

3333

Docs/basic-guides/separate-implementation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Separate Implementation
44
This example shows how to register the service as an interface with implementation.
55
Service will be accessible only by an interface, implementation is hidden for the client
66

7-
.. literalinclude:: ../../Examples/SeparateImplementation.cpp
8-
:caption: Examples/SeparateImplementation
7+
.. literalinclude:: ../../Examples/Guides/SeparateImplementation.cpp
8+
:caption: Examples/Guides/SeparateImplementation
99
:language: C++
1010

1111
.. code-block:: console

Docs/basic-guides/services-lifetime.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Service can be registered as singleton, scoped or transient.
2020

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

23-
.. literalinclude:: ../../Examples/ServicesLifeTime.cpp
24-
:caption: Examples/ServicesLifeTime
23+
.. literalinclude:: ../../Examples/Guides/ServicesLifeTime.cpp
24+
:caption: Examples/Guides/ServicesLifeTime
2525
:language: C++
2626

2727
.. code-block:: console

0 commit comments

Comments
 (0)