From 23a11dd103e7a9c03ea0931fb9fb14cfbebacc06 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 11 Apr 2022 17:52:15 +0800 Subject: [PATCH] init --- .vscode/settings.json | 61 +++++++++++ CMakeLists.txt | 88 ++++++++++++++++ README.md | 8 ++ cmake/FindFFmpeg.cmake | 120 ++++++++++++++++++++++ cmake/FindGFlags.cmake | 96 ++++++++++++++++++ cmake/FindGlog.cmake | 94 +++++++++++++++++ cmake/FindMYSQL.cmake | 129 ++++++++++++++++++++++++ docker/Dockerfile | 0 framework/CMakeLists.txt | 42 ++++++++ lib/libmodels.so | Bin 0 -> 27504 bytes modules/CMakeLists.txt | 85 ++++++++++++++++ modules/TcpServer/include/TcpServer.hpp | 35 +++++++ modules/TcpServer/src/TcpServer.cpp | 18 ++++ modules/UserApp/include/UserApp.hpp | 94 +++++++++++++++++ modules/UserApp/src/UserApp.cpp | 42 ++++++++ source/config/config.ini | 0 source/src/main.cpp | 54 ++++++++++ 17 files changed, 966 insertions(+) create mode 100644 .vscode/settings.json create mode 100755 CMakeLists.txt create mode 100644 README.md create mode 100644 cmake/FindFFmpeg.cmake create mode 100644 cmake/FindGFlags.cmake create mode 100644 cmake/FindGlog.cmake create mode 100644 cmake/FindMYSQL.cmake create mode 100644 docker/Dockerfile create mode 100644 framework/CMakeLists.txt create mode 100755 lib/libmodels.so create mode 100644 modules/CMakeLists.txt create mode 100644 modules/TcpServer/include/TcpServer.hpp create mode 100644 modules/TcpServer/src/TcpServer.cpp create mode 100644 modules/UserApp/include/UserApp.hpp create mode 100644 modules/UserApp/src/UserApp.cpp create mode 100644 source/config/config.ini create mode 100644 source/src/main.cpp diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..81c7f08 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,61 @@ +{ + "files.associations": { + "*.cpp": "cpp", + "iostream": "cpp", + "functional": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "array": "cpp", + "atomic": "cpp", + "strstream": "cpp", + "*.tcc": "cpp", + "bitset": "cpp", + "chrono": "cpp", + "complex": "cpp", + "condition_variable": "cpp", + "cstdint": "cpp", + "deque": "cpp", + "forward_list": "cpp", + "list": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "ratio": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "istream": "cpp", + "limits": "cpp", + "memory": "cpp", + "mutex": "cpp", + "new": "cpp", + "ostream": "cpp", + "numeric": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "cfenv": "cpp", + "cinttypes": "cpp", + "regex": "cpp", + "utility": "cpp", + "typeindex": "cpp", + "typeinfo": "cpp", + "valarray": "cpp" + } +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..0615cd3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,88 @@ +if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}") + message(FATAL_ERROR "Please create a separate directory for build files.") +endif() + +cmake_minimum_required(VERSION 3.6) + +project(ISNS C CXX) +set(CMAKE_VERBOSE_MAKEFILE OFF) + +# ---[ Options +option(build_modules "build modules" ON) + +# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/source/bin/) +if(build_modules) + add_subdirectory(modules) +endif() + +##OpenCV +if(WITH_OPENCV) + if(CMAKE_TOOLCHAIN_FILE) + if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv) + set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_features2d opencv_flann) + if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv2/imgcodecs) + list(APPEND OpenCV_LIBS opencv_imgcodecs) + endif() + if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv2/videoio) + list(APPEND OpenCV_LIBS opencv_videoio) + endif() + message(STATUS "HAVE_OPENCV enabled") + message(STATUS "opencv libraries: ${OpenCV_LIBS}") + set(HAVE_OPENCV true) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENCV") + else() + set (HAVE_OPENCV false) + endif() + else() + set(OpenCV_FIND_QUIETLY true) + #find_package(OpenCV REQUIRED) //this will include opencv_ts which result in crash on centos + find_package(OpenCV OPTIONAL_COMPONENTS imgcodecs) + find_package(OpenCV OPTIONAL_COMPONENTS videoio) + set(optional_opencv_libs ${OpenCV_LIBS}) + find_package(OpenCV REQUIRED core imgproc highgui features2d) + if(OpenCV_FOUND) + if(imgcodecs_FOUND) + list(APPEND OpenCV_LIBS optional_opencv_libs) + endif() + message(STATUS "HAVE_OPENCV enabled") + message(STATUS "opencv libraries: ${OpenCV_LIBS}") + set(HAVE_OPENCV true) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENCV") + else() + set (HAVE_OPENCV false) + endif() + endif() +else() + set (HAVE_OPENCV false) +endif() + +#查找mysql是否安装 +find_package(MYSQL QUIET) +if(MYSQL_FOUND AND ENABLE_MYSQL) + message(STATUS "找到mysqlclient库:\"${MYSQL_INCLUDE_DIR}\",ENABLE_MYSQL宏已打开") + include_directories(${MYSQL_INCLUDE_DIR}) + include_directories(${MYSQL_INCLUDE_DIR}/mysql) + add_definitions(-DENABLE_MYSQL) + list(APPEND 3RDPARTY_LIBS ${MYSQL_LIBRARIES}) +endif() + +include_directories(${PROJECT_SOURCE_DIR}/3rdparty/rapidjson/include/) +include_directories(/usr/local/include/hv) +include_directories(${PROJECT_SOURCE_DIR}/modules/UserApp/include/) + + +# 寻找当前目录下所有源文件 +aux_source_directory(./source/src DIR_SRCS) + +add_compile_options(-Wall -std=c++11 -O2 -g) + +link_directories(${PROJECT_SOURCE_DIR}/lib) +link_directories(/usr/local/lib) + +list(APPEND ALL_LINKER_LIBS mk_api ZLToolKit dl ${3RDPARTY_LIBS} ${OpenCV_LIBS} pthread hv models) + +# 指定生成的目标 +add_executable(main ${DIR_SRCS}) + +# 链接 +target_link_libraries(main ${ALL_LINKER_LIBS}) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4e53b47 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +## Satellite +*** +> Satellite + + + + + diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake new file mode 100644 index 0000000..aba0eec --- /dev/null +++ b/cmake/FindFFmpeg.cmake @@ -0,0 +1,120 @@ +# ============================================== +# Try to find FFmpeg libraries: +# - avcodec +# - avformat +# - avdevice +# - avutil +# - swscale +# - avfilter +# +# FFMPEG_FOUND - system has FFmpeg +# FFMPEG_INCLUDE_DIR - the FFmpeg inc directory +# FFMPEG_LIBRARIES - Link these to use FFmpeg +# ============================================== +# Notice: this original script is from internet. + +if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) + # in cache already + set(FFMPEG_FOUND TRUE) +else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) + + find_path( + FFMPEG_AVCODEC_INCLUDE_DIR + NAMES libavcodec/avcodec.h + PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} + /usr/include/ffmpeg + /usr/local/include + /usr/local/ffmpeg/include + ) + + find_library( + FFMPEG_LIBAVCODEC + NAMES avcodec + PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} + /usr/lib64 + /usr/local/lib + /usr/local/ffmpeg/lib + /usr/lib/aarch64-linux-gnu/ + ) + + find_library( + FFMPEG_LIBAVFORMAT + NAMES avformat + PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} + /usr/lib64 + /usr/local/lib + /usr/local/ffmpeg/lib + /usr/lib/aarch64-linux-gnu + ) + + find_library( + FFMPEG_LIBSWRESAMPLE + NAMES swresample + PATHS ${_FFMPEG_SWRESAMPLE_LIBRARY_DIRS} + /usr/lib64 + /usr/local/lib + /usr/local/ffmpeg/lib + /usr/lib/aarch64-linux-gnu/ + ) + + find_library( + FFMPEG_LIBAVUTIL + NAMES avutil + PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} + /usr/lib64 + /usr/local/lib + /usr/local/ffmpeg/lib + /usr/lib/aarch64-linux-gnu/ + ) + + find_library( + FFMPEG_LIBSWSCALE + NAMES swscale + PATHS ${_FFMPEG_SWSCALE_LIBRARY_DIRS} + /usr/lib64 + /usr/local/lib + /usr/local/ffmpeg/lib + /usr/lib/aarch64-linux-gnu/ + ) + + find_library( + FFMPEG_LIBAVFILTER + NAMES avfilter + PATHS ${_FFMPEG_AVFILTER_LIBRARY_DIRS} + /usr/lib64 + /usr/local/lib + /usr/local/ffmpeg/lib + /usr/lib/aarch64-linux-gnu/ + ) + find_library( + FFMPEG_LIBAVDEVICE + NAMES avdevice + PATHS ${_FFMPEG_AVDEVICE_LIBRARY_DIRS} + /usr/lib64 + /usr/local/lib + /usr/local/ffmpeg/lib + /usr/lib/aarch64-linux-gnu/ + ) + if (WITH_FFMPEG_AVDEVICE AND NOT FFMPEG_LIBAVDEVICE) + message(FATAL_ERROR "Not find FFmpeg LIBAVDEVICE ") + endif () + if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT AND FFMPEG_LIBAVUTIL AND FFMPEG_LIBSWSCALE AND FFMPEG_LIBSWRESAMPLE AND (FFMPEG_LIBAVDEVICE OR NOT WITH_FFMPEG_AVDEVICE)) + set(FFMPEG_FOUND TRUE) + endif () + + if (FFMPEG_FOUND) + set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR}) + set(FFMPEG_LIBRARIES + ${FFMPEG_LIBAVCODEC} + ${FFMPEG_LIBAVFORMAT} + ${FFMPEG_LIBAVUTIL} + ${FFMPEG_LIBSWSCALE} + ${FFMPEG_LIBSWRESAMPLE}) + if (WITH_FFMPEG_AVDEVICE) + list(APPEND FFMPEG_LIBRARIES ${FFMPEG_LIBAVDEVICE}) + endif (WITH_FFMPEG_AVDEVICE) + else (FFMPEG_FOUND) + message(FATAL_ERROR "Could not find FFmpeg libraries!") + endif (FFMPEG_FOUND) + +endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) diff --git a/cmake/FindGFlags.cmake b/cmake/FindGFlags.cmake new file mode 100644 index 0000000..579d750 --- /dev/null +++ b/cmake/FindGFlags.cmake @@ -0,0 +1,96 @@ +#COPYRIGHT +# +#All contributions by the University of California: +#Copyright (c) 2014-2017 The Regents of the University of California (Regents) +#All rights reserved. +# +#All other contributions: +#Copyright (c) 2014-2017, the respective contributors +#All rights reserved. +# +#Caffe uses a shared copyright model: each contributor holds copyright over +#their contributions to Caffe. The project versioning records all such +#contribution and copyright details. If a contributor wants to further mark +#their specific copyright on a particular contribution, they should indicate +#their copyright solely in the commit message of the change when it is +#committed. +# +#LICENSE +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are met: +# +#1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +#2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +#ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +#ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +#CONTRIBUTION AGREEMENT +# +#By contributing to the BVLC/caffe repository through pull-request, comment, +#or otherwise, the contributor releases their content to the +#license and copyright terms herein. +# + +# - Try to find GFLAGS +# +# The following variables are optionally searched for defaults +# GFLAGS_ROOT_DIR: Base directory where all GFLAGS components are found +# +# The following are set after configuration is done: +# GFLAGS_FOUND +# GFLAGS_INCLUDE_DIRS +# GFLAGS_LIBRARIES +# GFLAGS_LIBRARYRARY_DIRS + +include(FindPackageHandleStandardArgs) + +set(GFLAGS_ROOT_DIR "" CACHE PATH "Folder contains Gflags") + +# We are testing only a couple of files in the include directories +if(WIN32) + find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h + PATHS ${GFLAGS_ROOT_DIR}/src/windows) +else() + find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h + PATHS ${GFLAGS_ROOT_DIR}) +endif() + +if(MSVC) + find_library(GFLAGS_LIBRARY_RELEASE + NAMES libgflags + PATHS ${GFLAGS_ROOT_DIR} + PATH_SUFFIXES Release) + + find_library(GFLAGS_LIBRARY_DEBUG + NAMES libgflags-debug + PATHS ${GFLAGS_ROOT_DIR} + PATH_SUFFIXES Debug) + + set(GFLAGS_LIBRARY optimized ${GFLAGS_LIBRARY_RELEASE} debug ${GFLAGS_LIBRARY_DEBUG}) +else() + find_library(GFLAGS_LIBRARY gflags) +endif() + +find_package_handle_standard_args(GFlags DEFAULT_MSG GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY) + + +if(GFLAGS_FOUND) + set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR}) + set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY}) + message(STATUS "Found gflags (include: ${GFLAGS_INCLUDE_DIR}, library: ${GFLAGS_LIBRARY})") + mark_as_advanced(GFLAGS_LIBRARY_DEBUG GFLAGS_LIBRARY_RELEASE + GFLAGS_LIBRARY GFLAGS_INCLUDE_DIR GFLAGS_ROOT_DIR) +endif() diff --git a/cmake/FindGlog.cmake b/cmake/FindGlog.cmake new file mode 100644 index 0000000..accbf93 --- /dev/null +++ b/cmake/FindGlog.cmake @@ -0,0 +1,94 @@ +#COPYRIGHT +# +#All contributions by the University of California: +#Copyright (c) 2014-2017 The Regents of the University of California (Regents) +#All rights reserved. +# +#All other contributions: +#Copyright (c) 2014-2017, the respective contributors +#All rights reserved. +# +#Caffe uses a shared copyright model: each contributor holds copyright over +#their contributions to Caffe. The project versioning records all such +#contribution and copyright details. If a contributor wants to further mark +#their specific copyright on a particular contribution, they should indicate +#their copyright solely in the commit message of the change when it is +#committed. +# +#LICENSE +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are met: +# +#1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +#2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +#ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +#ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +#CONTRIBUTION AGREEMENT +# +#By contributing to the BVLC/caffe repository through pull-request, comment, +#or otherwise, the contributor releases their content to the +#license and copyright terms herein. +# + +# - Try to find Glog +# +# The following variables are optionally searched for defaults +# GLOG_ROOT_DIR: Base directory where all GLOG components are found +# +# The following are set after configuration is done: +# GLOG_FOUND +# GLOG_INCLUDE_DIRS +# GLOG_LIBRARIES +# GLOG_LIBRARYRARY_DIRS + +include(FindPackageHandleStandardArgs) + +set(GLOG_ROOT_DIR "" CACHE PATH "Folder contains Google glog") + +if(WIN32) + find_path(GLOG_INCLUDE_DIR glog/logging.h + PATHS ${GLOG_ROOT_DIR}/src/windows) +else() + find_path(GLOG_INCLUDE_DIR glog/logging.h + PATHS ${GLOG_ROOT_DIR}) +endif() + +if(MSVC) + find_library(GLOG_LIBRARY_RELEASE libglog_static + PATHS ${GLOG_ROOT_DIR} + PATH_SUFFIXES Release) + + find_library(GLOG_LIBRARY_DEBUG libglog_static + PATHS ${GLOG_ROOT_DIR} + PATH_SUFFIXES Debug) + + set(GLOG_LIBRARY optimized ${GLOG_LIBRARY_RELEASE} debug ${GLOG_LIBRARY_DEBUG}) +else() + find_library(GLOG_LIBRARY glog + PATHS ${GLOG_ROOT_DIR} + PATH_SUFFIXES lib lib64) +endif() + +find_package_handle_standard_args(Glog DEFAULT_MSG GLOG_INCLUDE_DIR GLOG_LIBRARY) + +if(GLOG_FOUND) + set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR}) + set(GLOG_LIBRARIES ${GLOG_LIBRARY}) + message(STATUS "Found glog (include: ${GLOG_INCLUDE_DIR}, library: ${GLOG_LIBRARY})") + mark_as_advanced(GLOG_ROOT_DIR GLOG_LIBRARY_RELEASE GLOG_LIBRARY_DEBUG + GLOG_LIBRARY GLOG_INCLUDE_DIR) +endif() diff --git a/cmake/FindMYSQL.cmake b/cmake/FindMYSQL.cmake new file mode 100644 index 0000000..b82e6e1 --- /dev/null +++ b/cmake/FindMYSQL.cmake @@ -0,0 +1,129 @@ +# - Try to find MySQL / MySQL Embedded library +# Find the MySQL includes and client library +# This module defines +# MYSQL_INCLUDE_DIR, where to find mysql.h +# MYSQL_LIBRARIES, the libraries needed to use MySQL. +# MYSQL_LIB_DIR, path to the MYSQL_LIBRARIES +# MYSQL_EMBEDDED_LIBRARIES, the libraries needed to use MySQL Embedded. +# MYSQL_EMBEDDED_LIB_DIR, path to the MYSQL_EMBEDDED_LIBRARIES +# MYSQL_FOUND, If false, do not try to use MySQL. +# MYSQL_EMBEDDED_FOUND, If false, do not try to use MySQL Embedded. + +# Copyright (c) 2006-2008, Jarosław Staniek +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +include(CheckCXXSourceCompiles) + +if(WIN32) + find_path(MYSQL_INCLUDE_DIR mysql.h + PATHS + $ENV{MYSQL_INCLUDE_DIR} + $ENV{MYSQL_DIR}/include + $ENV{ProgramFiles}/MySQL/*/include + $ENV{SystemDrive}/MySQL/*/include + $ENV{ProgramW6432}/MySQL/*/include + ) +else(WIN32) + find_path(MYSQL_INCLUDE_DIR mysql/mysql.h + PATHS + $ENV{MYSQL_INCLUDE_DIR} + $ENV{MYSQL_DIR}/include + /usr/local/mysql/include + PATH_SUFFIXES + mysql + ) +endif(WIN32) + +if(WIN32) + if (${CMAKE_BUILD_TYPE}) + string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) + endif() + + # path suffix for debug/release mode + # binary_dist: mysql binary distribution + # build_dist: custom build + if(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug") + set(binary_dist debug) + set(build_dist Debug) + else(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug") + ADD_DEFINITIONS(-DDBUG_OFF) + set(binary_dist opt) + set(build_dist Release) + endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug") + +# find_library(MYSQL_LIBRARIES NAMES mysqlclient + set(MYSQL_LIB_PATHS + $ENV{MYSQL_DIR}/lib/${binary_dist} + $ENV{MYSQL_DIR}/libmysql/${build_dist} + $ENV{MYSQL_DIR}/client/${build_dist} + $ENV{ProgramFiles}/MySQL/*/lib/${binary_dist} + $ENV{SystemDrive}/MySQL/*/lib/${binary_dist} + $ENV{MYSQL_DIR}/lib/opt + $ENV{MYSQL_DIR}/client/release + $ENV{ProgramFiles}/MySQL/*/lib/opt + $ENV{ProgramFiles}/MySQL/*/lib/ + $ENV{SystemDrive}/MySQL/*/lib/opt + $ENV{ProgramW6432}/MySQL/*/lib + ) + find_library(MYSQL_LIBRARIES NAMES libmysql + PATHS + ${MYSQL_LIB_PATHS} + ) +else(WIN32) +# find_library(MYSQL_LIBRARIES NAMES mysqlclient + set(MYSQL_LIB_PATHS + $ENV{MYSQL_DIR}/libmysql_r/.libs + $ENV{MYSQL_DIR}/lib + $ENV{MYSQL_DIR}/lib/mysql + /usr/local/mysql/lib + /opt/mysql/mysql/lib + $ENV{MYSQL_DIR}/libmysql_r/.libs + $ENV{MYSQL_DIR}/lib + $ENV{MYSQL_DIR}/lib/mysql + /usr/local/mysql/lib + /opt/mysql/mysql/lib + PATH_SUFFIXES + mysql + ) + find_library(MYSQL_LIBRARIES NAMES mysqlclient + PATHS + ${MYSQL_LIB_PATHS} + ) +endif(WIN32) + +find_library(MYSQL_EMBEDDED_LIBRARIES NAMES mysqld + PATHS + ${MYSQL_LIB_PATHS} +) + +if(MYSQL_LIBRARIES) + get_filename_component(MYSQL_LIB_DIR ${MYSQL_LIBRARIES} PATH) +endif(MYSQL_LIBRARIES) + +if(MYSQL_EMBEDDED_LIBRARIES) + get_filename_component(MYSQL_EMBEDDED_LIB_DIR ${MYSQL_EMBEDDED_LIBRARIES} PATH) +endif(MYSQL_EMBEDDED_LIBRARIES) + +set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR} ) +set( CMAKE_REQUIRED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES} ) +check_cxx_source_compiles( "#include \nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_OPT_EMBEDDED_CONNECTION ) + +if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) + set(MYSQL_FOUND TRUE) + message(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}") +else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) + set(MYSQL_FOUND FALSE) + message(STATUS "MySQL not found.") +endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) + +if(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION) + set(MYSQL_EMBEDDED_FOUND TRUE) + message(STATUS "Found MySQL Embedded: ${MYSQL_INCLUDE_DIR}, ${MYSQL_EMBEDDED_LIBRARIES}") +else(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION) + set(MYSQL_EMBEDDED_FOUND FALSE) + message(STATUS "MySQL Embedded not found.") +endif(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION) + +mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES MYSQL_EMBEDDED_LIBRARIES) diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..e69de29 diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt new file mode 100644 index 0000000..4dc6709 --- /dev/null +++ b/framework/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.6) +set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib/) +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/) +set(INS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) + +add_compile_options(-std=c++11) + +# compile flags +set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-as-needed") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_REENTRANT -fPIC -Wall -Werror") + +set(CNSTREAM_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) +set(LIBRARY_OUTPUT_PATH ${CNSTREAM_ROOT_DIR}/lib) +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/) +set(CMAKE_MODULE_PATH ${CNSTREAM_ROOT_DIR}/cmake) + +set(VERSION_HEAD_FILE ${INS_ROOT_DIR}/framework/core/include/ins_version.hpp) + +execute_process(COMMAND awk /INS_MAJOR_VERSION/ ${VERSION_HEAD_FILE} OUTPUT_VARIABLE VERSION_STR) +string(REGEX MATCH "[0-9]+" MAJOR_VERSION ${VERSION_STR}) +execute_process(COMMAND awk /INS_MINOR_VERSION/ ${VERSION_HEAD_FILE} OUTPUT_VARIABLE VERSION_STR) +string(REGEX MATCH "[0-9]+" MINOR_VERSION ${VERSION_STR}) +execute_process(COMMAND awk /INS_PATCH_VERSION/ ${VERSION_HEAD_FILE} OUTPUT_VARIABLE VERSION_STR) +string(REGEX MATCH "[0-9]+" PATCH_VERSION ${VERSION_STR}) +set(ISNS_TARGET_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") + +include_directories(${3RDPARTY_INCLUDE_DIRS}) + +include_directories(${PROJECT_SOURCE_DIR}/3rdparty/) +include_directories(${PROJECT_SOURCE_DIR}/3rdparty/rapidjson/include/) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dataType/include/) + +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/core/src core_srcs) +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/dataType/src core_srcs) + +add_library(ins_core SHARED ${core_srcs} ) +target_link_libraries(ins_core protobuf ${SOURCE_LINKER_LIBS}) +target_link_libraries(ins_core dl pthread ${CNRT_LIBS} ${GFLAGS_LIBRARIES}) +set_target_properties(ins_core PROPERTIES LINK_FLAGS_RELEASE -s) +set_target_properties(ins_core PROPERTIES VERSION ${ISNS_TARGET_VERSION}) diff --git a/lib/libmodels.so b/lib/libmodels.so new file mode 100755 index 0000000000000000000000000000000000000000..8b83c02ac0703d92fa78f136226f2c15bb226d15 GIT binary patch literal 27504 zcmeHQdwkT@mA`ob3MLT&5m3hnNI=I-cnAnGLozVI04WI=A9R>ZCdp{X#K|NC7c2r& zLYgkCZfkvX>8@q1R*SZ}Xj_d!LECN{w-sr%noqUt1l$%M#Z)QT@43HoXYTywH;{yG zKmM^-e{+84+;h)8_uO+I`P~O!a+fYjPfHUjWQgkoVa|Mm;^c@uetrRPirHc)elHah zByUzcD(P*)T!W;b5H?AmJci)uyjG%sHu<7pD+}Ee6K=$(gNxEd=Sg-zgRWo~F(4>7 z%s@pZAU&^eQO$57^C?KY6w3Y(siyZe(knZU$L7}^+K#xRc|fy?ns#50KygvofO$TuO#9jD>Big7!` zs~I`~xr)R!c%OrZTx&ia3JVM%f1UVs;X%nnF&;Ob#ds)q@LZ3lln{iac$VY&0-hCk zD)6kta|0dTg)K{@$stpLj7N??jhp>&%CTw>)ld z{?vWn^%uWsFFADkqHkqf{OGY?{VDsY7j8_y#r@WgNB`oJi@&jA{ks^zaen)8oO-uJ?UTX(%Xdwa>m z-_41<^1bEHeDi0|AN7ta{wY%V|BJgXc&Oz2ANgd)!-YeJq+IboIL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ERzDJwFj4_>rMkYgK|h3qB9yxkE$q0RMcDDlZY@5; zC4UYaD23MLv4n)RXCtWnCJIhux&l~sO9*yg*oqob>D9gz1?9t> zN`J+tAnjGAy~XdlA-ixvZ%(3DjU(%{u%|<{xg-oO0UY_!08uKVg$7h zM?tm!jnY#ZbNW`$uw+fgEM!po{S+L>bOlIPJv0H))5rGp@Ir|^i=idJXMPzJyc3w7 zUhV%;Q1NlHnEnd?vMIgVccS2LRDn5xSzd=Jz1rWXAeJE$g1P+na(Y$&YTuE9mr&uf zVAI~|^+7zuqSBlHT^aT7$Ph0DbN=4}O;4}(F)26^>)3iQnL~WvlwR$3Qm|4_jCXVX zKLHI(Sh4o4_C=|GuSWT)5@XK)HAG;^DVARC7d?Efk;2Sx#(xJkD!*zUYClqUKhyu- zlwPeHMLE3`Zm1%E&H4WcRBAgaf3304J_V&D10aqlPpz!wf;Dp z)2nf1~ytTa-<2Bd2; + + ~TcpServer(); + + /** + * @description: 创建新实例 + * @param {int} port + * @return {*} + */ + static std::shared_ptr CreateNew(int port); +private: + int port_; +}; + + +#endif diff --git a/modules/TcpServer/src/TcpServer.cpp b/modules/TcpServer/src/TcpServer.cpp new file mode 100644 index 0000000..1e6f721 --- /dev/null +++ b/modules/TcpServer/src/TcpServer.cpp @@ -0,0 +1,18 @@ +/* + * @Description: + * @Version: 1.0 + * @Autor: lishengyin + * @Date: 2022-04-11 17:31:02 + * @LastEditors: lishengyin + * @LastEditTime: 2022-04-11 17:43:05 + */ +#include "TcpServer.hpp" + +/** + * @description: 创建新的实例 + * @param {int} port + * @return {*} + */ +std::shared_ptr TcpServer::CreateNew(int port){ + return std::shared_ptr(new TcpServer(port)); +} \ No newline at end of file diff --git a/modules/UserApp/include/UserApp.hpp b/modules/UserApp/include/UserApp.hpp new file mode 100644 index 0000000..0421bf3 --- /dev/null +++ b/modules/UserApp/include/UserApp.hpp @@ -0,0 +1,94 @@ +/* + * @Description: + * @Version: 1.0 + * @Autor: lishengyin + * @Date: 2022-04-11 17:12:05 + * @LastEditors: lishengyin + * @LastEditTime: 2022-04-11 17:31:20 + */ +#ifndef __USERAPP_HPP_ +#define __USERAPP_HPP_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + + +#define OK 0 +#define ERR -1 + +// NonCopyAble +class NonCopyable { + protected: + NonCopyable() {}; + ~NonCopyable() {}; + + public: + NonCopyable(const NonCopyable&) = delete; + NonCopyable(NonCopyable&&) = delete; + NonCopyable& operator=(const NonCopyable&) = delete; + NonCopyable& operator=(NonCopyable&&) = delete; + + static std::string getDataTime(){ + char ctime[80]; + time_t rawtime; + struct tm *info; + time(&rawtime); + info = localtime(&rawtime); + strftime(ctime, 80, "%Y-%m-%d %H:%M:%S", info); + std::string DataTime = ctime; + return DataTime; + } +}; + +class UserApp:private NonCopyable +{ +private: + UserApp(std::string appName):appName_(appName){} +public: + using Ptr = std::shared_ptr; + + ~UserApp(){} + + /** + * @description: 创建新的实例 + * @param {string} appName + * @return {*} + */ + static std::shared_ptr CreateNew(std::string appName); + + /** + * @description: 初始化 + * @param {*} + * @return {*} + */ + int8_t Init(); + + /** + * @description: 启动任务 + * @param {*} + * @return {*} + */ + int8_t StartTask(); + +private: + std::string appName_; +}; + + + +#endif \ No newline at end of file diff --git a/modules/UserApp/src/UserApp.cpp b/modules/UserApp/src/UserApp.cpp new file mode 100644 index 0000000..585a408 --- /dev/null +++ b/modules/UserApp/src/UserApp.cpp @@ -0,0 +1,42 @@ +/* + * @Description: + * @Version: 1.0 + * @Autor: lishengyin + * @Date: 2022-04-11 17:12:10 + * @LastEditors: lishengyin + * @LastEditTime: 2022-04-11 17:41:49 + */ +#include "UserApp.hpp" + +/** + * @description: 创建新的实例 + * @param {string} appName + * @return {*} + */ +std::shared_ptr UserApp::CreateNew(std::string appName){ + return std::shared_ptr(new UserApp(appName)); +} + +/** + * @description: 初始化 + * @param {*} + * @return {*} + */ +int8_t UserApp::Init(){ + + return OK; +} + +/** + * @description: 启动任务 + * @param {*} + * @return {*} + */ +int8_t StartTask(){ + + + return OK; +} + + + diff --git a/source/config/config.ini b/source/config/config.ini new file mode 100644 index 0000000..e69de29 diff --git a/source/src/main.cpp b/source/src/main.cpp new file mode 100644 index 0000000..5d59adf --- /dev/null +++ b/source/src/main.cpp @@ -0,0 +1,54 @@ +#include +#include +#include "Util/logger.h" +#include "Util/NoticeCenter.h" +#include "UserApp.hpp" +#include "Network/TcpServer.h" + +using namespace std; +using namespace toolkit; + +class EchoSession: public TcpSession { +public: + EchoSession(const Socket::Ptr &sock) : + TcpSession(sock) { + DebugL; + } + ~EchoSession() { + DebugL; + } + virtual void onRecv(const Buffer::Ptr &buf) override{ + //处理客户端发送过来的数据 + TraceL << buf->data() << " from port:" << get_local_port(); + send(buf); + } + virtual void onError(const SockException &err) override{ + //客户端断开连接或其他原因导致该对象脱离TCPServer管理 + WarnL << err.what(); + } + virtual void onManager() override{ + //定时管理该对象,譬如会话超时检查 + DebugL; + } + +private: + Ticker _ticker; +}; + +int main(int argc, char *argv[]) +{ + //设置退出信号处理函数 + static semaphore sem; + signal(SIGINT, [](int) { sem.post(); });// 设置退出信号 + + // 设置日志 + Logger::Instance().add(std::make_shared()); + Logger::Instance().add(std::make_shared()); + Logger::Instance().setWriter(std::make_shared()); + + TcpServer::Ptr server(new TcpServer()); + server->start(7400);//监听9000端口 + + sem.wait(); + return 0; +}