From 394c55ae5c7b5a8381018caaf2409b036fdd8da0 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 16 Mar 2025 10:46:06 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D0=BA=D0=B8=D0=B4=D0=B0=D1=82=D1=8C=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 ++ project.qbs | 4 +- qbs/modules/odbModule/odbModule.qbs | 19 +++++++++- redkbuild | 1 + src/cpp-opds.qbs | 26 +------------ src/{ => database}/author_s.h | 4 +- src/{ => database}/book_s.h | 4 +- src/{ => database}/database.hxx | 0 src/database/database.qbs | 52 ++++++++++++++++++++++++++ src/{ => database}/databasemanager.cpp | 0 src/{ => database}/databasemanager.h | 2 +- src/main.cpp | 15 ++++---- src/restapi/restapi.qbs | 31 +++++++++++++++ src/{ => restapi}/restapiserver.cpp | 7 ++-- src/{ => restapi}/restapiserver.h | 3 +- 15 files changed, 129 insertions(+), 42 deletions(-) create mode 100644 .gitmodules create mode 160000 redkbuild rename src/{ => database}/author_s.h (94%) rename src/{ => database}/book_s.h (91%) rename src/{ => database}/database.hxx (100%) create mode 100644 src/database/database.qbs rename src/{ => database}/databasemanager.cpp (100%) rename src/{ => database}/databasemanager.h (97%) create mode 100644 src/restapi/restapi.qbs rename src/{ => restapi}/restapiserver.cpp (97%) rename src/{ => restapi}/restapiserver.h (87%) diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..223e5c9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "redkbuild"] + path = redkbuild + url = ssh://git@gitea.redkit-lab.work:57322/redkit-lab/redkbuild.git diff --git a/project.qbs b/project.qbs index 11f7f19..a7628b6 100644 --- a/project.qbs +++ b/project.qbs @@ -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", ] } diff --git a/qbs/modules/odbModule/odbModule.qbs b/qbs/modules/odbModule/odbModule.qbs index 0cd4980..1f0837c 100644 --- a/qbs/modules/odbModule/odbModule.qbs +++ b/qbs/modules/odbModule/odbModule.qbs @@ -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" + ] } diff --git a/redkbuild b/redkbuild new file mode 160000 index 0000000..260497a --- /dev/null +++ b/redkbuild @@ -0,0 +1 @@ +Subproject commit 260497af1461d519122f8bdcb3909fa4339950f9 diff --git a/src/cpp-opds.qbs b/src/cpp-opds.qbs index bea1d78..c1f36a7 100644 --- a/src/cpp-opds.qbs +++ b/src/cpp-opds.qbs @@ -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 diff --git a/src/author_s.h b/src/database/author_s.h similarity index 94% rename from src/author_s.h rename to src/database/author_s.h index 0dc1949..2a5487b 100644 --- a/src/author_s.h +++ b/src/database/author_s.h @@ -4,6 +4,8 @@ #ifndef AUTHOR_S_H #define AUTHOR_S_H +// #include + #include // std::size_t #include #include @@ -13,7 +15,7 @@ #include #pragma db object -class Author_S +class __attribute__((visibility("default"))) Author_S { public: Author_S() = default; diff --git a/src/book_s.h b/src/database/book_s.h similarity index 91% rename from src/book_s.h rename to src/database/book_s.h index bb34c7b..a09ac73 100644 --- a/src/book_s.h +++ b/src/database/book_s.h @@ -4,6 +4,8 @@ #ifndef BOOK_S_H #define BOOK_S_H +// #include + #include #include @@ -12,7 +14,7 @@ #include "author_s.h" #pragma db object -class Book_S +class __attribute__((visibility("default"))) Book_S { public: Book_S() = default; diff --git a/src/database.hxx b/src/database/database.hxx similarity index 100% rename from src/database.hxx rename to src/database/database.hxx diff --git a/src/database/database.qbs b/src/database/database.qbs new file mode 100644 index 0000000..87b0a38 --- /dev/null +++ b/src/database/database.qbs @@ -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" + ] +} diff --git a/src/databasemanager.cpp b/src/database/databasemanager.cpp similarity index 100% rename from src/databasemanager.cpp rename to src/database/databasemanager.cpp diff --git a/src/databasemanager.h b/src/database/databasemanager.h similarity index 97% rename from src/databasemanager.h rename to src/database/databasemanager.h index f7be5ad..5d1b844 100644 --- a/src/databasemanager.h +++ b/src/database/databasemanager.h @@ -35,7 +35,7 @@ struct SelectBuilder } }; -class DatabaseManager +class Q_DECL_EXPORT DatabaseManager { public: static DatabaseManager& instance(); // Singleton diff --git a/src/main.cpp b/src/main.cpp index 7d8945b..f9a7275 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,17 +1,16 @@ #include -#include "restapiserver.h" +#include /* Опыты с odb */ -#include "author_s-odb.hxx" // Должен быть здесь -#include "author_s.h" - -#include "book_s-odb.hxx" // Должен быть здесь -#include "book_s.h" - +#include // Должен быть здесь +#include +#include // Должен быть здесь +#include +#include // create_database #include -#include "database.hxx" // create_database +#include using unidb = std::unique_ptr; diff --git a/src/restapi/restapi.qbs b/src/restapi/restapi.qbs new file mode 100644 index 0000000..6d99fdb --- /dev/null +++ b/src/restapi/restapi.qbs @@ -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 diff --git a/src/restapiserver.cpp b/src/restapi/restapiserver.cpp similarity index 97% rename from src/restapiserver.cpp rename to src/restapi/restapiserver.cpp index bdde6dd..da06f3d 100644 --- a/src/restapiserver.cpp +++ b/src/restapi/restapiserver.cpp @@ -5,15 +5,16 @@ #include #include -#include "book_s-odb.hxx" -#include "book_s.h" +#include + +#include "database/book_s-odb.hxx" #include #include #include RestApiServer::RestApiServer(odb::database& db, QObject* parent) : - m_db(db), QTcpServer(parent) {} + QTcpServer(parent), m_db(db) {} void RestApiServer::start(quint16 port) { diff --git a/src/restapiserver.h b/src/restapi/restapiserver.h similarity index 87% rename from src/restapiserver.h rename to src/restapi/restapiserver.h index 33232d9..a742100 100644 --- a/src/restapiserver.h +++ b/src/restapi/restapiserver.h @@ -3,10 +3,11 @@ #include +#include #include #include -class RestApiServer : public QTcpServer +class Q_DECL_EXPORT RestApiServer : public QTcpServer { Q_OBJECT public: