Skip to content

Commit 9061472

Browse files
committed
update cmake
1 parent fe2b570 commit 9061472

File tree

2 files changed

+125
-5
lines changed

2 files changed

+125
-5
lines changed

Docs/getting-started.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Installation
2727
**There are a few ways of installation:**
2828

2929

30-
#. Using Cmake fetch content api - Option in progress
30+
#. Using Cmake fetch content api - Recommended
3131
Update CMakeLists.txt file with following code
3232

3333
.. code-block:: Cmake
@@ -36,17 +36,17 @@ Installation
3636
FetchContent_Declare(
3737
7bitDI
3838
GIT_REPOSITORY https://github.com/7bitcoder/7bitDI.git
39-
GIT_TAG 86228173f14f449dde88a84c549474ba43c2fd25 # release-1.0.0
39+
GIT_TAG 86228173f14f449dde88a84c549474ba43c2fd25 # proper release tag for example 1.0.0
4040
)
4141
FetchContent_MakeAvailable(7bitDI)
4242
43-
#. Using Conan.io package manager - Recommended
43+
#. Using Conan.io package manager
4444
Download and install Conan_, and create conanfile.txt in the root of your project for example:
4545

4646
.. code-block:: Txt
4747
4848
[requires]
49-
7bitdi/1.0.0
49+
7bitdi/2.0.0
5050
5151
change the version to newer if available, then run the command:
5252

README.md

+121-1
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,130 @@
2121

2222
<br />
2323

24-
### Built With
24+
## Built With
2525

2626
- [Google Test](https://github.com/google/googletest)
2727

28+
## Supported Platforms
29+
30+
7bitDI requires client code and compiler compatible with the C++17 standard or newer.
31+
32+
The library is officially supported on the following platforms:
33+
34+
**Operating systems:**
35+
36+
* Linux
37+
* macOS
38+
* Windows
39+
40+
**Compilers:**
41+
42+
* gcc 7.0+
43+
* clang 6.0+
44+
* MSVC 2015+
45+
46+
If you notice any problems/bugs, please file an issue on the repository GitHub Issue Tracker. Pull requests containing
47+
fixes are welcome!
48+
49+
## Installation
50+
51+
**There are a few ways of installation:**
52+
53+
### 1. Using Cmake fetch content api - Recommended
54+
55+
Update CMakeLists.txt file with following code
56+
57+
```cmake
58+
include(FetchContent)
59+
FetchContent_Declare(
60+
7bitDI
61+
GIT_REPOSITORY https://github.com/7bitcoder/7bitDI.git
62+
GIT_TAG 86228173f14f449dde88a84c549474ba43c2fd25 # proper release tag for example 1.0.0
63+
)
64+
FetchContent_MakeAvailable(7bitDI)
65+
```
66+
67+
### 2. Using Conan.io package manager
68+
69+
Download and install A [Conan](https://conan.io/), and create conanfile.txt in the root of your project for example:
70+
71+
```txt
72+
[requires]
73+
7bitdi/2.0.0
74+
```
75+
76+
change the version to newer if available, then run the command:
77+
78+
```sh
79+
conan install . --output-folder=build --build=missing
80+
```
81+
82+
### 3. Header only
83+
84+
Download source code from the most recent release,
85+
copy include folder into your project location,
86+
for example copy into the '/SevenBitDI' folder.
87+
Include this folder into the project, with [Cmake](https://cmake.org/), u can use:
88+
89+
```cmake
90+
include_directories(/SevenBitDI/Include)
91+
```
92+
93+
### 4. Header only - Single file
94+
95+
Download SevenBitDI.hpp header file from the most recent release,
96+
copy this file into your project location and include it.
97+
98+
### 5. Building library as Static/Shared
99+
100+
Download source code from the most recent release, build or install the project using [Cmake](https://cmake.org/)_,
101+
for more details see the Building Library guide
102+
in [Documentation](https://7bitdi.readthedocs.io/en/latest/getting-started.html).
103+
104+
### The library relies on two core classes:
105+
106+
* ServiceCollection: class is responsible for registering services and building service provider
107+
* ServiceProvider: class is responsible for delivering real services and managing its lifetime
108+
109+
## Injection Rules
110+
111+
The dependency injection mechanism relies heavily on template metaprogramming and it has some limitations.
112+
113+
### General
114+
115+
* Only one constructor should be defined for each instance implementation
116+
* If the service is registered with interface and implementation, the interface should have a virtual destructor
117+
* If multiple services are registered by the same interface, all should have the same lifetime (the build method will
118+
throw an exception)
119+
* Only one service implementation can be registered (the build method will throw an exception)
120+
121+
### Injecting Services
122+
123+
* Services cannot be injected by value: (T)
124+
* Singleton/scoped services can be injected using one of:
125+
* References: (T&)
126+
* Const references: (const T&)
127+
* Pointers: (T*)
128+
* Const pointer: (T* const)
129+
* Pointer to const object: (const T*)
130+
* Const pointer to const object: (const T* const)
131+
* Transient services can be injected using std::unique_ptr: (unique_ptr<T>) or directly T if object is movable or
132+
copyable
133+
* Multiple services implementing specified interface can be injected using std::vector:
134+
* Transient (std::vector<std::unique_ptr<T>>)
135+
* Singleton/scoped (std::vector<T*>)
136+
137+
### Injection Table
138+
139+
| Constructor param type | ServiceProvider method used |
140+
|---------------------------------|------------------------------------|
141+
| T - if movable or copyable | provider.createServiceInPlace<T>() |
142+
| std::unique_ptr<T> | provider.createService<T>() |
143+
| T& | provider.getService<T>() |
144+
| T* | provider.tryGetService<T>() |
145+
| std::vector<T*> | provider.getServices<T>() |
146+
| std::vector<std::unique_ptr<T>> | provider.createServices<T>() |
147+
28148
### Sample Usage
29149

30150
```cpp

0 commit comments

Comments
 (0)