first commit
This commit is contained in:
7
test/qxClientServer/qxService/debug/debug_client/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/debug/debug_client/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
7
test/qxClientServer/qxService/debug/debug_server/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/debug/debug_server/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
23
test/qxClientServer/qxService/include/business_object/user.h
Normal file
23
test/qxClientServer/qxService/include/business_object/user.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _QX_SERVICE_BO_USER_H_
|
||||
#define _QX_SERVICE_BO_USER_H_
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT user
|
||||
{
|
||||
public:
|
||||
// -- contructor, virtual destructor
|
||||
user() : id(0) { ; }
|
||||
virtual ~user() { ; }
|
||||
// -- properties
|
||||
long id;
|
||||
QString first_name;
|
||||
QString last_name;
|
||||
QDateTime birth_date;
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(user, qx::trait::no_base_class_defined, 0)
|
||||
|
||||
typedef std::shared_ptr<user> user_ptr;
|
||||
typedef qx::QxCollection<long, user_ptr> list_of_users;
|
||||
typedef std::shared_ptr<list_of_users> list_of_users_ptr;
|
||||
|
||||
#endif // _QX_SERVICE_BO_USER_H_
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef _QX_SERVICE_BO_USER_SEARCH_H_
|
||||
#define _QX_SERVICE_BO_USER_SEARCH_H_
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT user_search
|
||||
{
|
||||
public:
|
||||
// -- contructor, virtual destructor
|
||||
user_search() { ; }
|
||||
virtual ~user_search() { ; }
|
||||
// -- properties
|
||||
QString first_name;
|
||||
QString last_name;
|
||||
QDateTime birth_date;
|
||||
// -- methods
|
||||
bool empty() const
|
||||
{ return (first_name.isEmpty() && last_name.isEmpty() && ! birth_date.isValid()); }
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(user_search, qx::trait::no_base_class_defined, 0)
|
||||
|
||||
typedef std::shared_ptr<user_search> user_search_ptr;
|
||||
|
||||
#endif // _QX_SERVICE_BO_USER_SEARCH_H_
|
||||
25
test/qxClientServer/qxService/include/dao/user_manager.h
Normal file
25
test/qxClientServer/qxService/include/dao/user_manager.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _QX_SERVICE_MODE_CLIENT
|
||||
#ifndef _QX_SERVICE_USER_MANAGER_H_
|
||||
#define _QX_SERVICE_USER_MANAGER_H_
|
||||
|
||||
#include "../../include/business_object/user.h"
|
||||
#include "../../include/business_object/user_search.h"
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT user_manager
|
||||
{
|
||||
public:
|
||||
user_manager() { user_manager::init_database(); }
|
||||
~user_manager() { ; }
|
||||
QSqlError insert(user_ptr p);
|
||||
QSqlError update(user_ptr p);
|
||||
QSqlError remove(user_ptr p);
|
||||
QSqlError remove_all();
|
||||
QSqlError fetch_by_id(user_ptr p);
|
||||
QSqlError fetch_all(list_of_users_ptr lst);
|
||||
QSqlError get_by_criteria(user_search_ptr criteria, list_of_users_ptr lst);
|
||||
private:
|
||||
static void init_database();
|
||||
};
|
||||
|
||||
#endif // _QX_SERVICE_USER_MANAGER_H_
|
||||
#endif // _QX_SERVICE_MODE_CLIENT
|
||||
18
test/qxClientServer/qxService/include/export.h
Normal file
18
test/qxClientServer/qxService/include/export.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _QX_SERVICE_EXPORT_H_
|
||||
#define _QX_SERVICE_EXPORT_H_
|
||||
|
||||
#ifdef _BUILDING_QX_SERVICE
|
||||
#define QX_SERVICE_DLL_EXPORT QX_DLL_EXPORT_HELPER
|
||||
#else // _BUILDING_QX_SERVICE
|
||||
#define QX_SERVICE_DLL_EXPORT QX_DLL_IMPORT_HELPER
|
||||
#endif // _BUILDING_QX_SERVICE
|
||||
|
||||
#ifdef _BUILDING_QX_SERVICE
|
||||
#define QX_REGISTER_HPP_QX_SERVICE QX_REGISTER_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_SERVICE QX_REGISTER_CPP_EXPORT_DLL
|
||||
#else // _BUILDING_QX_SERVICE
|
||||
#define QX_REGISTER_HPP_QX_SERVICE QX_REGISTER_HPP_IMPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_SERVICE QX_REGISTER_CPP_IMPORT_DLL
|
||||
#endif // _BUILDING_QX_SERVICE
|
||||
|
||||
#endif // _QX_SERVICE_EXPORT_H_
|
||||
9
test/qxClientServer/qxService/include/precompiled.h
Normal file
9
test/qxClientServer/qxService/include/precompiled.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef _QX_SERVICE_PRECOMPILED_HEADER_H_
|
||||
#define _QX_SERVICE_PRECOMPILED_HEADER_H_
|
||||
|
||||
#include <QxOrm.h>
|
||||
#include <QxServices.h>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#endif // _QX_SERVICE_PRECOMPILED_HEADER_H_
|
||||
34
test/qxClientServer/qxService/include/service/server_infos.h
Normal file
34
test/qxClientServer/qxService/include/service/server_infos.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _QX_SERVICE_SERVER_INFOS_H_
|
||||
#define _QX_SERVICE_SERVER_INFOS_H_
|
||||
|
||||
/* -- Service Input Parameters -- */
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT server_infos_input : public qx::service::IxParameter
|
||||
{ QX_SERVICE_IX_PARAMETER_SERIALIZATION_HPP(server_infos_input); };
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(server_infos_input, qx::service::IxParameter, 0)
|
||||
typedef std::shared_ptr<server_infos_input> server_infos_input_ptr;
|
||||
|
||||
/* -- Service Output Parameters -- */
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT server_infos_output : public qx::service::IxParameter
|
||||
{ public: QDateTime current_date_time; QX_SERVICE_IX_PARAMETER_SERIALIZATION_HPP(server_infos_output); };
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(server_infos_output, qx::service::IxParameter, 0)
|
||||
typedef std::shared_ptr<server_infos_output> server_infos_output_ptr;
|
||||
|
||||
/* -- Service Definition -- */
|
||||
|
||||
typedef qx::service::QxService<server_infos_input, server_infos_output> server_infos_base_class;
|
||||
class QX_SERVICE_DLL_EXPORT server_infos : public server_infos_base_class
|
||||
{
|
||||
public:
|
||||
server_infos() : server_infos_base_class("server_infos") { ; }
|
||||
virtual ~server_infos() { ; }
|
||||
void get_current_date_time();
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(server_infos, qx::service::IxService, 0)
|
||||
typedef std::shared_ptr<server_infos> server_infos_ptr;
|
||||
|
||||
#endif // _QX_SERVICE_SERVER_INFOS_H_
|
||||
56
test/qxClientServer/qxService/include/service/user_service.h
Normal file
56
test/qxClientServer/qxService/include/service/user_service.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef _QX_SERVICE_USER_SERVICE_H_
|
||||
#define _QX_SERVICE_USER_SERVICE_H_
|
||||
|
||||
#include "../../include/business_object/user.h"
|
||||
#include "../../include/business_object/user_search.h"
|
||||
|
||||
/* -- Service Input Parameters -- */
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT user_service_input : public qx::service::IxParameter
|
||||
{
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_HPP(user_service_input);
|
||||
public:
|
||||
user_service_input() : id(0) { ; }
|
||||
virtual ~user_service_input() { ; }
|
||||
long id;
|
||||
user_ptr user;
|
||||
user_search_ptr criteria;
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(user_service_input, qx::service::IxParameter, 0)
|
||||
typedef std::shared_ptr<user_service_input> user_service_input_ptr;
|
||||
|
||||
/* -- Service Output Parameters -- */
|
||||
|
||||
class QX_SERVICE_DLL_EXPORT user_service_output : public qx::service::IxParameter
|
||||
{
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_HPP(user_service_output);
|
||||
public:
|
||||
user_ptr user;
|
||||
list_of_users_ptr list_of_users;
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(user_service_output, qx::service::IxParameter, 0)
|
||||
typedef std::shared_ptr<user_service_output> user_service_output_ptr;
|
||||
|
||||
/* -- Service Definition -- */
|
||||
|
||||
typedef qx::service::QxService<user_service_input, user_service_output> user_service_base_class;
|
||||
class QX_SERVICE_DLL_EXPORT user_service : public user_service_base_class
|
||||
{
|
||||
public:
|
||||
user_service() : user_service_base_class("user_service") { ; }
|
||||
virtual ~user_service() { ; }
|
||||
void insert();
|
||||
void update();
|
||||
void remove();
|
||||
void remove_all();
|
||||
void fetch_by_id();
|
||||
void fetch_all();
|
||||
void get_by_criteria();
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_SERVICE(user_service, qx::service::IxService, 0)
|
||||
typedef std::shared_ptr<user_service> user_service_ptr;
|
||||
|
||||
#endif // _QX_SERVICE_USER_SERVICE_H_
|
||||
7
test/qxClientServer/qxService/qt/moc/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/qt/moc/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
7
test/qxClientServer/qxService/qt/rcc/src/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/qt/rcc/src/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
7
test/qxClientServer/qxService/qt/ui/include/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/qt/ui/include/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
7
test/qxClientServer/qxService/qt/ui/src/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/qt/ui/src/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
37
test/qxClientServer/qxService/qxService.pri
Normal file
37
test/qxClientServer/qxService/qxService.pri
Normal file
@@ -0,0 +1,37 @@
|
||||
include(../../../QxOrm.pri)
|
||||
|
||||
!contains(DEFINES, _QX_ENABLE_QT_NETWORK) {
|
||||
error(unable to use QxOrm QxService module : please define _QX_ENABLE_QT_NETWORK compilation option in QxOrm.pri configuration file)
|
||||
} # !contains(DEFINES, _QX_ENABLE_QT_NETWORK)
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += dll
|
||||
DEFINES += _BUILDING_QX_SERVICE
|
||||
INCLUDEPATH += ../../../../QxOrm/include/
|
||||
DESTDIR = ../../../../QxOrm/test/_bin/
|
||||
LIBS += -L"../../../../QxOrm/lib"
|
||||
|
||||
!contains(DEFINES, _QX_NO_PRECOMPILED_HEADER) {
|
||||
PRECOMPILED_HEADER = ./include/precompiled.h
|
||||
} # !contains(DEFINES, _QX_NO_PRECOMPILED_HEADER)
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
LIBS += -l"QxOrmd"
|
||||
} else {
|
||||
LIBS += -l"QxOrm"
|
||||
} # CONFIG(debug, debug|release)
|
||||
|
||||
HEADERS += ./include/precompiled.h
|
||||
HEADERS += ./include/export.h
|
||||
HEADERS += ./include/service/server_infos.h
|
||||
HEADERS += ./include/service/user_service.h
|
||||
HEADERS += ./include/business_object/user.h
|
||||
HEADERS += ./include/business_object/user_search.h
|
||||
HEADERS += ./include/dao/user_manager.h
|
||||
|
||||
SOURCES += ./src/service/server_infos.cpp
|
||||
SOURCES += ./src/service/user_service.cpp
|
||||
SOURCES += ./src/business_object/user.cpp
|
||||
SOURCES += ./src/business_object/user_search.cpp
|
||||
SOURCES += ./src/dao/user_manager.cpp
|
||||
SOURCES += ./src/main.cpp
|
||||
11
test/qxClientServer/qxService/qxServiceClient.pro
Normal file
11
test/qxClientServer/qxService/qxServiceClient.pro
Normal file
@@ -0,0 +1,11 @@
|
||||
include(./qxService.pri)
|
||||
|
||||
DEFINES += _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
OBJECTS_DIR = ./debug/debug_client/
|
||||
TARGET = qxServiceClientd
|
||||
} else {
|
||||
OBJECTS_DIR = ./release/release_client/
|
||||
TARGET = qxServiceClient
|
||||
} # CONFIG(debug, debug|release)
|
||||
64
test/qxClientServer/qxService/qxServiceClient/CMakeLists.txt
Normal file
64
test/qxClientServer/qxService/qxServiceClient/CMakeLists.txt
Normal file
@@ -0,0 +1,64 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(qxServiceClient LANGUAGES CXX)
|
||||
|
||||
include(../../../../QxOrm.cmake)
|
||||
|
||||
if(_QX_ENABLE_QT_NETWORK)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
set(HEADERS
|
||||
../include/precompiled.h
|
||||
../include/export.h
|
||||
../include/service/server_infos.h
|
||||
../include/service/user_service.h
|
||||
../include/business_object/user.h
|
||||
../include/business_object/user_search.h
|
||||
../include/dao/user_manager.h
|
||||
)
|
||||
|
||||
set(SRCS
|
||||
../src/service/server_infos.cpp
|
||||
../src/service/user_service.cpp
|
||||
../src/business_object/user.cpp
|
||||
../src/business_object/user_search.cpp
|
||||
../src/dao/user_manager.cpp
|
||||
../src/main.cpp
|
||||
)
|
||||
|
||||
add_library(qxServiceClient SHARED ${SRCS} ${HEADERS})
|
||||
|
||||
target_compile_definitions(qxServiceClient PRIVATE -D_BUILDING_QX_SERVICE -D_QX_SERVICE_MODE_CLIENT)
|
||||
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(qxServiceClient PRIVATE ../include/precompiled.h)
|
||||
endif() # (COMMAND target_precompile_headers)
|
||||
|
||||
target_link_libraries(qxServiceClient ${QX_LIBRARIES} QxOrm)
|
||||
|
||||
set_target_properties(qxServiceClient PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
)
|
||||
|
||||
else() # _QX_ENABLE_QT_NETWORK
|
||||
|
||||
message(STATUS "qxServiceClient project not loaded because _QX_ENABLE_QT_NETWORK option not enabled (QxOrm QxService module is disabled)")
|
||||
|
||||
endif() # _QX_ENABLE_QT_NETWORK
|
||||
9
test/qxClientServer/qxService/qxServiceServer.pro
Normal file
9
test/qxClientServer/qxService/qxServiceServer.pro
Normal file
@@ -0,0 +1,9 @@
|
||||
include(./qxService.pri)
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
OBJECTS_DIR = ./debug/debug_server/
|
||||
TARGET = qxServiceServerd
|
||||
} else {
|
||||
OBJECTS_DIR = ./release/release_server/
|
||||
TARGET = qxServiceServer
|
||||
} # CONFIG(debug, debug|release)
|
||||
64
test/qxClientServer/qxService/qxServiceServer/CMakeLists.txt
Normal file
64
test/qxClientServer/qxService/qxServiceServer/CMakeLists.txt
Normal file
@@ -0,0 +1,64 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(qxServiceServer LANGUAGES CXX)
|
||||
|
||||
include(../../../../QxOrm.cmake)
|
||||
|
||||
if(_QX_ENABLE_QT_NETWORK)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
set(HEADERS
|
||||
../include/precompiled.h
|
||||
../include/export.h
|
||||
../include/service/server_infos.h
|
||||
../include/service/user_service.h
|
||||
../include/business_object/user.h
|
||||
../include/business_object/user_search.h
|
||||
../include/dao/user_manager.h
|
||||
)
|
||||
|
||||
set(SRCS
|
||||
../src/service/server_infos.cpp
|
||||
../src/service/user_service.cpp
|
||||
../src/business_object/user.cpp
|
||||
../src/business_object/user_search.cpp
|
||||
../src/dao/user_manager.cpp
|
||||
../src/main.cpp
|
||||
)
|
||||
|
||||
add_library(qxServiceServer SHARED ${SRCS} ${HEADERS})
|
||||
|
||||
target_compile_definitions(qxServiceServer PRIVATE -D_BUILDING_QX_SERVICE)
|
||||
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(qxServiceServer PRIVATE ../include/precompiled.h)
|
||||
endif() # (COMMAND target_precompile_headers)
|
||||
|
||||
target_link_libraries(qxServiceServer ${QX_LIBRARIES} QxOrm)
|
||||
|
||||
set_target_properties(qxServiceServer PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../../_bin"
|
||||
)
|
||||
|
||||
else() # _QX_ENABLE_QT_NETWORK
|
||||
|
||||
message(STATUS "qxServiceServer project not loaded because _QX_ENABLE_QT_NETWORK option not enabled (QxOrm QxService module is disabled)")
|
||||
|
||||
endif() # _QX_ENABLE_QT_NETWORK
|
||||
7
test/qxClientServer/qxService/release/release_client/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/release/release_client/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
7
test/qxClientServer/qxService/release/release_server/.gitignore
vendored
Normal file
7
test/qxClientServer/qxService/release/release_server/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
17
test/qxClientServer/qxService/src/business_object/user.cpp
Normal file
17
test/qxClientServer/qxService/src/business_object/user.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "../../include/precompiled.h"
|
||||
|
||||
#include "../../include/business_object/user.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_SERVICE(user)
|
||||
|
||||
namespace qx {
|
||||
template <> void register_class(QxClass<user> & t)
|
||||
{
|
||||
t.id(& user::id, "id");
|
||||
|
||||
t.data(& user::first_name, "first_name");
|
||||
t.data(& user::last_name, "last_name");
|
||||
t.data(& user::birth_date, "birth_date");
|
||||
}}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "../../include/precompiled.h"
|
||||
|
||||
#include "../../include/business_object/user_search.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_SERVICE(user_search)
|
||||
|
||||
namespace qx {
|
||||
template <> void register_class(QxClass<user_search> & t)
|
||||
{
|
||||
t.data(& user_search::first_name, "first_name");
|
||||
t.data(& user_search::last_name, "last_name");
|
||||
t.data(& user_search::birth_date, "birth_date");
|
||||
}}
|
||||
90
test/qxClientServer/qxService/src/dao/user_manager.cpp
Normal file
90
test/qxClientServer/qxService/src/dao/user_manager.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
#ifndef _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
#include "../../include/precompiled.h"
|
||||
|
||||
#include "../../include/dao/user_manager.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
void user_manager::init_database()
|
||||
{
|
||||
static QMutex mutex;
|
||||
static bool bInitDone = false;
|
||||
if (bInitDone) { return; }
|
||||
QMutexLocker locker(& mutex);
|
||||
if (bInitDone) { return; }
|
||||
bInitDone = true;
|
||||
|
||||
QFile::remove("./user.db");
|
||||
qx::QxSqlDatabase::getSingleton()->setDriverName("QSQLITE");
|
||||
qx::QxSqlDatabase::getSingleton()->setDatabaseName("user.db");
|
||||
qx::QxSqlDatabase::getSingleton()->setHostName("localhost");
|
||||
qx::QxSqlDatabase::getSingleton()->setUserName("root");
|
||||
qx::QxSqlDatabase::getSingleton()->setPassword("");
|
||||
qx::dao::create_table<user>();
|
||||
}
|
||||
|
||||
QSqlError user_manager::insert(user_ptr p)
|
||||
{
|
||||
if (! p) { return QSqlError("cannot insert user : invalid user (null pointer)", "", QSqlError::UnknownError); }
|
||||
if (p->first_name.trimmed().isEmpty()) { return QSqlError("cannot insert user : 'first_name' is required", "", QSqlError::UnknownError); }
|
||||
if (p->last_name.trimmed().isEmpty()) { return QSqlError("cannot insert user : 'last_name' is required", "", QSqlError::UnknownError); }
|
||||
return qx::dao::insert(p);
|
||||
}
|
||||
|
||||
QSqlError user_manager::update(user_ptr p)
|
||||
{
|
||||
if (! p) { return QSqlError("cannot update user : invalid user (null pointer)", "", QSqlError::UnknownError); }
|
||||
if (p->id == 0) { return QSqlError("cannot update user : 'id' is required", "", QSqlError::UnknownError); }
|
||||
if (p->first_name.trimmed().isEmpty()) { return QSqlError("cannot update user : 'first_name' is required", "", QSqlError::UnknownError); }
|
||||
if (p->last_name.trimmed().isEmpty()) { return QSqlError("cannot update user : 'last_name' is required", "", QSqlError::UnknownError); }
|
||||
if (! qx::dao::exist(p)) { return QSqlError("cannot update user : user doesn't exist in database", "", QSqlError::UnknownError); }
|
||||
return qx::dao::update(p);
|
||||
}
|
||||
|
||||
QSqlError user_manager::remove(user_ptr p)
|
||||
{
|
||||
if (! p) { return QSqlError("cannot remove user : invalid user (null pointer)", "", QSqlError::UnknownError); }
|
||||
if (p->id == 0) { return QSqlError("cannot remove user : 'id' is required", "", QSqlError::UnknownError); }
|
||||
if (! qx::dao::exist(p)) { return QSqlError("cannot remove user : user doesn't exist in database", "", QSqlError::UnknownError); }
|
||||
return qx::dao::delete_by_id(p);
|
||||
}
|
||||
|
||||
QSqlError user_manager::remove_all()
|
||||
{
|
||||
return qx::dao::delete_all<user>();
|
||||
}
|
||||
|
||||
QSqlError user_manager::fetch_by_id(user_ptr p)
|
||||
{
|
||||
if (! p) { return QSqlError("cannot fetch user : invalid user (null pointer)", "", QSqlError::UnknownError); }
|
||||
if (p->id == 0) { return QSqlError("cannot fetch user : 'id' is required", "", QSqlError::UnknownError); }
|
||||
if (! qx::dao::exist(p)) { return QSqlError("cannot fetch user : user doesn't exist in database", "", QSqlError::UnknownError); }
|
||||
return qx::dao::fetch_by_id(p);
|
||||
}
|
||||
|
||||
QSqlError user_manager::fetch_all(list_of_users_ptr lst)
|
||||
{
|
||||
return qx::dao::fetch_all(lst);
|
||||
}
|
||||
|
||||
QSqlError user_manager::get_by_criteria(user_search_ptr criteria, list_of_users_ptr lst)
|
||||
{
|
||||
if (! criteria) { return QSqlError("cannot search users : invalid criteria (null pointer)", "", QSqlError::UnknownError); }
|
||||
if (criteria->empty()) { return fetch_all(lst); }
|
||||
|
||||
QString sql = "WHERE ";
|
||||
if (! criteria->first_name.isEmpty()) { sql += "user.first_name LIKE :first_name AND "; }
|
||||
if (! criteria->last_name.isEmpty()) { sql += "user.last_name LIKE :last_name AND "; }
|
||||
if (criteria->birth_date.isValid()) { sql += "user.birth_date = :birth_date AND "; }
|
||||
sql = sql.left(sql.count() - 5); // Remove last " AND "
|
||||
|
||||
qx::QxSqlQuery query(sql);
|
||||
if (! criteria->first_name.isEmpty()) { query.bind(":first_name", criteria->first_name); }
|
||||
if (! criteria->last_name.isEmpty()) { query.bind(":last_name", criteria->last_name); }
|
||||
if (criteria->birth_date.isValid()) { query.bind(":birth_date", criteria->birth_date); }
|
||||
|
||||
return qx::dao::fetch_by_query(query, lst);
|
||||
}
|
||||
|
||||
#endif // _QX_SERVICE_MODE_CLIENT
|
||||
20
test/qxClientServer/qxService/src/main.cpp
Normal file
20
test/qxClientServer/qxService/src/main.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
extern "C"
|
||||
int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpReservedt */)
|
||||
{
|
||||
(void)hInstance;
|
||||
switch (dwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH: ::OutputDebugStringA("qxService.DllMain() ---> DLL_PROCESS_ATTACH\n"); break;
|
||||
case DLL_PROCESS_DETACH: ::OutputDebugStringA("qxService.DllMain() ---> DLL_PROCESS_DETACH\n"); break;
|
||||
case DLL_THREAD_ATTACH: ::OutputDebugStringA("qxService.DllMain() ---> DLL_THREAD_ATTACH\n"); break;
|
||||
case DLL_THREAD_DETACH: ::OutputDebugStringA("qxService.DllMain() ---> DLL_THREAD_DETACH\n"); break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // _MSC_VER
|
||||
42
test/qxClientServer/qxService/src/service/server_infos.cpp
Normal file
42
test/qxClientServer/qxService/src/service/server_infos.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "../../include/precompiled.h"
|
||||
|
||||
#include "../../include/service/server_infos.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_SERVICE(server_infos_input)
|
||||
QX_REGISTER_CPP_QX_SERVICE(server_infos_output)
|
||||
QX_REGISTER_CPP_QX_SERVICE(server_infos)
|
||||
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(server_infos_input)
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(server_infos_output)
|
||||
|
||||
namespace qx {
|
||||
|
||||
template <> void register_class(QxClass<server_infos_input> & t)
|
||||
{ Q_UNUSED(t); }
|
||||
|
||||
template <> void register_class(QxClass<server_infos_output> & t)
|
||||
{ t.data(& server_infos_output::current_date_time, "current_date_time"); }
|
||||
|
||||
template <> void register_class(QxClass<server_infos> & t)
|
||||
{ t.fct_0<void>(std::mem_fn(& server_infos::get_current_date_time), "get_current_date_time"); } // using std::mem_fn() here is just a workaround for an issue with some versions of MSVC, it is not required with a full compliant C++11 compiler (http://stackoverflow.com/questions/23778883/vs2013-stdfunction-with-member-function)
|
||||
|
||||
} // namespace qx
|
||||
|
||||
#ifdef _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
void server_infos::get_current_date_time()
|
||||
{ qx::service::execute_client(this, "get_current_date_time"); }
|
||||
|
||||
#else // _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
void server_infos::get_current_date_time()
|
||||
{
|
||||
server_infos_output_ptr output = server_infos_output_ptr(new server_infos_output());
|
||||
output->current_date_time = QDateTime::currentDateTime();
|
||||
setOutputParameter(output);
|
||||
setMessageReturn(true);
|
||||
}
|
||||
|
||||
#endif // _QX_SERVICE_MODE_CLIENT
|
||||
133
test/qxClientServer/qxService/src/service/user_service.cpp
Normal file
133
test/qxClientServer/qxService/src/service/user_service.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
#include "../../include/precompiled.h"
|
||||
|
||||
#include "../../include/service/user_service.h"
|
||||
|
||||
#include "../../include/dao/user_manager.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_SERVICE(user_service_input)
|
||||
QX_REGISTER_CPP_QX_SERVICE(user_service_output)
|
||||
QX_REGISTER_CPP_QX_SERVICE(user_service)
|
||||
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(user_service_input)
|
||||
QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(user_service_output)
|
||||
|
||||
namespace qx {
|
||||
|
||||
template <> void register_class(QxClass<user_service_input> & t)
|
||||
{
|
||||
t.data(& user_service_input::id, "id");
|
||||
t.data(& user_service_input::user, "user");
|
||||
t.data(& user_service_input::criteria, "criteria");
|
||||
}
|
||||
|
||||
template <> void register_class(QxClass<user_service_output> & t)
|
||||
{
|
||||
t.data(& user_service_output::user, "user");
|
||||
t.data(& user_service_output::list_of_users, "list_of_users");
|
||||
}
|
||||
|
||||
template <> void register_class(QxClass<user_service> & t)
|
||||
{
|
||||
t.fct_0<void>(std::mem_fn(& user_service::insert), "insert"); // using std::mem_fn() here is just a workaround for an issue with some versions of MSVC, it is not required with a full compliant C++11 compiler (http://stackoverflow.com/questions/23778883/vs2013-stdfunction-with-member-function)
|
||||
t.fct_0<void>(std::mem_fn(& user_service::update), "update");
|
||||
t.fct_0<void>(std::mem_fn(& user_service::remove), "remove");
|
||||
t.fct_0<void>(std::mem_fn(& user_service::remove_all), "remove_all");
|
||||
t.fct_0<void>(std::mem_fn(& user_service::fetch_by_id), "fetch_by_id");
|
||||
t.fct_0<void>(std::mem_fn(& user_service::fetch_all), "fetch_all");
|
||||
t.fct_0<void>(std::mem_fn(& user_service::get_by_criteria), "get_by_criteria");
|
||||
}
|
||||
|
||||
} // namespace qx
|
||||
|
||||
#ifdef _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
void user_service::insert() { qx::service::execute_client(this, "insert"); }
|
||||
void user_service::update() { qx::service::execute_client(this, "update"); }
|
||||
void user_service::remove() { qx::service::execute_client(this, "remove"); }
|
||||
void user_service::remove_all() { qx::service::execute_client(this, "remove_all"); }
|
||||
void user_service::fetch_by_id() { qx::service::execute_client(this, "fetch_by_id"); }
|
||||
void user_service::fetch_all() { qx::service::execute_client(this, "fetch_all"); }
|
||||
void user_service::get_by_criteria() { qx::service::execute_client(this, "get_by_criteria"); }
|
||||
|
||||
#else // _QX_SERVICE_MODE_CLIENT
|
||||
|
||||
void user_service::insert()
|
||||
{
|
||||
user_service_input_ptr input = getInputParameter();
|
||||
if (! input) { setMessageReturn(0, "invalid input parameter to call service 'user_service::insert()'"); return; }
|
||||
QSqlError err = user_manager().insert(input->user);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); return; }
|
||||
user_service_output_ptr output = user_service_output_ptr(new user_service_output());
|
||||
output->user = input->user;
|
||||
setOutputParameter(output);
|
||||
setMessageReturn(true);
|
||||
}
|
||||
|
||||
void user_service::update()
|
||||
{
|
||||
user_service_input_ptr input = getInputParameter();
|
||||
if (! input) { setMessageReturn(0, "invalid input parameter to call service 'user_service::update()'"); return; }
|
||||
QSqlError err = user_manager().update(input->user);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); }
|
||||
else { setMessageReturn(true); }
|
||||
}
|
||||
|
||||
void user_service::remove()
|
||||
{
|
||||
user_service_input_ptr input = getInputParameter();
|
||||
if (! input) { setMessageReturn(0, "invalid input parameter to call service 'user_service::remove()'"); return; }
|
||||
user_ptr user_tmp = user_ptr(new user());
|
||||
user_tmp->id = input->id;
|
||||
QSqlError err = user_manager().remove(user_tmp);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); }
|
||||
else { setMessageReturn(true); }
|
||||
}
|
||||
|
||||
void user_service::remove_all()
|
||||
{
|
||||
QSqlError err = user_manager().remove_all();
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); }
|
||||
else { setMessageReturn(true); }
|
||||
}
|
||||
|
||||
void user_service::fetch_by_id()
|
||||
{
|
||||
user_service_input_ptr input = getInputParameter();
|
||||
if (! input) { setMessageReturn(0, "invalid input parameter to call service 'user_service::fetch_by_id()'"); return; }
|
||||
user_ptr user_output = user_ptr(new user());
|
||||
user_output->id = input->id;
|
||||
QSqlError err = user_manager().fetch_by_id(user_output);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); return; }
|
||||
user_service_output_ptr output = user_service_output_ptr(new user_service_output());
|
||||
output->user = user_output;
|
||||
setOutputParameter(output);
|
||||
setMessageReturn(true);
|
||||
}
|
||||
|
||||
void user_service::fetch_all()
|
||||
{
|
||||
list_of_users_ptr list_of_users_output = list_of_users_ptr(new list_of_users());
|
||||
QSqlError err = user_manager().fetch_all(list_of_users_output);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); return; }
|
||||
user_service_output_ptr output = user_service_output_ptr(new user_service_output());
|
||||
output->list_of_users = list_of_users_output;
|
||||
setOutputParameter(output);
|
||||
setMessageReturn(true);
|
||||
}
|
||||
|
||||
void user_service::get_by_criteria()
|
||||
{
|
||||
user_service_input_ptr input = getInputParameter();
|
||||
if (! input) { setMessageReturn(0, "invalid input parameter to call service 'user_service::get_by_criteria()'"); return; }
|
||||
list_of_users_ptr list_of_users_output = list_of_users_ptr(new list_of_users());
|
||||
QSqlError err = user_manager().get_by_criteria(input->criteria, list_of_users_output);
|
||||
if (err.isValid()) { setMessageReturn(0, err.text()); return; }
|
||||
user_service_output_ptr output = user_service_output_ptr(new user_service_output());
|
||||
output->list_of_users = list_of_users_output;
|
||||
setOutputParameter(output);
|
||||
setMessageReturn(true);
|
||||
}
|
||||
|
||||
#endif // _QX_SERVICE_MODE_CLIENT
|
||||
4
test/qxClientServer/qxService/tools/build_debug.bat
Normal file
4
test/qxClientServer/qxService/tools/build_debug.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
qmake %QXORM_QMAKE_PARAMS% "./qxServiceClient.pro"
|
||||
nmake debug
|
||||
qmake %QXORM_QMAKE_PARAMS% "./qxServiceServer.pro"
|
||||
nmake debug
|
||||
4
test/qxClientServer/qxService/tools/build_release.bat
Normal file
4
test/qxClientServer/qxService/tools/build_release.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
qmake %QXORM_QMAKE_PARAMS% "./qxServiceClient.pro"
|
||||
nmake release
|
||||
qmake %QXORM_QMAKE_PARAMS% "./qxServiceServer.pro"
|
||||
nmake release
|
||||
4
test/qxClientServer/qxService/tools/clean_debug.bat
Normal file
4
test/qxClientServer/qxService/tools/clean_debug.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
cd "./debug/"
|
||||
del /F /S /Q "./*.*"
|
||||
cd "../"
|
||||
del /F /S /Q "./vc90.pdb"
|
||||
2
test/qxClientServer/qxService/tools/clean_release.bat
Normal file
2
test/qxClientServer/qxService/tools/clean_release.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
cd "./release/"
|
||||
del /F /S /Q "./*.*"
|
||||
Reference in New Issue
Block a user