mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-04-27 02:04:38 +00:00
add usage information
This commit is contained in:
parent
141c95fa08
commit
4bf84707a7
105
README.md
105
README.md
@ -12,8 +12,50 @@ This library consists of two levels (AbstractNode level and DataBaseNode level).
|
||||
### AbstractNode level (1)
|
||||
#### Description
|
||||
The AbstractNode level implement only base functons of create new work threads and parsing packages.
|
||||
Example of use AbstractNode level
|
||||
|
||||
For more information see QuasarApp Heart documentation.
|
||||
|
||||
### DataBaseNode level (2)
|
||||
#### Description
|
||||
The DataBaseNode level implement methods and packages for work with databases. This level using Qt classes for wrking with database, so for more information about suport databases see [Qt Documentation](https://doc.qt.io/qt-5/sql-driver.html).
|
||||
|
||||
### NetworkNode level (3)
|
||||
#### Description
|
||||
This level is still in develop.
|
||||
|
||||
## Build and Include
|
||||
|
||||
### For cmake projects
|
||||
|
||||
* cd yourRepo
|
||||
* git submodule add https://github.com/QuasarApp/Heart.git # add the repository of Heart into your repo like submodule
|
||||
* git submodule update --init --recursive
|
||||
* Include in your CMakeLists.txt file the main CMakeLists.txt file of Heart library
|
||||
``` cmake
|
||||
add_subdirectory(Heart)
|
||||
```
|
||||
* select requiriment build level for you project
|
||||
```
|
||||
set(HEART_BUILD_LVL 2)
|
||||
```
|
||||
where 1 - is code of build level
|
||||
|
||||
1 - AbstractNode
|
||||
|
||||
2 - DataBaseNode
|
||||
|
||||
3 - NetworkNode
|
||||
* link the Heart library to your target
|
||||
```cmake
|
||||
target_link_libraries(yourLib PUBLIC Heart)
|
||||
```
|
||||
* rebuild yuor project
|
||||
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Create a own package class and override some basic methods.
|
||||
```cpp
|
||||
|
||||
class MyPackage: public QH::AbstractData
|
||||
@ -60,7 +102,10 @@ protected:
|
||||
}
|
||||
|
||||
};
|
||||
```
|
||||
|
||||
Create a server class and override parsePackage method for work with packages.
|
||||
```cpp
|
||||
class TestingServer: public QH::AbstractNode {
|
||||
|
||||
|
||||
@ -93,12 +138,17 @@ protected:
|
||||
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
Create a client class and override parsePackage method for work with packages.
|
||||
|
||||
```cpp
|
||||
|
||||
class TestingClient: public QH::AbstractNode {
|
||||
|
||||
|
||||
protected:
|
||||
// parsing incoming packages
|
||||
ParserResult DataBaseNode::parsePackage(const Package &pkg,
|
||||
const AbstractNodeInfo *sender) {
|
||||
|
||||
@ -110,14 +160,16 @@ protected:
|
||||
if (H_16<MyPackage>() == pkg.hdr.command) {
|
||||
MyPackage obj(pkg);
|
||||
|
||||
// print responce of server
|
||||
std::cout << obj._data;
|
||||
...
|
||||
return ParserResult::Processed;
|
||||
}
|
||||
// Do not forget return status of parsing packages
|
||||
return ParserResult::NotProcessed;
|
||||
|
||||
}
|
||||
|
||||
// sending request to server
|
||||
bool sendMyPackage() {
|
||||
Ping cmd;
|
||||
return sendData(&cmd, address);
|
||||
@ -125,54 +177,5 @@ protected:
|
||||
};
|
||||
```
|
||||
|
||||
For more information see QuasarApp Heart documentation.
|
||||
|
||||
### DataBaseNode level (2)
|
||||
#### Description
|
||||
The DataBaseNode level implement methods and packages for work with databases. This level using Qt classes for wrking with database, so for more information about suport databases see [Qt Documentation](https://doc.qt.io/qt-5/sql-driver.html).
|
||||
|
||||
Example of use DataBaseNode level
|
||||
|
||||
```cpp
|
||||
EXAMPLE
|
||||
```
|
||||
### NetworkNode level (3)
|
||||
#### Description
|
||||
This level is still in develop.
|
||||
|
||||
## Build and Include
|
||||
|
||||
### For cmake projects
|
||||
|
||||
* cd yourRepo
|
||||
* git submodule add https://github.com/QuasarApp/Heart.git # add the repository of Heart into your repo like submodule
|
||||
* git submodule update --init --recursive
|
||||
* Include in your CMakeLists.txt file the main CMakeLists.txt file of Heart library
|
||||
``` cmake
|
||||
add_subdirectory(Heart)
|
||||
```
|
||||
* select requiriment build level for you project
|
||||
```
|
||||
set(HEART_BUILD_LVL 2)
|
||||
```
|
||||
where 1 - is code of build level
|
||||
|
||||
1 - AbstractNode
|
||||
|
||||
2 - DataBaseNode
|
||||
|
||||
3 - NetworkNode
|
||||
* link the Heart library to your target
|
||||
```cmake
|
||||
target_link_libraries(yourLib PUBLIC Heart)
|
||||
```
|
||||
* rebuild yuor project
|
||||
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
To-do
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user