Попытка раскидать по библиотекам

This commit is contained in:
2025-03-16 10:46:06 +05:00
parent d47988adda
commit 394c55ae5c
15 changed files with 129 additions and 42 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "redkbuild"]
path = redkbuild
url = ssh://git@gitea.redkit-lab.work:57322/redkit-lab/redkbuild.git

View File

@@ -8,12 +8,14 @@ Project {
// // "guiness/qbs",
// // "prerequisites/qbs",
// // "report/qbs",
// "redkbuild",
"redkbuild",
// // "ext_libs/openssl/qbs",
// "redkitty/lib/redkit-gen-integration/qbs",
]
references: [
"src/cpp-opds.qbs",
"src/database/database.qbs",
"src/restapi/restapi.qbs",
]
}

View File

@@ -35,6 +35,7 @@ Module {
// "--include-prefix", FileInfo.cleanPath(input.filePath + "/../"),
// "--output-dir", product.Qt.core.qmDir,
"--output-dir", FileInfo.cleanPath(input.filePath + "/../"),
"-I/home/uzver/qt5.15/include",
input.filePath,
]);
cmd.description = "Generating ODB files for " + input.fileName;
@@ -44,5 +45,21 @@ Module {
return [cmd];
}
}
cpp.includePaths: [ project.sourceDirectory, product.Qt.core.qmDir ]
cpp.includePaths: [
project.sourceDirectory,
product.Qt.core.qmDir,
"/usr/include", // Общие заголовки
"/usr/include/odb" // Заголовки ODB
]
// Подключаем библиотеки ODB
cpp.libraryPaths: [
"/usr/lib" // Путь к библиотекам
]
cpp.dynamicLibraries: [
"odb",
"odb-sqlite"
]
}

1
redkbuild Submodule

Submodule redkbuild added at 260497af14

View File

@@ -15,6 +15,7 @@ Application {
Depends { name: "Qt"; submodules: [ "core", "sql", "network" ] }
Depends { name: "cpp" }
Depends { name: "database" }
Depends { name: "odbModule"}
// Depends { name: "redkit_gen" }
@@ -24,35 +25,10 @@ Application {
Group {
name: "cpp"
files: [
"books.*",
"databasemanager.*",
"main.cpp",
"restapiserver.*",
]
}
Group {
name: "odb"
files: [
"author_s.h",
"book_s.h",
]
fileTags: ["odb"]
}
cpp.includePaths: [
"/usr/include", // Общие заголовки
"/usr/include/odb" // Заголовки ODB
]
// Подключаем библиотеки ODB
cpp.libraryPaths: [
"/usr/lib" // Путь к библиотекам
]
cpp.dynamicLibraries: [
"odb",
"odb-sqlite"
]
// }
} // Project

View File

@@ -4,6 +4,8 @@
#ifndef AUTHOR_S_H
#define AUTHOR_S_H
// #include <QtCore/QObject>
#include <cstddef> // std::size_t
#include <memory>
#include <string>
@@ -13,7 +15,7 @@
#include <odb/query.hxx>
#pragma db object
class Author_S
class __attribute__((visibility("default"))) Author_S
{
public:
Author_S() = default;

View File

@@ -4,6 +4,8 @@
#ifndef BOOK_S_H
#define BOOK_S_H
// #include <QtCore/QObject>
#include <memory>
#include <string>
@@ -12,7 +14,7 @@
#include "author_s.h"
#pragma db object
class Book_S
class __attribute__((visibility("default"))) Book_S
{
public:
Book_S() = default;

52
src/database/database.qbs Normal file
View File

@@ -0,0 +1,52 @@
/*!
\qmltype cpp-opds
\inherits Project
\brief Описание
*/
PSLibrary {
cpp.defines: [
// You can make your code fail to compile if it uses deprecated APIs.
// In order to do so, uncomment the following line.
//"QT_DISABLE_DEPRECATED_BEFORE=0x060000" // disables all the APIs deprecated before Qt 6.0.0
"DATABASE_SQLITE"
]
consoleApplication: true
Depends { name: "Qt"; submodules: [ "core", "sql", "network" ] }
Depends { name: "cpp" }
Depends { name: "odbModule"}
cpp.cxxLanguageVersion: "c++20"
Group {
name: "cpp"
files: [
"books.*",
"databasemanager.*",
]
}
Group {
name: "odb"
files: [
"author_s.h",
"book_s.h",
]
fileTags: ["odb"]
}
cpp.includePaths: [
"/usr/include", // Общие заголовки
"/usr/include/odb" // Заголовки ODB
]
// Подключаем библиотеки ODB
cpp.libraryPaths: [
"/usr/lib" // Путь к библиотекам
]
cpp.dynamicLibraries: [
"odb",
"odb-sqlite"
]
}

View File

@@ -35,7 +35,7 @@ struct SelectBuilder
}
};
class DatabaseManager
class Q_DECL_EXPORT DatabaseManager
{
public:
static DatabaseManager& instance(); // Singleton

View File

@@ -1,17 +1,16 @@
#include <QCoreApplication>
#include "restapiserver.h"
#include <restapi/restapiserver.h>
/* Опыты с odb */
#include "author_s-odb.hxx" // Должен быть здесь
#include "author_s.h"
#include "book_s-odb.hxx" // Должен быть здесь
#include "book_s.h"
#include <database/author_s-odb.hxx> // Должен быть здесь
#include <database/author_s.h>
#include <database/book_s-odb.hxx> // Должен быть здесь
#include <database/book_s.h>
#include <database/database.hxx> // create_database
#include <odb/database.hxx>
#include "database.hxx" // create_database
#include <iostream>
using unidb = std::unique_ptr<odb::database>;

31
src/restapi/restapi.qbs Normal file
View File

@@ -0,0 +1,31 @@
/*!
\qmltype cpp-opds
\inherits Project
\brief Описание
*/
PSLibrary {
cpp.defines: [
// You can make your code fail to compile if it uses deprecated APIs.
// In order to do so, uncomment the following line.
//"QT_DISABLE_DEPRECATED_BEFORE=0x060000" // disables all the APIs deprecated before Qt 6.0.0
"DATABASE_SQLITE"
]
consoleApplication: true
Depends { name: "Qt"; submodules: [ "core", "sql", "network" ] }
Depends { name: "cpp" }
Depends { name: "database" }
Depends { name: "odbModule"}
// Depends { name: "redkit_gen" }
cpp.cxxLanguageVersion: "c++20"
Group {
name: "cpp"
files: [
"restapiserver.*",
]
}
} // Project

View File

@@ -5,15 +5,16 @@
#include <QJsonObject>
#include <QJsonValue>
#include "book_s-odb.hxx"
#include "book_s.h"
#include <database/book_s.h>
#include "database/book_s-odb.hxx"
#include <odb/core.hxx>
#include <odb/database.hxx>
#include <odb/query.hxx>
RestApiServer::RestApiServer(odb::database& db, QObject* parent) :
m_db(db), QTcpServer(parent) {}
QTcpServer(parent), m_db(db) {}
void RestApiServer::start(quint16 port)
{

View File

@@ -3,10 +3,11 @@
#include <odb/database.hxx>
#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>
class RestApiServer : public QTcpServer
class Q_DECL_EXPORT RestApiServer : public QTcpServer
{
Q_OBJECT
public: