diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1018551f..7e08b469 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(pip)
set(_PIP_MAJOR 1)
-set(_PIP_MINOR 23)
-set(_PIP_REVISION 0)
-set(_PIP_SUFFIX )
+set(_PIP_MINOR 99)
+set(_PIP_REVISION 3)
+set(_PIP_SUFFIX _prebeta)
set(_PIP_COMPANY SHS)
set(_PIP_DOMAIN org.SHS)
@@ -14,6 +14,7 @@ endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(PIP_BUILD 1)
include(CheckFunctionExists)
+include(GenerateExportHeader)
include(DeployMacros)
include(PIPMacros)
if(NOT DEFINED BUILD_NUMBER)
@@ -40,53 +41,94 @@ set(PIP_UTILS 1)
if(LIBPROJECT)
set(PIP_UTILS ${UTILS})
endif()
+set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD 11)
# Basic
-macro(gather_src DIR CPP H H_P)
- set(CS)
- set(HS)
- set(PHS)
- file(GLOB CS "${DIR}/*.cpp")
- file(GLOB HS "${DIR}/*.h")
- file(GLOB PHS "${DIR}/*_p.h")
- list(REMOVE_ITEM HS "${PHS}")
- list(APPEND ${CPP} ${CS})
- list(APPEND ${H} ${HS})
- list(APPEND ${H_P} ${PHS})
-endmacro()
-
-set(PIP_SRC_MAIN "lib/main")
-set(PIP_SRC_CONSOLE "lib/console")
-set(PIP_SRC_CRYPT "lib/crypt")
-set(PIP_SRC_COMPRESS "lib/compress")
-set(PIP_SRC_USB "lib/usb")
-set(PIP_SRC_FFTW "lib/fftw")
-set(PIP_SRC_OPENCL "lib/opencl")
-set(PIP_SRC_IO_UTILS "lib/io_utils")
-set(PIP_SRC_CONCURRENT "lib/concurrent")
-set(PIP_SRC_CLOUD "lib/cloud")
-set(PIP_SRC_DIRS ${PIP_SRC_MAIN}
- ${PIP_SRC_CONSOLE}
- ${PIP_SRC_CRYPT}
- ${PIP_SRC_COMPRESS}
- ${PIP_SRC_USB}
- ${PIP_SRC_FFTW}
- ${PIP_SRC_OPENCL}
- ${PIP_SRC_IO_UTILS}
- ${PIP_SRC_CONCURRENT}
- ${PIP_SRC_CLOUD}
-)
-set(PIP_LIBS_TARGETS pip)
+set(PIP_MODULES)
set(LIBS_MAIN)
set(LIBS_STATUS)
set(HDRS)
set(PHDRS)
+set(HDR_DIRS)
+set(PIP_UTILS_LIST)
+set(PIP_TESTS_LIST)
+set(PIP_EXPORTS)
-if (TESTS)
- set(PIP_SRC_CONCURRENT_TEST "lib/concurrent/test")
-endif()
+set(PIP_SRC_MODULES "console;crypt;compress;usb;fftw;opencl;io_utils;cloud;lua")
+foreach(_m ${PIP_SRC_MODULES})
+ set(PIP_MSG_${_m} "no")
+endforeach()
+
+macro(pip_module NAME LIBS LABEL INCLUDES MSG)
+ set(CPPS)
+ set(HS)
+ set(PHS)
+ set(CRES)
+ file(GLOB_RECURSE CPPS "lib/${NAME}/*.cpp")
+ file(GLOB_RECURSE HS "lib/${NAME}/*.h")
+ file(GLOB_RECURSE PHS "lib/${NAME}/*_p.h")
+ file(GLOB_RECURSE RES "lib/${NAME}/*conf.h")
+ list(REMOVE_ITEM HS "${PHS}")
+ list(APPEND HDRS ${HS})
+ list(APPEND PHDRS ${PHS})
+
+ set(_target "pip_${NAME}")
+ set(_libs "${LIBS}")
+ if ("${NAME}" STREQUAL "main")
+ set(_target "pip")
+ else()
+ list(APPEND _libs "pip")
+ endif()
+ string(TOUPPER "${_target}" DEF_NAME)
+
+ set(PIP_MSG_${NAME} "yes${MSG}")
+ import_version(${_target} PIP)
+ set_deploy_property(${_target} ${PIP_LIB_TYPE}
+ LABEL "${LABEL}"
+ FULLNAME "${_PIP_DOMAIN}.${_target}"
+ COMPANY "${_PIP_COMPANY}"
+ INFO "Platform-Independent Primitives")
+ make_rc(${_target} _RC)
+
+ set(LINK_LIBS)
+ foreach (_l ${_libs})
+ if (${${_l}_FOUND})
+ list(APPEND LINK_LIBS ${${_l}_LIBRARIES})
+ else()
+ list(APPEND LINK_LIBS ${_l})
+ endif()
+ endforeach()
+
+ if (NOT "${RES}" STREQUAL "")
+ pip_resources(CRES "${RES}")
+ endif()
+ add_definitions(-D${DEF_NAME})
+ add_library(${_target} ${PIP_LIB_TYPE} ${CPPS} ${CRES} ${_RC})
+ if (NOT "${RES}" STREQUAL "")
+ add_dependencies(${_target} pip_rc)
+ endif()
+ if (NOT "${INCLUDES}" STREQUAL "")
+ target_include_directories(${_target} PRIVATE ${INCLUDES})
+ endif()
+ generate_export_header(${_target})
+ list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/${_target}_export.h")
+ list(APPEND PIP_EXPORTS "${DEF_NAME}_EXPORT")
+ target_link_libraries(${_target} ${LINK_LIBS})
+ list(APPEND PIP_MODULES ${_target})
+ if (NOT "${LIBS}" STREQUAL "")
+ list(APPEND LIBS_STATUS ${LIBS})
+ endif()
+endmacro()
+
+macro(pip_find_lib NAME)
+ find_library(${NAME}_LIBRARIES ${NAME} ${ARGN})
+ set(${NAME}_FOUND FALSE)
+ if(${NAME}_LIBRARIES)
+ set(${NAME}_FOUND TRUE)
+ endif()
+endmacro()
if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
set(STATIC_LIB ON)
@@ -94,11 +136,11 @@ endif()
if(STATIC_LIB)
set(PIP_LIB_TYPE STATIC)
+ set(PIP_LIB_TYPE_MSG "Static")
add_definitions(-DPIP_STATIC_DEFINE)
- #message(STATUS "Building PIP static library")
else()
set(PIP_LIB_TYPE SHARED)
- #message(STATUS "Building PIP shared library")
+ set(PIP_LIB_TYPE_MSG "Shared")
endif()
@@ -110,17 +152,10 @@ set_version(PIP
BUILD "${BUILD_NUMBER}"
SUFFIX "${_PIP_SUFFIX}"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/piversion.h")
-set_deploy_property(pip ${PIP_LIB_TYPE}
- LABEL "PIP main library"
- FULLNAME "${_PIP_DOMAIN}.pip"
- COMPANY "${_PIP_COMPANY}"
- INFO "Platform-Independent Primitives")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h")
file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h")
endif()
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/piversion.h")
-message(STATUS "Building PIP version ${PIP_VERSION} (${PIP_LIB_TYPE})")
-
if(MINGW)
find_package(MinGW REQUIRED)
@@ -172,48 +207,25 @@ endif()
# Compiler
get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
-#message("${C_COMPILER}")
-# Sources
-
# Main lib
-set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt" "introspection" "concurrent" "cloud")
-include_directories("${PIP_SRC_MAIN}")
+file(GLOB PIP_FOLDERS LIST_DIRECTORIES TRUE "${CMAKE_CURRENT_SOURCE_DIR}/lib/main/*")
+list(APPEND PIP_FOLDERS "${CMAKE_CURRENT_SOURCE_DIR}/lib/main")
set(PIP_MAIN_FOLDERS)
foreach(F ${PIP_FOLDERS})
- list(APPEND PIP_MAIN_FOLDERS "\"${PROJECT_SOURCE_DIR}/${PIP_SRC_MAIN}/${F}\"")
- include_directories("${PIP_SRC_MAIN}/${F}")
- gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS)
+ if (IS_DIRECTORY "${F}")
+ list(APPEND PIP_MAIN_FOLDERS "${F}")
+ include_directories("${F}")
+ endif()
endforeach(F)
-# Crypt lib
-gather_src("${PIP_SRC_CRYPT}" CPP_LIB_CRYPT HDRS PHDRS)
+if (DEFINED LIBPROJECT)
+ set(PIP_MAIN_FOLDERS "${PIP_MAIN_FOLDERS}" PARENT_SCOPE)
+endif()
-# Console lib
-gather_src("${PIP_SRC_CONSOLE}" CPP_LIB_CONSOLE HDRS PHDRS)
-
-# Compress lib
-gather_src("${PIP_SRC_COMPRESS}" CPP_LIB_COMPRESS HDRS PHDRS)
-
-# USB lib
-gather_src("${PIP_SRC_USB}" CPP_LIB_USB HDRS PHDRS)
-
-# FFTW lib
-gather_src("${PIP_SRC_FFTW}" CPP_LIB_FFTW HDRS PHDRS)
-
-# OpenCL lib
-gather_src("${PIP_SRC_OPENCL}" CPP_LIB_OPENCL HDRS PHDRS)
-
-# IO Utils lib
-gather_src("${PIP_SRC_IO_UTILS}" CPP_LIB_IO_UTILS HDRS PHDRS)
-
-# Concurrent lib
-gather_src("${PIP_SRC_CONCURRENT}" CPP_LIB_CONCURRENT HDRS PHDRS)
-
-gather_src("${PIP_SRC_CONCURRENT_TEST}" CPP_CONCURRENT_TEST HDRS PHDRS)
-
-# Cloud lib
-gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS)
+if (TESTS)
+ add_subdirectory(tests)
+endif()
if(PIP_FREERTOS)
add_definitions(-DPIP_FREERTOS)
@@ -257,57 +269,47 @@ if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT WIN32) AND (NOT DEFINED
list(APPEND LIBS_MAIN rt)
set(CMAKE_REQUIRED_LIBRARIES rt)
endif()
-CHECK_FUNCTION_EXISTS(timer_create PIP_TIMER_RT_0)
+CHECK_FUNCTION_EXISTS(timer_create PIP_TIMER_RT_0)
CHECK_FUNCTION_EXISTS(timer_settime PIP_TIMER_RT_1)
-CHECK_FUNCTION_EXISTS(timer_delete PIP_TIMER_RT_2)
+CHECK_FUNCTION_EXISTS(timer_delete PIP_TIMER_RT_2)
# Check if build debug version
if (CMAKE_BUILD_TYPE MATCHES Debug)
+ set(PIP_BUILD_TYPE "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall")
add_definitions(-DPIP_DEBUG)
- message(STATUS "Building PIP debug version")
else()
+ set(PIP_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
- message(STATUS "Building PIP release version")
endif()
-if (TESTS)
- include(DownloadGTest)
- set(CONCURRENT_TESTS 1) #"Enable tests for concurrent library"
-else()
- set(CONCURRENT_TESTS 0)
-endif()
# Check if std::iostream operators support
+set(PIP_STD_IOSTREAM "no")
if(STD_IOSTREAM)
+ set(PIP_STD_IOSTREAM "yes")
add_definitions(-DPIP_STD_IOSTREAM)
- message(STATUS "Building PIP with std iostream operators support")
-else()
- message(STATUS "Building PIP without std iostream operators support")
endif()
# Check if ICU used for PIString and PIChar
+set(PIP_ICU "no")
if(ICU)
- message(STATUS "Building PIP with ICU")
+ set(PIP_ICU "yes")
add_definitions(-DPIP_ICU)
list(APPEND LIBS_MAIN icuuc)
-else()
- message(STATUS "Building PIP without ICU")
endif()
# Check if PIP should be built with introspection
set(_PIP_DEFS "")
set(_PIP_DEFS_FILE "${CMAKE_CURRENT_BINARY_DIR}/pip_defs.h")
+set(PIP_INTROSPECTION "no")
if(INTROSPECTION)
- message(STATUS "Building PIP with introspection")
- message(STATUS "Warning: Introspection reduces the performance!")
+ set(PIP_INTROSPECTION "yes")
add_definitions(-DPIP_INTROSPECTION)
set(_PIP_DEFS "PIP_INTROSPECTION")
-else()
- message(STATUS "Building PIP without introspection")
endif()
if ((NOT DEFINED _PIP_SAVED_DEFS) OR (NOT "x${_PIP_SAVED_DEFS}" STREQUAL "x${_PIP_DEFS}"))
set(_PIP_SAVED_DEFS "${_PIP_DEFS}" CACHE STRING "pip_defs" FORCE)
@@ -322,10 +324,10 @@ list(APPEND HDRS ${_PIP_DEFS_FILE})
# Check if RT timers exists
if(PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2)
+ set(PIP_TIMERS "Thread, ThreadRT, Pool")
add_definitions(-DPIP_TIMER_RT)
- message(STATUS "Building PIP with timers: Thread, ThreadRT, Pool")
else()
- message(STATUS "Building PIP with timers: Thread, Pool")
+ set(PIP_TIMERS "Thread, Pool")
endif()
@@ -361,19 +363,12 @@ if(PIP_FREERTOS)
set(PIP_LIBS ${LIBS_MAIN})
else()
foreach(LIB_ ${LIBS_MAIN})
- find_library(${LIB_}_FOUND ${LIB_})
- if(${LIB_}_FOUND)
- list(APPEND CMAKE_REQUIRED_LIBRARIES ${${LIB_}_FOUND})
- list(APPEND PIP_LIBS ${${LIB_}_FOUND})
- endif()
+ pip_find_lib(${LIB_})
endforeach()
endif()
-list(APPEND LIBS_STATUS ${LIBS_MAIN})
import_version(pip PIP)
if(WIN32)
- make_rc(pip _RC)
add_definitions(-DPSAPI_VERSION=1)
- add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN} ${HDRS} ${PHDRS} ${_RC})
if(${C_COMPILER} STREQUAL "cl.exe")
set(CMAKE_CXX_FLAGS "/O2 /Ob2 /Ot /W0")
endif()
@@ -381,91 +376,37 @@ else()
set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} -fPIC")
if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
- else()
endif()
- add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN})
endif()
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
-include(GenerateExportHeader)
-generate_export_header(pip)
-list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
-target_link_libraries(pip ${PIP_LIBS})
+
+
+pip_module(main "${LIBS_MAIN}" "PIP main library" "" "")
+
if (NOT CROSSTOOLS)
if (NOT PIP_FREERTOS)
- # Check if USB is supported
- find_library(usb_FOUND usb SHARED)
+
+
+ pip_module(console "" "PIP console support" "" "")
+
+
+ pip_find_lib(usb)
if(usb_FOUND)
- message(STATUS "Building PIP with USB support")
- import_version(pip_usb pip)
- set_deploy_property(pip_usb ${PIP_LIB_TYPE}
- LABEL "PIP usb support"
- FULLNAME "${_PIP_DOMAIN}.pip_usb"
- COMPANY "${_PIP_COMPANY}"
- INFO "Platform-Independent Primitives")
- make_rc(pip_usb _RC)
- add_definitions(-DPIP_USB)
- add_library(pip_usb ${PIP_LIB_TYPE} ${CPP_LIB_USB} ${_RC})
- target_link_libraries(pip_usb pip ${usb_FOUND})
- list(APPEND LIBS_STATUS usb)
- list(APPEND PIP_LIBS_TARGETS pip_usb)
- else()
- message(STATUS "Building PIP without USB support")
+ pip_module(usb "usb" "PIP usb support" "" "")
endif()
- # Add console library
- import_version(pip_console pip)
- set_deploy_property(pip_console ${PIP_LIB_TYPE}
- LABEL "PIP console support"
- FULLNAME "${_PIP_DOMAIN}.pip_console"
- COMPANY "${_PIP_COMPANY}"
- INFO "Platform-Independent Primitives")
- make_rc(pip_console _RC)
- add_library(pip_console ${PIP_LIB_TYPE} ${CPP_LIB_CONSOLE} ${_RC})
- target_link_libraries(pip_console pip)
- list(APPEND PIP_LIBS_TARGETS pip_console)
-
-
- # Check if PIP support cryptographic encryption/decryption using sodium library
- find_library(sodium_FOUND sodium)
- if(sodium_FOUND)
- message(STATUS "Building PIP with crypt support")
- import_version(pip_crypt pip)
- set_deploy_property(pip_crypt ${PIP_LIB_TYPE}
- LABEL "PIP crypt support"
- FULLNAME "${_PIP_DOMAIN}.pip_crypt"
- COMPANY "${_PIP_COMPANY}"
- INFO "Platform-Independent Primitives")
- make_rc(pip_crypt _RC)
- add_definitions(-DPIP_CRYPT)
- add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT} ${_RC})
- target_link_libraries(pip_crypt pip ${sodium_FOUND})
- list(APPEND LIBS_STATUS sodium)
- list(APPEND PIP_LIBS_TARGETS pip_crypt)
- else()
- message(STATUS "Building PIP without crypt support")
- endif()
-
-
- # Check if PIP support compress/decompress using zlib library
- find_library(zlib_FOUND NAMES z zlib)
+ pip_find_lib(zlib NAMES z zlib)
if(zlib_FOUND)
- message(STATUS "Building PIP with zlib compress support")
- import_version(pip_compress pip)
- set_deploy_property(pip_compress ${PIP_LIB_TYPE}
- LABEL "PIP compression support"
- FULLNAME "${_PIP_DOMAIN}.pip_compress"
- COMPANY "${_PIP_COMPANY}"
- INFO "Platform-Independent Primitives")
- make_rc(pip_compress _RC)
- add_definitions(-DPIP_COMPRESS)
- add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS} ${_RC})
- target_link_libraries(pip_compress pip ${zlib_FOUND})
- list(APPEND LIBS_STATUS zlib)
- list(APPEND PIP_LIBS_TARGETS pip_compress)
- else()
- message(STATUS "Building PIP without compress support")
+ pip_module(compress "zlib" "PIP compression support" "" "")
+ endif()
+
+
+ pip_find_lib(sodium)
+ if(sodium_FOUND)
+ pip_module(crypt "sodium" "PIP crypt support" "" "")
+ pip_module(cloud "pip_crypt" "PIP cloud support" "" "")
endif()
@@ -475,7 +416,6 @@ if (NOT CROSSTOOLS)
set(FFTW_LIB_SUFFIXES2 "" "-3")
set(FFTW_LIBS)
set(FFTW_ABS_LIBS)
- set(PIP_FFTW_FOUND)
set(CMAKE_REQUIRED_INCLUDES fftw3.h)
foreach(FFTW_S_ IN LISTS FFTW_LIB_SUFFIXES)
set(FFTW_BREAK false)
@@ -483,171 +423,100 @@ if (NOT CROSSTOOLS)
if(NOT FFTW_BREAK)
set(FFTW_CLN "${FFTW_LIB_NAME}${FFTW_S_}${FFTW_S2_}")
set(FFTW_CLNT "${FFTW_LIB_NAME}${FFTW_S_}_threads${FFTW_S2_}")
- find_library(${FFTW_CLN}_FOUND ${FFTW_CLN})
- find_library(${FFTW_CLNT}_FOUND ${FFTW_CLNT})
- if(${FFTW_CLN}_FOUND)
+ find_library(${FFTW_CLN}_LIBRARIES ${FFTW_CLN})
+ find_library(${FFTW_CLNT}_LIBRARIES ${FFTW_CLNT})
+ set(${FFTW_CLN}_FOUND FALSE)
+ set(${FFTW_CLNT}_FOUND FALSE)
+ if(${FFTW_CLN}_LIBRARIES)
+ set(${FFTW_CLN}_FOUND TRUE)
list(APPEND FFTW_LIBS "${FFTW_CLN}")
- list(APPEND FFTW_ABS_LIBS "${${FFTW_CLN}_FOUND}")
- #message(STATUS "PIFFTW found ${FFTW_CLN} = ${${FFTW_CLN}_FOUND}")
+ list(APPEND FFTW_ABS_LIBS "${${FFTW_CLN}_LIBRARIES}")
set(${FFTW_CLN}_CTS "${FFTW_CLN}")
- if(${FFTW_CLNT}_FOUND)
+ if(${FFTW_CLNT}_FLIBRARIES)
+ set(${FFTW_CLNT}_FOUND TRUE)
list(APPEND FFTW_LIBS "${FFTW_CLNT}")
- list(APPEND FFTW_ABS_LIBS "${${FFTW_CLNT}_FOUND}")
+ list(APPEND FFTW_ABS_LIBS "${${FFTW_CLNT}_LIBRARIES}")
list(APPEND ${FFTW_CLN}_CTS "${FFTW_CLNT}")
endif()
set(CMAKE_REQUIRED_LIBRARIES ${${FFTW_CLN}_CTS})
CHECK_FUNCTION_EXISTS(fftw${FFTW_S_}_make_planner_thread_safe ${FFTW_CLN}_TSFE)
add_definitions(-DPIP_FFTW${FFTW_S_})
- set(PIP_FFTW_FOUND true)
if(${FFTW_CLN}_TSFE)
add_definitions(-DPIP_FFTW${FFTW_S_}_THREADSAFE)
else()
message(STATUS "Warning: PIFFTW${FFTW_S_}::preparePlan was not threadsafe")
endif()
- #message(STATUS "${FFTW_CLN} -> ${${FFTW_CLN}_TSFE}")
endif()
endif()
endforeach()
endforeach()
if(FFTW_LIBS)
- message(STATUS "Building PIP with fftw3 support: ${FFTW_LIBS}")
- import_version(pip_fftw pip)
- set_deploy_property(pip_fftw ${PIP_LIB_TYPE}
- LABEL "PIP FFTW support"
- FULLNAME "${_PIP_DOMAIN}.pip_fftw"
- COMPANY "${_PIP_COMPANY}"
- INFO "Platform-Independent Primitives")
- make_rc(pip_fftw _RC)
- add_library(pip_fftw ${PIP_LIB_TYPE} ${CPP_LIB_FFTW} ${_RC})
- target_link_libraries(pip_fftw pip ${FFTW_ABS_LIBS})
- list(APPEND LIBS_STATUS ${FFTW_LIBS})
- list(APPEND PIP_LIBS_TARGETS pip_fftw)
- else()
- message(STATUS "Building PIP without fftw3 support")
+ pip_module(fftw "${FFTW_LIBS}" "PIP FFTW support" "" "")
endif()
- # Check if PIP support OpenCL
- find_package(OpenCL QUIET)
+ find_package(OpenCL QUIET) #OpenCL_VERSION_STRING
if(OpenCL_FOUND)
- message(STATUS "Building PIP with OpenCL support")
- import_version(pip_opencl pip)
- set_deploy_property(pip_opencl ${PIP_LIB_TYPE}
- LABEL "PIP OpenCL support"
- FULLNAME "${_PIP_DOMAIN}.pip_opencl"
- COMPANY "${_PIP_COMPANY}"
- INFO "Platform-Independent Primitives")
- make_rc(pip_opencl _RC)
- if(APPLE)
- include_directories(${OpenCL_INCLUDE_DIRS}/Headers)
- else()
- include_directories(${OpenCL_INCLUDE_DIRS})
- endif()
- add_definitions(-DPIP_OPENCL)
- pip_resources(CL_RES "${PIP_SRC_OPENCL}/resources.conf")
- add_library(pip_opencl ${PIP_LIB_TYPE} ${CPP_LIB_OPENCL} ${CL_RES} ${_RC})
- add_dependencies(pip_opencl pip_rc)
+ set(_opencl_lib OpenCL::OpenCL)
if(${CMAKE_VERSION} VERSION_LESS "3.7.0")
- target_link_libraries(pip_opencl pip OpenCL)
- else()
- target_link_libraries(pip_opencl pip OpenCL::OpenCL)
+ target_link_libraries(_opencl_lib OpenCL)
endif()
- list(APPEND LIBS_STATUS OpenCL)
- list(APPEND PIP_LIBS_TARGETS pip_opencl)
- set(OpenCL_FOUND ${OpenCL_LIBRARIES})
- else()
- message(STATUS "Building PIP without OpenCL support")
+ pip_module(opencl "${_opencl_lib}" "PIP OpenCL support" "" " (${OpenCL_VERSION_STRING})")
endif()
- # Check if PIP IO Utils library supports crypt
- set(IO_UTILS_LIBS pip)
- import_version(pip_io_utils pip)
- set_deploy_property(pip_io_utils ${PIP_LIB_TYPE}
- LABEL "PIP I/O utilites"
- FULLNAME "${_PIP_DOMAIN}.pip_io_utils"
- COMPANY "${_PIP_COMPANY}"
- INFO "Platform-Independent Primitives")
- make_rc(pip_io_utils _RC)
- add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS} ${_RC})
if(sodium_FOUND)
- message(STATUS "Building PIP IO Utils library with crypt support")
- list(APPEND IO_UTILS_LIBS pip_crypt)
+ pip_module(io_utils "pip_crypt" "PIP I/O support" "" " (+crypt)")
else()
- message(STATUS "Building PIP IO Utils library without crypt support, attention!")
- endif()
- target_link_libraries(pip_io_utils ${IO_UTILS_LIBS})
- list(APPEND PIP_LIBS_TARGETS pip_io_utils)
-
-
- # Concurrent module
- set(CONCURRENT_LIBS pip)
- import_version(pip_concurrent pip)
- set_deploy_property(pip_concurrent ${PIP_LIB_TYPE}
- LABEL "PIP concurrent support"
- FULLNAME "${_PIP_DOMAIN}.pip_concurrent"
- COMPANY "${_PIP_COMPANY}"
- INFO "Platform-Independent Primitives")
- make_rc(pip_concurrent _RC)
- add_library(pip_concurrent ${PIP_LIB_TYPE} ${CPP_LIB_CONCURRENT} ${_RC})
- target_link_libraries(pip_concurrent ${CONCURRENT_LIBS})
- set_property(TARGET pip_concurrent PROPERTY CXX_STANDARD 11)
- list(APPEND PIP_LIBS_TARGETS pip_concurrent)
-
- # Enable build tests for concurrent module
- if(CONCURRENT_TESTS)
- add_executable(pip_concurrent_test ${CPP_CONCURRENT_TEST})
- target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent)
- add_test(NAME pip_concurrent_test COMMAND tests)
- add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test)
+ pip_module(io_utils "" "PIP I/O support" "" "")
endif()
- # Build cloud library if crypt enabled
- if(sodium_FOUND)
- message(STATUS "Building PICloud support")
- import_version(pip_cloud pip)
- set_deploy_property(pip_cloud ${PIP_LIB_TYPE}
- LABEL "PIP cloud transport support"
- FULLNAME "${_PIP_DOMAIN}.pip_cloud"
- COMPANY "${_PIP_COMPANY}"
- INFO "Platform-Independent Primitives")
- make_rc(pip_cloud _RC)
- add_definitions(-DPIP_CLOUD)
- add_library(pip_cloud ${PIP_LIB_TYPE} ${CPP_LIB_CLOUD} ${_RC})
- target_link_libraries(pip_cloud pip pip_crypt)
- list(APPEND PIP_LIBS_TARGETS pip_cloud)
+ # Check Lua support
+ if(MINGW)
+ set(LUA_INCLUDE_DIR ${MINGW_INCLUDE})
endif()
-
+ find_package(Lua QUIET)
+ if (LUA_FOUND)
+ pip_module(lua "LUA" "PIP Lua support" "${LUA_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/3rd" " (${LUA_VERSION_STRING})")
+ list(APPEND HDR_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/3rd/LuaBridge")
+ endif()
+
# Test program
if(PIP_UTILS)
add_executable(pip_test "main.cpp")
target_link_libraries(pip_test pip)
+ if (LUA_FOUND)
+ target_link_libraries(pip_test pip_lua ${LUA_LIBRARIES})
+ endif()
endif()
else()
- message(STATUS "Building PIP with crypt support")
+ set(PIP_MSG_crypt "yes")
+ set(PIP_MSG_compress "yes")
+ set(PIP_MODULES pip)
add_definitions(-DPIP_CRYPT)
add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT})
target_link_libraries(pip_crypt pip)
- list(APPEND PIP_LIBS_TARGETS pip_crypt)
+ list(APPEND PIP_MODULES pip_crypt)
set(IO_UTILS_LIBS pip)
add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS})
- message(STATUS "Building PIP IO Utils library with crypt support")
list(APPEND IO_UTILS_LIBS pip_crypt)
target_link_libraries(pip_io_utils ${IO_UTILS_LIBS})
- list(APPEND PIP_LIBS_TARGETS pip_io_utils)
- message(STATUS "Building PIP with zlib compress support")
+ list(APPEND PIP_MODULES pip_io_utils)
add_definitions(-DPIP_COMPRESS)
add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS})
target_link_libraries(pip_compress pip)
- list(APPEND PIP_LIBS_TARGETS pip_compress)
+ list(APPEND PIP_MODULES pip_compress)
endif()
endif()
+string(REPLACE ";" "," PIP_EXPORTS_STR "${PIP_EXPORTS}")
+target_compile_definitions(pip PRIVATE "PICODE_DEFINES=\"${PIP_EXPORTS_STR}\"")
+
# Install
# Check if system or local install will be used (to system install use "-DLIB=" argument of cmake)
if(LIB)
@@ -655,9 +524,13 @@ if(LIB)
if(MINGW)
if (NOT CROSSTOOLS)
install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip)
- install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION ${MINGW_LIB})
+ install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip)
+ if(HDR_DIRS)
+ install(DIRECTORY ${HDR_DIRS} DESTINATION ${MINGW_INCLUDE}/pip)
+ endif()
+ install(TARGETS ${PIP_MODULES} ARCHIVE DESTINATION ${MINGW_LIB})
endif()
- install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION ${MINGW_BIN})
+ install(TARGETS ${PIP_MODULES} RUNTIME DESTINATION ${MINGW_BIN})
find_library(STDLIB "stdc++-6" PATHS ${MINGW_BIN} NO_DEFAULT_PATH)
find_library(STDLIB "stdc++-6")
#message("${STDLIB}")
@@ -667,28 +540,31 @@ if(LIB)
file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool")
endif()
else()
- #message("${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pip_export.h DESTINATION include)
endif()
else()
if (NOT CROSSTOOLS)
install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip)
+ if(HDR_DIRS)
+ install(DIRECTORY ${HDR_DIRS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip)
+ endif()
endif()
- install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
+ install(TARGETS ${PIP_MODULES} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()
- message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore")
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
else()
if(NOT PIP_FREERTOS)
if(WIN32)
- install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION bin)
- install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION lib)
+ install(TARGETS ${PIP_MODULES} RUNTIME DESTINATION bin)
+ install(TARGETS ${PIP_MODULES} ARCHIVE DESTINATION lib)
else()
- install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION lib)
+ install(TARGETS ${PIP_MODULES} DESTINATION lib)
endif()
install(FILES ${HDRS} DESTINATION include/pip)
- message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
+ if(HDR_DIRS)
+ install(DIRECTORY ${HDR_DIRS} DESTINATION include/pip)
+ endif()
endif()
endif()
@@ -696,7 +572,7 @@ if(NOT PIP_FREERTOS)
# Auxiliary
if (NOT CROSSTOOLS)
- add_subdirectory("${PIP_SRC_MAIN}/auxiliary/piterminal")
+ add_subdirectory("utils/piterminal")
endif()
# Utils
@@ -705,7 +581,6 @@ if(NOT PIP_FREERTOS)
add_subdirectory("utils/deploy_tool")
if(PIP_UTILS AND (NOT CROSSTOOLS))
add_subdirectory("utils/system_test")
- add_subdirectory("utils/remote_console")
add_subdirectory("utils/udp_file_transfer")
if(sodium_FOUND)
add_subdirectory("utils/system_daemon")
@@ -718,20 +593,11 @@ endif()
# Libraries messages
-message(STATUS "Building PIP modules: ${PIP_LIBS_TARGETS}")
if(DEFINED LIBPROJECT)
- set(PIP_LIBS_TARGETS ${PIP_LIBS_TARGETS} PARENT_SCOPE)
- list(APPEND _ALL_TARGETS ${PIP_LIBS_TARGETS})
+ set(PIP_MODULES ${PIP_MODULES} PARENT_SCOPE)
+ list(APPEND _ALL_TARGETS ${PIP_MODULES})
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
endif()
-if(NOT PIP_FREERTOS)
- foreach(LIB_ ${LIBS_STATUS})
- message(STATUS "Library ${LIB_} -> " ${${LIB_}_FOUND})
- if(NOT ${LIB_}_FOUND)
- message(WARNING "Library ${LIB_} not found, please install it")
- endif()
- endforeach()
-endif()
#
# Build Documentation
@@ -743,8 +609,9 @@ if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
set(DOXY_PROJECT_NUMBER "${PIP_VERSION}")
set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"")
set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"")
- set(DOXY_EXAMPLE_PATH "\"${PROJECT_SOURCE_DIR}/doc/examples\"")
- set(DOXY_IMAGE_PATH "\"${PROJECT_SOURCE_DIR}/doc/images\"")
+ set(DOXY_EXAMPLE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/examples\"")
+ set(DOXY_IMAGE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/images\"")
+ set(DOXY_EXCLUDE "\"${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/3rd\"")
if(DOXYGEN_DOT_EXECUTABLE)
string(REPLACE "\\" "" _DOT_PATH "${DOXYGEN_DOT_PATH}")
set(DOXY_DOT_PATH "\"${_DOT_PATH}\"")
@@ -752,13 +619,70 @@ if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
set(DOXY_DIA_PATH "\"${_DOT_PATH}\"")
endif()
set(DOXY_INPUT)
- foreach(F ${PIP_SRC_DIRS})
- list(APPEND DOXY_INPUT "\"${PROJECT_SOURCE_DIR}/${F}\"")
+ foreach(F ${PIP_MAIN_FOLDERS})
+ list(APPEND DOXY_INPUT "\"${F}\"")
endforeach(F)
- string(REPLACE ";" " " DOXY_INPUT "${DOXY_INPUT}")
- string(REPLACE ";" " " DOXY_INCLUDE_PATH "${PIP_MAIN_FOLDERS}")
+ string(REPLACE ";" " " DOXY_INPUT "\"${CMAKE_CURRENT_SOURCE_DIR}/lib\"")
+ string(REPLACE ";" " " DOXY_INCLUDE_PATH "${DOXY_INPUT}")
+ string(REPLACE ";" " " DOXY_DEFINES "${PIP_EXPORTS};DOXYGEN;PIOBJECT;PIOBJECT_SUBCLASS")
add_documentation(doc doc/Doxyfile.in)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION ../share/doc/pip COMPONENT doc EXCLUDE_FROM_ALL OPTIONAL)
endif()
endif()
+
+
+list(REMOVE_ITEM LIBS_STATUS ${PIP_MODULES})
+message("----------PIP----------")
+message(" Version: ${PIP_VERSION} ")
+message(" Linkage: ${PIP_LIB_TYPE_MSG}")
+message(" Type : ${PIP_BUILD_TYPE}")
+if(LIB)
+ message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
+else()
+ if(NOT PIP_FREERTOS)
+ message(" Install: local \"bin\", \"lib\" and \"include\"")
+ endif()
+endif()
+message("")
+message(" Options:")
+message(" std::iostream: ${PIP_STD_IOSTREAM}")
+message(" ICU strings : ${PIP_ICU}")
+message(" Timer types : ${PIP_TIMERS}")
+message(" Introspection: ${PIP_INTROSPECTION}")
+if(INTROSPECTION)
+ message(STATUS " Warning: Introspection reduces the performance!")
+endif()
+message("")
+message(" Modules:")
+foreach(_m ${PIP_SRC_MODULES})
+ message(" ${_m}: ${PIP_MSG_${_m}}")
+endforeach()
+message("")
+if (PIP_TESTS_LIST)
+ message(" Tests:")
+ foreach(_test ${PIP_TESTS_LIST})
+ message(" * ${_test}")
+ endforeach()
+else()
+ message(" Tests: skip (tests off)")
+endif()
+message("")
+message(" Utilites:")
+foreach(_util ${PIP_UTILS_LIST})
+ message(" * ${_util}")
+endforeach()
+if(NOT PIP_FREERTOS)
+ message("")
+ message(" Using libraries:")
+ foreach(LIB_ ${LIBS_STATUS})
+ if (NOT TARGET ${LIB_})
+ if(${LIB_}_FOUND)
+ message(" ${LIB_} -> ${${LIB_}_LIBRARIES}")
+ else()
+ message(" ${LIB_} not found, may fail")
+ endif()
+ endif()
+ endforeach()
+endif()
+message("-----------------------")
diff --git a/cmake/FindPIP.cmake b/cmake/FindPIP.cmake
index 5b21dc6b..06292c0d 100644
--- a/cmake/FindPIP.cmake
+++ b/cmake/FindPIP.cmake
@@ -5,11 +5,12 @@ Also create imported targets:
* PIP::USB
* PIP::Console
* PIP::Crypt
- * PIP::FFTW
* PIP::Compress
+ * PIP::FFTW
+ * PIP::OpenCL
* PIP::IOUtils
- * PIP::Concurrent
* PIP::Cloud
+ * PIP::Lua
These targets include directories and depends on
main library
@@ -63,9 +64,10 @@ find_library(PIP_CONSOLE_LIBRARY pip_console${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_CRYPT_LIBRARY pip_crypt${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_FFTW_LIBRARY pip_fftw${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_COMPRESS_LIBRARY pip_compress${_pip_suffix} HINTS ${_PIP_LIBDIR})
+find_library(PIP_OPENCL_LIBRARY pip_opencl${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_IO_UTILS_LIBRARY pip_io_utils${_pip_suffix} HINTS ${_PIP_LIBDIR})
-find_library(PIP_CONCURRENT_LIBRARY pip_concurrent${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_CLOUD_LIBRARY pip_cloud HINTS${_pip_suffix} ${_PIP_LIBDIR})
+find_library(PIP_LUA_LIBRARY pip_lua HINTS${_pip_suffix} ${_PIP_LIBDIR})
find_file(PIP_H_INCLUDE "pip.h" HINTS ${_PIP_INCDIR} $ENV{SMSDK_DIR}/include/pip)
get_filename_component(PIP_INCLUDES ${PIP_H_INCLUDE} PATH)
set(__ext "")
@@ -94,6 +96,19 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
endif()
endif()
+if(PIP_LUA_LIBRARY)
+ if (NOT LUA_FOUND)
+ if(MINGW)
+ set(LUA_INCLUDE_DIR ${MINGW_INCLUDE})
+ set(_prev_clp "${CMAKE_LIBRARY_PATH}")
+ set(CMAKE_LIBRARY_PATH "${MINGW_LIB}")
+ endif()
+ find_package(Lua QUIET)
+ if(MINGW)
+ set(CMAKE_LIBRARY_PATH "${_prev_clp}")
+ endif()
+ endif()
+endif()
if(NOT PIP_VERSION)
include(CheckSymbolExists)
@@ -117,15 +132,16 @@ if(PIP_FIND_VERSION VERSION_GREATER PIP_VERSION)
message(FATAL_ERROR "PIP version ${PIP_VERSION} is available, but ${PIP_FIND_VERSION} requested!")
endif()
-set(__modules "USB;Crypt;Console;FFTW;Compress;IOUtils;Concurrent;Cloud")
+set(__modules "USB;Crypt;Console;FFTW;Compress;IOUtils;Cloud;Lua")
set(__module_USB "${PIP_USB_LIBRARY}" )
set(__module_Console "${PIP_CONSOLE_LIBRARY}" )
set(__module_Crypt "${PIP_CRYPT_LIBRARY}" )
set(__module_FFTW "${PIP_FFTW_LIBRARY}" )
set(__module_Compress "${PIP_COMPRESS_LIBRARY}" )
+set(__module_OpenCL "${PIP_OPENCL_LIBRARY}" )
set(__module_IOUtils "${PIP_IO_UTILS_LIBRARY}" )
-set(__module_Concurrent "${PIP_CONCURRENT_LIBRARY}")
set(__module_Cloud "${PIP_CLOUD_LIBRARY}" )
+set(__module_Lua "${PIP_LUA_LIBRARY}" )
if((NOT TARGET PIP) AND PIP_LIBRARY)
add_library(PIP UNKNOWN IMPORTED)
set_target_properties(PIP PROPERTIES
@@ -147,6 +163,9 @@ endif()
if(__module_Cloud AND __module_IOUtils)
set_target_properties(PIP::Cloud PROPERTIES INTERFACE_LINK_LIBRARIES "PIP::IOUtils")
endif()
+if(__module_Lua)
+ set_target_properties(PIP::Lua PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES "PIP;${LUA_LIBRARIES}")
+endif()
include(PIPMacros)
diff --git a/cmake/PIPDocumentation.cmake b/cmake/PIPDocumentation.cmake
index e034bad2..9e9a099a 100644
--- a/cmake/PIPDocumentation.cmake
+++ b/cmake/PIPDocumentation.cmake
@@ -1,27 +1,6 @@
-macro(CONFIGURE_DOXYGEN_FILE DOXYGEN_CONFIG_FILE FILE_NAME_SUFFIX)
- if(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
- file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doxyfile-${FILE_NAME_SUFFIX}")
- file(READ ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE} DOXYFILE_CONTENTS)
- string(REPLACE "\\\n" " " DOXYFILE_CONTENTS "${DOXYFILE_CONTENTS}")
- string(REPLACE "\n" ";" DOXYFILE_LINES "${DOXYFILE_CONTENTS}")
- foreach(LINE IN LISTS DOXYFILE_LINES)
- if(LINE STRGREATER "")
- string(REGEX MATCH "^[a-zA-Z]([^ ])+" DOXY_PARAM ${LINE})
- if(DEFINED DOXY_${DOXY_PARAM})
- STRING(REGEX REPLACE "=([^\n])+" "= ${DOXY_${DOXY_PARAM}}" LINE ${LINE})
- endif(DEFINED DOXY_${DOXY_PARAM})
- endif()
- file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doxyfile-${FILE_NAME_SUFFIX} "${LINE}\n")
- endforeach()
- else()
- MESSAGE(SEND_ERROR "Doxygen configuration file '${DOXYGEN_CONFIG_FILE}' not found, can`t generate documentation")
- endif()
-endmacro(CONFIGURE_DOXYGEN_FILE)
-
-
macro(ADD_DOCUMENTATION TARGET DOXYGEN_CONFIG_FILE)
if(DOXYGEN_FOUND)
- configure_doxygen_file(${DOXYGEN_CONFIG_FILE} ${TARGET})
+ configure_file("${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/doxyfile-${TARGET}")
add_custom_target("genereate.${TARGET}" COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxyfile-${TARGET})
add_custom_target("${TARGET}" COMMAND ${CMAKE_COMMAND} -D COMPONENT=doc -P cmake_install.cmake)
add_dependencies("${TARGET}" "genereate.${TARGET}")
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
index 462dd31b..cbc2f526 100644
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -38,7 +38,7 @@ PROJECT_NAME = PIP
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 1.8.0
+PROJECT_NUMBER = ${DOXY_PROJECT_NUMBER}
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@@ -816,13 +816,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
-INPUT = src_main \
- src_crypt \
- src_fftw \
- src_io_utils \
- src_compress \
- src_opencl \
- src_usb
+INPUT = ${DOXY_INPUT}
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -895,7 +889,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.
-EXCLUDE =
+EXCLUDE = ${DOXY_EXCLUDE}
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
@@ -928,7 +922,7 @@ EXCLUDE_SYMBOLS =
# that contain example code fragments that are included (see the \include
# command).
-EXAMPLE_PATH = doc/examples
+EXAMPLE_PATH = ${DOXY_EXAMPLE_PATH}
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
@@ -948,7 +942,7 @@ EXAMPLE_RECURSIVE = NO
# that contain images that are to be included in the documentation (see the
# \image command).
-IMAGE_PATH = doc/images
+IMAGE_PATH = ${DOXY_IMAGE_PATH}
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
@@ -1459,14 +1453,14 @@ QHP_CUST_FILTER_NAME = PIP
# filters).
# This tag requires that the tag GENERATE_QHP is set to YES.
-QHP_CUST_FILTER_ATTRS = PIP
+QHP_CUST_FILTER_ATTRS = ${DOXY_QHP_CUST_FILTER_ATTRS}
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
# project's filter section matches. Qt Help Project / Filter Attributes (see:
# http://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
# This tag requires that the tag GENERATE_QHP is set to YES.
-QHP_SECT_FILTER_ATTRS = PIP
+QHP_SECT_FILTER_ATTRS = ${DOXY_QHP_SECT_FILTER_ATTRS}
# The QHG_LOCATION tag can be used to specify the location of Qt's
# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
@@ -2152,15 +2146,7 @@ SEARCH_INCLUDES = YES
# preprocessor.
# This tag requires that the tag SEARCH_INCLUDES is set to YES.
-INCLUDE_PATH = src_main/code \
- src_main/containers \
- src_main/core \
- src_main/math \
- src_main/system \
- src_main/thread \
- src_main/console \
- src_main/io_devices \
- src_main/io_utils
+INCLUDE_PATH = ${DOXY_INCLUDE_PATH}
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
@@ -2178,8 +2164,8 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-PREDEFINED = DOXYGEN \
- PIP_EXPORT
+PREDEFINED = ${DOXY_DEFINES}
+
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
@@ -2272,14 +2258,14 @@ CLASS_DIAGRAMS = YES
# the mscgen tool resides. If left empty the tool is assumed to be found in the
# default search path.
-MSCGEN_PATH = "C:/Program Files/doxygen/graphviz/bin"
+MSCGEN_PATH = ${DOXY_MSCGEN_PATH}
# You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
# If left empty dia is assumed to be found in the default search path.
-DIA_PATH = "C:/Program Files/doxygen/graphviz/bin"
+DIA_PATH = ${DOXY_DIA_PATH}
# If set to YES the inheritance and collaboration graphs will hide inheritance
# and usage relations if the target is undocumented or is not a class.
@@ -2472,7 +2458,7 @@ INTERACTIVE_SVG = NO
# found. If left blank, it is assumed the dot tool can be found in the path.
# This tag requires that the tag HAVE_DOT is set to YES.
-DOT_PATH = "C:/Program Files/doxygen/graphviz/bin"
+DOT_PATH = ${DOXY_DOT_PATH}
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the \dotfile
diff --git a/lib/cloud/piccloudclient.cpp b/lib/cloud/piccloudclient.cpp
index 6b7507ab..98fec593 100644
--- a/lib/cloud/piccloudclient.cpp
+++ b/lib/cloud/piccloudclient.cpp
@@ -23,3 +23,18 @@
PICloudClient::PICloudClient() {
}
+
+PICloudClient::~PICloudClient() {
+
+}
+
+
+bool PICloudClient::openDevice() {
+
+}
+
+
+bool PICloudClient::closeDevice() {
+
+}
+
diff --git a/lib/concurrent/piconditionlock.cpp b/lib/concurrent/piconditionlock.cpp
deleted file mode 100644
index 35dee0c4..00000000
--- a/lib/concurrent/piconditionlock.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- PIP - Platform Independent Primitives
-
- Stephan Fomenko
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see .
-*/
-
-#include "piconditionlock.h"
-#ifdef WINDOWS
-# include
-#else
-# include
-#endif
-
-
-PRIVATE_DEFINITION_START(PIConditionLock)
-#ifdef WINDOWS
- CRITICAL_SECTION
-#else
- pthread_mutex_t
-#endif
- nativeHandle;
-PRIVATE_DEFINITION_END(PIConditionLock)
-
-
-PIConditionLock::PIConditionLock() {
-#ifdef WINDOWS
- InitializeCriticalSection(&PRIVATE->nativeHandle);
-#else
- pthread_mutexattr_t attr;
- memset(&attr, 0, sizeof(attr));
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
- memset(&(PRIVATE->nativeHandle), 0, sizeof(PRIVATE->nativeHandle));
- pthread_mutex_init(&(PRIVATE->nativeHandle), &attr);
- pthread_mutexattr_destroy(&attr);
-#endif
-}
-
-
-PIConditionLock::~PIConditionLock() {
-#ifdef WINDOWS
- DeleteCriticalSection(&PRIVATE->nativeHandle);
-#else
- pthread_mutex_destroy(&(PRIVATE->nativeHandle));
-#endif
-}
-
-
-void PIConditionLock::lock() {
-#ifdef WINDOWS
- EnterCriticalSection(&PRIVATE->nativeHandle);
-#else
- pthread_mutex_lock(&(PRIVATE->nativeHandle));
-#endif
-}
-
-
-void PIConditionLock::unlock() {
-#ifdef WINDOWS
- LeaveCriticalSection(&PRIVATE->nativeHandle);
-#else
- pthread_mutex_unlock(&(PRIVATE->nativeHandle));
-#endif
-}
-
-
-void *PIConditionLock::handle() {
-#ifdef WINDOWS
- return &PRIVATE->nativeHandle;
-#else
- return &PRIVATE->nativeHandle;
-#endif
-}
-
-
-bool PIConditionLock::tryLock() {
-#ifdef WINDOWS
- return TryEnterCriticalSection(&PRIVATE->nativeHandle) != 0;
-#else
- return (pthread_mutex_trylock(&(PRIVATE->nativeHandle)) == 0);
-#endif
-}
diff --git a/lib/console/piconsole.cpp b/lib/console/piconsole.cpp
deleted file mode 100644
index 8202826b..00000000
--- a/lib/console/piconsole.cpp
+++ /dev/null
@@ -1,1168 +0,0 @@
-/*
- PIP - Platform Independent Primitives
- Console output/input
- Ivan Pelipenko peri4ko@yandex.ru
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see .
-*/
-#include "piconsole.h"
-#include "piincludes_p.h"
-#include "pipeer.h"
-#include "pidiagnostics.h"
-#include "pisystemmonitor.h"
-#ifndef WINDOWS
-# include
-# include
-# include
-#else
-# include
-# define COMMON_LVB_UNDERSCORE 0x8000
-#endif
-
-
-/** \class PIConsole
- * \brief Console output class
- * \details
- * \section PIConsole_sec0 Synopsis
- * This class provides output to console with automatic alignment and update.
- * It supports tabs, keyboard listening, formats and colors.
- *
- * \section PIConsole_sec1 Layout
- * %PIConsole works with variable pointers. You should add your variables with
- * functions \a addVariable() which receives label name, pointer to variable
- * and optional column and format. Columns count is dynamically increased if
- * new column used. E.g. if you add variable to empty tab to column 3, columns
- * count will be increased to 3, but two firsts columns will be empty. Each column
- * filled from top to bottom, but you can add just string with function
- * \a addString() or add empty line with function \a addEmptyLine(). Layout scheme:
- * \image html piconsole_layout.png
- *
- * \section PIConsole_sec2 Keyboard usage
- * %PIConsole should to be single in application. %PIConsole aggregate PIKbdListener
- * which grab keyboard and automatic switch tabs by theirs bind keys. If there is no
- * tab binded to pressed key external function "slot" will be called
- *
- **/
-
-
-PRIVATE_DEFINITION_START(PIConsole)
-#ifdef WINDOWS
-void getWinCurCoord() {GetConsoleScreenBufferInfo(hOut, &csbi); ccoord = csbi.dwCursorPosition;}
-COORD & getWinCoord(int dx = 0, int dy = 0) {getWinCurCoord(); ccoord.X += dx; ccoord.Y += dy; return ccoord;}
-void * hOut;
-CONSOLE_SCREEN_BUFFER_INFO sbi, csbi;
-CONSOLE_CURSOR_INFO curinfo;
-COORD ccoord, ulcoord;
-WORD dattr;
-DWORD smode, written;
-#endif
-PRIVATE_DEFINITION_END(PIConsole)
-
-
-PIConsole::PIConsole(bool startNow, PIKbdListener::KBFunc slot): PIThread() {
- setName("console");
- setPriority(piLow);
- needLockRun(true);
- ret_func = slot;
- num_format = systime_format = 0;
- vid = 0;
- cur_tab = width = height = pwidth = pheight = max_y = 0;
- def_align = Nothing;
- tabs.reserve(16);
-#ifdef WINDOWS
- PRIVATE->ulcoord.X = 0;
- PRIVATE->hOut = GetStdHandle(STD_OUTPUT_HANDLE);
- GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
- PRIVATE->dattr = PRIVATE->sbi.wAttributes;
- width = PRIVATE->sbi.srWindow.Right - PRIVATE->sbi.srWindow.Left;
- height = PRIVATE->sbi.srWindow.Bottom - PRIVATE->sbi.srWindow.Top;
- PRIVATE->ulcoord.Y = PRIVATE->sbi.srWindow.Top;
- GetConsoleMode(PRIVATE->hOut, &PRIVATE->smode);
- GetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
-#else
-# ifdef FREERTOS
- width = 80;
- height = 24;
-# else
- winsize ws;
- ioctl(0, TIOCGWINSZ, &ws);
- width = ws.ws_col;
- height = ws.ws_row;
-# endif
-#endif
- addTab("main");
- listener = new PIKbdListener(key_event, this);
- peer_timer = new PITimer();
- peer_timer->setName("__S__.PIConsole.peer_timer");
- peer = 0;
- server_mode = pause_ = false;
- state = Disconnected;
- peer_timer->addDelimiter(20);
- peer_timer->setName("__S__PIConsole::peer_timer");
- CONNECT2(void, void * , int, peer_timer, tickEvent, this, peerTimer);
- if (startNow) start();
-}
-
-
-PIConsole::~PIConsole() {
- stopPeer();
- if (isRunning())
- stop();
- clearTabs(false);
- delete listener;
- delete peer_timer;
-#ifdef WINDOWS
- SetConsoleMode(PRIVATE->hOut, PRIVATE->smode);
- SetConsoleTextAttribute(PRIVATE->hOut, PRIVATE->dattr);
-#endif
-}
-
-
-int PIConsole::addTab(const PIString & name, char bind_key) {
- if (isRunning()) lock();
- tabs.push_back(Tab(name, bind_key));
- cur_tab = tabs.size() - 1;
- if (isRunning()) unlock();
- return tabs.size();
-}
-
-
-void PIConsole::removeTab(uint index) {
- if (index >= tabs.size()) return;
- if (isRunning()) lock();
- tabs.remove(index);
- if (cur_tab >= tabs.size()) cur_tab = tabs.size() - 1;
- if (isRunning()) unlock();
-}
-
-
-void PIConsole::removeTab(const PIString & name) {
- uint index = tabs.size() + 1;
- for (uint i = 0; i < tabs.size(); ++i) {
- if (tabs[i].name == name) {
- index = i;
- break;
- }
- }
- removeTab(index);
-}
-
-
-void PIConsole::clearTab(uint index) {
- if (index >= tabs.size()) return;
- lock();
- tabs[index].columns.clear();
- if (cur_tab == index) {
- clearScreen();
- fillLabels();
- }
- if (cur_tab >= tabs.size()) cur_tab = tabs.size() - 1;
- unlock();
-}
-
-
-void PIConsole::clearTab(const PIString & name) {
- uint index = tabs.size() + 1;
- for (uint i = 0; i < tabs.size(); ++i) {
- if (tabs[i].name == name) {
- index = i;
- break;
- }
- }
- clearTab(index);
-}
-
-
-void PIConsole::update() {
- lock();
- fillLabels();
- unlock();
-}
-
-
-bool PIConsole::setTab(uint index) {
- if (index >= tabs.size())
- return false;
- if (!isRunning()) {
- cur_tab = index;
- return true;
- }
- lock();
- PICout::__mutex__().lock();
- cur_tab = index;
- clearScreen();
- fillLabels();
- PICout::__mutex__().unlock();
- unlock();
- return true;
-}
-
-
-bool PIConsole::setTab(const PIString & name) {
- uint index = tabs.size() + 1;
- for (uint i = 0; i < tabs.size(); ++i) {
- if (tabs[i].name == name) {
- index = i;
- break;
- }
- }
- return setTab(index);
-}
-
-
-bool PIConsole::setTabBindKey(uint index, char bind_key) {
- if (index >= tabs.size())
- return false;
- tabs[index].key = bind_key;
- return true;
-}
-
-
-bool PIConsole::setTabBindKey(const PIString & name, char bind_key) {
- uint index =tabs.size() + 1;
- for (uint i = 0; i < tabs.size(); ++i) {
- if (tabs[i].name == name) {
- index = i;
- break;
- }
- }
- return setTabBindKey(index, bind_key);
-}
-
-
-void PIConsole::key_event(PIKbdListener::KeyEvent key, void * t) {
- PIConsole * p = (PIConsole * )t;
- int ct = p->cur_tab;
- if (key.key == PIKbdListener::LeftArrow) {
- do {
- ct--;
- if (ct < 0) return;
- } while (p->tabs[ct].key == 0);
- p->setTab(ct);
- return;
- }
- if (key.key == PIKbdListener::RightArrow) {
- do {
- ct++;
- if (ct >= p->tabs.size_s()) return;
- } while (p->tabs[ct].key == 0);
- p->setTab(ct);
- return;
- }
- for (uint i = 0; i < p->tabsCount(); ++i) {
- if (p->tabs[i].key == key.key) {
- p->setTab(i);
- return;
- }
- }
- if (p->ret_func != 0) p->ret_func(key, t);
- p->keyPressed(key, t);
-}
-
-
-int PIConsole::couts(const PIString & v) {
- return printf("%s", v.data());
-}
-
-
-int PIConsole::couts(const char * v) {
- return printf("%s", v);
-}
-
-
-void PIConsole::clearVariables(bool clearScreen) {
- if (isRunning()) lock();
- if (clearScreen && isRunning()) {
- toUpperLeft();
- clearScreenLower();
- }
- columns().clear();
- if (isRunning()) unlock();
-}
-
-
-void PIConsole::stop(bool clear) {
- PIThread::stop(true);
- if (clear) clearScreen();
- moveTo(0, max_y + 4);
- showCursor();
- couts(fstr(Normal));
-#ifdef WINDOWS
- SetConsoleMode(PRIVATE->hOut, PRIVATE->smode);
- SetConsoleTextAttribute(PRIVATE->hOut, PRIVATE->dattr);
-#endif
- fflush(0);
-}
-
-
-PIString PIConsole::fstr(FormatFlags f) {
- num_format = systime_format = 0;
- if (f[PIConsole::Dec]) num_format = 0;
- if (f[PIConsole::Hex]) num_format = 1;
- if (f[PIConsole::Oct]) num_format = 2;
- if (f[PIConsole::Bin]) num_format = 4;
- if (f[PIConsole::Scientific]) num_format = 3;
- if (f[PIConsole::SystemTimeSplit]) systime_format = 0;
- if (f[PIConsole::SystemTimeSeconds]) systime_format = 1;
-
-#ifdef WINDOWS
- WORD attr = 0;
-
- if (f[PIConsole::Inverse]) {
- if (f[PIConsole::Red]) attr |= BACKGROUND_RED;
- if (f[PIConsole::Green]) attr |= BACKGROUND_GREEN;
- if (f[PIConsole::Blue]) attr |= BACKGROUND_BLUE;
- if (f[PIConsole::Yellow]) attr |= (BACKGROUND_RED | BACKGROUND_GREEN);
- if (f[PIConsole::Magenta]) attr |= (BACKGROUND_RED | BACKGROUND_BLUE);
- if (f[PIConsole::Cyan]) attr |= (BACKGROUND_GREEN | BACKGROUND_BLUE);
- if (f[PIConsole::White]) attr |= (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE);
- if (f[PIConsole::BackRed]) attr |= FOREGROUND_RED;
- if (f[PIConsole::BackGreen]) attr |= FOREGROUND_GREEN;
- if (f[PIConsole::BackBlue]) attr |= FOREGROUND_BLUE;
- if (f[PIConsole::BackYellow]) attr |= (FOREGROUND_RED | FOREGROUND_GREEN);
- if (f[PIConsole::BackMagenta]) attr |= (FOREGROUND_RED | FOREGROUND_BLUE);
- if (f[PIConsole::BackCyan]) attr |= (FOREGROUND_GREEN | FOREGROUND_BLUE);
- if (f[PIConsole::BackWhite]) attr |= (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- if ((attr & BACKGROUND_RED) + (attr & BACKGROUND_GREEN) + (attr & BACKGROUND_BLUE) == 0)
- attr |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
- } else {
- if (f[PIConsole::Red]) attr |= FOREGROUND_RED;
- if (f[PIConsole::Green]) attr |= FOREGROUND_GREEN;
- if (f[PIConsole::Blue]) attr |= FOREGROUND_BLUE;
- if (f[PIConsole::Yellow]) attr |= (FOREGROUND_RED | FOREGROUND_GREEN);
- if (f[PIConsole::Magenta]) attr |= (FOREGROUND_RED | FOREGROUND_BLUE);
- if (f[PIConsole::Cyan]) attr |= (FOREGROUND_GREEN | FOREGROUND_BLUE);
- if (f[PIConsole::White]) attr |= (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
- if (f[PIConsole::BackRed]) attr |= BACKGROUND_RED;
- if (f[PIConsole::BackGreen]) attr |= BACKGROUND_GREEN;
- if (f[PIConsole::BackBlue]) attr |= BACKGROUND_BLUE;
- if (f[PIConsole::BackYellow]) attr |= (BACKGROUND_RED | BACKGROUND_GREEN);
- if (f[PIConsole::BackMagenta]) attr |= (BACKGROUND_RED | BACKGROUND_BLUE);
- if (f[PIConsole::BackCyan]) attr |= (BACKGROUND_GREEN | BACKGROUND_BLUE);
- if (f[PIConsole::BackWhite]) attr |= (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE);
- if ((attr & FOREGROUND_RED) + (attr & FOREGROUND_GREEN) + (attr & FOREGROUND_BLUE) == 0)
- attr |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
- }
- if (f[PIConsole::Bold]) attr |= FOREGROUND_INTENSITY;
- if (f[PIConsole::Underline]) attr |= COMMON_LVB_UNDERSCORE;
-
- SetConsoleTextAttribute(PRIVATE->hOut, attr);
- return PIString();
-#else
- PIString ts("\e[0");
-
- if (f[PIConsole::Bold]) ts += ";1";
- if (f[PIConsole::Faint]) ts += ";2";
- if (f[PIConsole::Italic]) ts += ";3";
- if (f[PIConsole::Underline]) ts += ";4";
- if (f[PIConsole::Blink]) ts += ";5";
- if (f[PIConsole::Inverse]) ts += ";7";
-
- if (f[PIConsole::Black]) ts += ";30";
- if (f[PIConsole::Red]) ts += ";31";
- if (f[PIConsole::Green]) ts += ";32";
- if (f[PIConsole::Yellow]) ts += ";33";
- if (f[PIConsole::Blue]) ts += ";34";
- if (f[PIConsole::Magenta]) ts += ";35";
- if (f[PIConsole::Cyan]) ts += ";36";
- if (f[PIConsole::White]) ts += ";37";
-
- if (f[PIConsole::BackBlack]) ts += ";40";
- if (f[PIConsole::BackRed]) ts += ";41";
- if (f[PIConsole::BackGreen]) ts += ";42";
- if (f[PIConsole::BackYellow]) ts += ";43";
- if (f[PIConsole::BackBlue]) ts += ";44";
- if (f[PIConsole::BackMagenta]) ts += ";45";
- if (f[PIConsole::BackCyan]) ts += ";46";
- if (f[PIConsole::BackWhite]) ts += ";47";
-
- return ts + "m";
-#endif
-}
-
-
-inline int PIConsole::couts(const bool v) {return (v ? printf("true") : printf("false"));}
-inline int PIConsole::couts(const char v) {return printf("%c", v);}
-inline int PIConsole::couts(const short v) {
- switch (num_format) {case (1): return printf("0x%.4hX", v); break; case (2): return printf("%o", v); break; case (4): return printf("%s", toBin(&v, 2)); break; default: return printf("%hd", v); break;}
-}
-inline int PIConsole::couts(const int v) {
- switch (num_format) {case (1): return printf("0x%.8X", v); break; case (2): return printf("%o", v); break; case (4): return printf("%s", toBin(&v, 4)); break; default: return printf("%d", v); break;}
-}
-inline int PIConsole::couts(const long v) {
- switch (num_format) {case (1): return printf("0x%.16lX", v); break; case (2): return printf("%lo", v); break; case (4): return printf("%s", toBin(&v, sizeof(v))); break; default: return printf("%ld", v); break;}
-}
-inline int PIConsole::couts(const llong v) {
- switch (num_format) {case (1): return printf("0x%.16llX", v); break; case (2): return printf("%llo", v); break; case (4): return printf("%s", toBin(&v, sizeof(v))); break; default: return printf("%lld", v); break;}
-}
-inline int PIConsole::couts(const uchar v) {
- switch (num_format) {case (1): return printf("0x%.2X", v); break; case (2): return printf("%o", v); break; case (4): return printf("%s", toBin(&v, 1)); break; default: return printf("%u", v); break;}
-}
-inline int PIConsole::couts(const ushort v) {
- switch (num_format) {case (1): return printf("0x%.4hX", v); break; case (2): return printf("%o", v); break; case (4): return printf("%s", toBin(&v, 2)); break; default: return printf("%hu", v); break;}
-}
-inline int PIConsole::couts(const uint v) {
- switch (num_format) {case (1): return printf("0x%.8X", v); break; case (2): return printf("%o", v); break; case (4): return printf("%s", toBin(&v, 4)); break; default: return printf("%u", v); break;}
-}
-inline int PIConsole::couts(const ulong v) {
- switch (num_format) {case (1): return printf("0x%.16lX", v); break; case (2): return printf("%lo", v); break; case (4): return printf("%s", toBin(&v, sizeof(v))); break; default: return printf("%lu", v); break;}
-}
-inline int PIConsole::couts(const ullong v) {
- switch (num_format) {case (1): return printf("0x%.16llX", v); break; case (2): return printf("%llo", v); break; case (4): return printf("%s", toBin(&v, sizeof(v))); break; default: return printf("%llu", v); break;}
-}
-inline int PIConsole::couts(const float v) {
- switch (num_format) {case (3): return printf("%e", v); break; default: return printf("%.5g", v); break;}
-}
-inline int PIConsole::couts(const double v) {
- switch (num_format) {case (3): return printf("%le", v); break; default: return printf("%.5lg", v); break;}
-}
-inline int PIConsole::couts(const PISystemTime & v) {
- switch (systime_format) {case (1): return printf("%.6lg", v.toSeconds()); break;
- default: return couts(v.seconds) + printf(" s, ") + couts(v.nanoseconds) + printf(" ns"); break;}
-}
-
-
-void PIConsole::toUpperLeft() {
-#ifdef WINDOWS
- SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ulcoord);
-#else
- printf("\e[H");
-#endif
-}
-
-void PIConsole::moveRight(int n) {
-#ifdef WINDOWS
- SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->getWinCoord(n));
-#else
- if (n > 0) printf("\e[%dC", n);
-#endif
-}
-
-void PIConsole::moveLeft(int n) {
-#ifdef WINDOWS
- SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->getWinCoord(-n));
-#else
- if (n > 0) printf("\e[%dD", n);
-#endif
-}
-
-void PIConsole::moveTo(int x, int y) {
-#ifdef WINDOWS
- PRIVATE->ccoord.X = x;
- PRIVATE->ccoord.Y = PRIVATE->ulcoord.Y + y;
- SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);
-#else
- printf("\e[%d;%dH", y, x);
-#endif
-}
-
-void PIConsole::clearScreen() {
-#ifdef WINDOWS
- couts(fstr(Normal));
- toUpperLeft();
- FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
- FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
-#else
- couts(fstr(Normal)); printf("\e[H\e[J");
-#endif
-}
-
-void PIConsole::clearScreenLower() {
-#ifdef WINDOWS
- couts(fstr(Normal));
- PRIVATE->getWinCurCoord();
- FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
- FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
-#else
- couts(fstr(Normal)); printf("\e[J");
-#endif
-}
-
-void PIConsole::clearLine() {
-#ifdef WINDOWS
- PRIVATE->getWinCurCoord();
- FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width - PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
- FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width - PRIVATE->ccoord.X, PRIVATE->ccoord, &PRIVATE->written);
-#else
- printf("\e[K");
-#endif
-}
-
-void PIConsole::newLine() {
-#ifdef WINDOWS
- PRIVATE->getWinCurCoord();
- PRIVATE->ccoord.X = 0; PRIVATE->ccoord.Y++;
- SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);
-#else
- printf("\eE");
-#endif
-}
-
-void PIConsole::hideCursor() {
-#ifdef WINDOWS
- PRIVATE->curinfo.bVisible = false;
- SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
-#else
- printf("\e[?25l");
-#endif
-}
-
-void PIConsole::showCursor() {
-#ifdef WINDOWS
- PRIVATE->curinfo.bVisible = true; SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
-#else
- printf("\e[?25h");
-#endif
-}
-
-
-void PIConsole::begin() {
-#ifdef WINDOWS
- SetConsoleMode(PRIVATE->hOut, ENABLE_WRAP_AT_EOL_OUTPUT);
-#endif
- max_y = 0;
- PICout::__mutex__().lock();
- clearScreen();
- hideCursor();
- fillLabels();
- PICout::__mutex__().unlock();
-}
-
-
-void PIConsole::run() {
- if (pause_) return;
- uint cx, clen = 0;
- int j;
-#ifdef WINDOWS
- GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
- width = PRIVATE->sbi.srWindow.Right - PRIVATE->sbi.srWindow.Left;
- height = PRIVATE->sbi.srWindow.Bottom - PRIVATE->sbi.srWindow.Top;
-#else
-# ifdef FREERTOS
- width = 80;
- height = 24;
-# else
- winsize ws;
- ioctl(0, TIOCGWINSZ, &ws);
- width = ws.ws_col;
- height = ws.ws_row;
-# endif
-#endif
- //fflush(0); return;
- PICout::__mutex__().lock();
- if (pwidth != width || pheight != height) {
- clearScreen();
- fillLabels();
- }
- pwidth = width;
- pheight = height;
- col_cnt = columns().size();
- col_wid = (col_cnt > 0) ? width / col_cnt : width;
- for (uint i = 0; i < col_cnt; ++i) {
- PIVector & cvars(tabs[cur_tab].columns[i].variables);
- cx = col_wid * i;
- toUpperLeft();
- if (max_y < cvars.size()) max_y = cvars.size();
- j = 0;
- piForeachC (Variable & tv_, cvars) {
- if (j > height - 3) continue;
- j++;
- moveRight(cx);
- if (tv_.type == 15) {
- newLine();
- continue;
- }
- moveRight(tv_.offset);
- const void * ptr = 0;
- if (tv_.remote) {
- if (tv_.type == 0) {
- rstr.clear();
- rba = tv_.rdata;
- rba >> rstr;
- rstr.trim();
- ptr = &rstr;
- } else
- ptr = tv_.rdata.data();
- } else
- ptr = tv_.ptr;
- switch (tv_.type) {
- case 0: clen = printValue(ptr != 0 ? *(const PIString*)ptr : PIString(), tv_.format); break;
- case 1: clen = printValue(ptr != 0 ? *(const bool*)ptr : false, tv_.format); break;
- case 2: clen = printValue(ptr != 0 ? *(const int*)ptr : 0, tv_.format); break;
- case 3: clen = printValue(ptr != 0 ? *(const long*)ptr : 0l, tv_.format); break;
- case 4: clen = printValue(ptr != 0 ? *(const char*)ptr : char(0), tv_.format); break;
- case 5: clen = printValue(ptr != 0 ? *(const float*)ptr : 0.f, tv_.format); break;
- case 6: clen = printValue(ptr != 0 ? *(const double*)ptr : 0., tv_.format); break;
- case 7: clen = printValue(ptr != 0 ? *(const short*)ptr : short(0), tv_.format); break;
- case 8: clen = printValue(ptr != 0 ? *(const uint*)ptr : 0u, tv_.format); break;
- case 9: clen = printValue(ptr != 0 ? *(const ulong*)ptr : 0ul, tv_.format); break;
- case 10: clen = printValue(ptr != 0 ? *(const ushort*)ptr : ushort(0), tv_.format); break;
- case 11: clen = printValue(ptr != 0 ? *(const uchar*)ptr : uchar(0), tv_.format); break;
- case 12: clen = printValue(ptr != 0 ? *(const llong*)ptr : 0l, tv_.format); break;
- case 13: clen = printValue(ptr != 0 ? *(const ullong*)ptr: 0ull, tv_.format); break;
- case 20: clen = printValue(ptr != 0 ? *(const PISystemTime*)ptr: PISystemTime(), tv_.format); break;
- case 14: clen = printValue(bitsValue(ptr, tv_.bitFrom, tv_.bitCount), tv_.format); break;
- }
- if (clen + tv_.offset < (uint)col_wid) {
- PIString ts = PIString(
- #if defined(QNX) || defined(FREE_BSD)
- col_wid - clen - tv_.offset - 1, ' ');
-#else
- col_wid - clen - tv_.offset, ' ');
-#endif
- printf("%s", ts.data());
- }
- newLine();
- }
- }
-#ifdef WINDOWS
- moveTo(0, max_y + 1);
-#else
- moveTo(0, max_y + 2);
-#endif
- fflush(0);
- PICout::__mutex__().unlock();
-}
-
-
-void PIConsole::fillLabels() {
- if (!isRunning()) return;
- uint cx, cy, mx = 0, dx;
-#ifdef WINDOWS
- GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
- width = PRIVATE->sbi.srWindow.Right - PRIVATE->sbi.srWindow.Left;
- height = PRIVATE->sbi.srWindow.Bottom - PRIVATE->sbi.srWindow.Top;
-#else
-# ifdef FREERTOS
- width = 80;
- height = 24;
-# else
- winsize ws;
- ioctl(0, TIOCGWINSZ, &ws);
- width = ws.ws_col;
- height = ws.ws_row;
-# endif
-#endif
- max_y = 0;
- col_cnt = columns().size();
- col_wid = (col_cnt > 0) ? width / col_cnt : width;
- for (uint i = 0; i < col_cnt; ++i) {
- Column & ccol(tabs[cur_tab].columns[i]);
- PIVector & cvars(ccol.variables);
- if (ccol.alignment != Nothing) {
- mx = 0;
- piForeachC (Variable & j, cvars)
- if (!j.isEmpty())
- if (mx < j.name.size())
- mx = j.name.size();
- mx += 2;
- }
- cx = col_wid * i;
- cy = 1;
- toUpperLeft();
- for (uint j = 0; j < cvars.size(); ++j) {
- if (int(j) > height - 3) continue;
- if (max_y < j) max_y = j;
- moveRight(cx);
- Variable & tv_(cvars[j]);
- cvars[j].nx = cx;
- cvars[j].ny = cy;
- if (tv_.name.isEmpty()) {
- cvars[j].offset = 0;
- clearLine();
- newLine();
- cy++;
- continue;
- }
- clearLine();
- //piCout << tv_.name << tv_.type << tv_.ptr;
- if (tv_.type == 15) {
- cvars[j].offset = cvars[j].name.length();
- cvars[j].nx += cvars[j].offset;
- printLine(tv_.name, cx, tv_.format);
- newLine();
- cy++;
- continue;
- }
- if (!tv_.isEmpty()) {
- switch (ccol.alignment) {
- case Nothing:
- cvars[j].offset = (tv_.name + ": ").length();
- cvars[j].nx += cvars[j].offset;
- printValue(tv_.name + ": ", tv_.format);
- break;
- case Left:
- cvars[j].offset = mx;
- cvars[j].nx += cvars[j].offset;
- printValue(tv_.name + ": ", tv_.format);
- break;
- case Right:
- cvars[j].offset = mx;
- cvars[j].nx += cvars[j].offset;
- dx = mx - (tv_.name + ": ").length();
- moveRight(dx);
- printValue(tv_.name + ": ", tv_.format);
- moveLeft(dx);
- break;
- }
- }
- newLine();
- cy++;
- }
- }
-#ifdef WINDOWS
- moveTo(0, max_y + 1);
-#else
- moveTo(0, max_y + 2);
-#endif
- if (!tabs[cur_tab].status.isEmpty()) {
- printValue(tabs[cur_tab].status);
- newLine();
- }
- status();
-}
-
-
-void PIConsole::status() {
- Tab * ctab;
- for (uint i = 0; i < tabsCount(); ++i) {
- ctab = &tabs[i];
- if (ctab->key == 0) continue;
- printValue(ctab->key, PIConsole::White | PIConsole::Bold);
- if (i == cur_tab)
- printValue(ctab->name + " ", PIConsole::BackYellow | PIConsole::Black);
- else
- printValue(ctab->name + " ", PIConsole::Cyan | PIConsole::Inverse);
- printValue(" ");
- }
- newLine();
-}
-
-
-int PIConsole::bitsValue(const void * src, int offset, int count) const {
- int ret = 0, stbyte = offset / 8, cbit = offset - stbyte * 8;
- char cbyte = reinterpret_cast(src)[stbyte];
- for (int i = 0; i < count; i++) {
- ret |= ((cbyte >> cbit & 1) << i);
- cbit++;
- if (cbit == 8) {
- cbit = 0;
- stbyte++;
- cbyte = reinterpret_cast(src)[stbyte];
- }
- }
- return ret;
-}
-
-
-const char * PIConsole::toBin(const void * d, int s) {
- binstr.clear();
- uchar cc, b;
- for (int i = 0; i < s; ++i) {
- cc = ((const uchar *)d)[i];
- b = 1;
- for (int j = 0; j < 8; ++j) {
- binstr << (cc & b ? "1" : "0");
- b <<= 1;
- }
- if (i < s - 1) binstr << " ";
- }
- binstr.reverse();
- return binstr.data();
-}
-
-
-#define ADD_VAR_BODY vid++; tv.id = vid; tv.name = name; tv.bitFrom = tv.bitCount = 0; tv.format = format; tv.remote = false; checkColumn(col);
-
-void PIConsole::addString(const PIString & name, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 15; tv.size = 0; tv.ptr = 0; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const PIString * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 0; tv.size = 0; tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const bool * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 1; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const int * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 2; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const long * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 3; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const char * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 4; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const float * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 5; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const double * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 6; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const short * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 7; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const uint * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 8; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const ulong * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 9; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const ushort * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 10; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const uchar * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 11; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const llong * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 12; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const ullong * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 13; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-void PIConsole::addVariable(const PIString & name, const PISystemTime * ptr, int col, FormatFlags format) {
- ADD_VAR_BODY tv.type = 20; tv.size = sizeof(*ptr); tv.ptr = ptr; column(col).push_back(tv);}
-/** \brief Add to current tab to column "column" variable with label "name", pointer "ptr" and format "format"
- * \details This function add to column "column" next lines:
- * * " diagnostics"
- * * "Received count": \a PIDiagnostics::receiveCount
- * * "Invalid count": \a PIDiagnostics::wrongCount
- * * "Sended count": \a PIDiagnostics::sendCount
- * * "Immediate Frequency, Hz": \a PIDiagnostics::immediateFrequency
- * * "Integral Frequency, Hz": \a PIDiagnostics::integralFrequency
- * * "Receive speed": \a PIDiagnostics::receiveSpeed
- * * "Send speed": \a PIDiagnostics::sendSpeed
- * * "Quality": \a PIDiagnostics::quality
- * */
-void PIConsole::addVariable(const PIString & name, const PIDiagnostics * ptr, int col, FormatFlags format) {
- addString(name + " diagnostics", col, format | PIConsole::Bold);
-// addVariable("Received count", ptr->receiveCount_ptr(), col, format);
-// addVariable("Invalid count", ptr->wrongCount_ptr(), col, format);
-// addVariable("Sended count", ptr->sendCount_ptr(), col, format);
-// addVariable("Immediate Frequency, Hz", ptr->immediateFrequency_ptr(), col, format);
-// addVariable("Integral Frequency, Hz", ptr->integralFrequency_ptr(), col, format);
-// addVariable("Receive speed", ptr->receiveSpeed_ptr(), col, format);
-// addVariable("Send speed", ptr->sendSpeed_ptr(), col, format);
-// addVariable("Quality", ptr->quality_ptr(), col, format);
-}
-void PIConsole::addVariable(const PIString & name, const PISystemMonitor * ptr, int col, FormatFlags format) {
- addString("monitor " + name, col, format | PIConsole::Bold);
- //addVariable("PID", &(ptr->statistic().ID), col, format);
- //addVariable("state", &(ptr->statistic().state), col, format);
- //addVariable("threads", &(ptr->statistic().threads), col, format);
- //addVariable("priority", &(ptr->statistic().priority), col, format);
- //addVariable("memory physical", &(ptr->statistic().physical_memsize_readable), col, format);
- //addVariable("memory shared", &(ptr->statistic().share_memsize_readable), col, format);
- //addVariable("cpu load kernel", &(ptr->statistic().cpu_load_system), col, format);
- //addVariable("cpu load user", &(ptr->statistic().cpu_load_user), col, format);
-}
-void PIConsole::addBitVariable(const PIString & name, const void * ptr, int fromBit, int bitCount, int col, FormatFlags format) {
- vid++; tv.id = vid; tv.size = sizeof(ullong); tv.name = name; tv.bitFrom = fromBit; tv.bitCount = bitCount; tv.type = 14; tv.ptr = ptr; tv.format = format;
- checkColumn(col); column(col).push_back(tv);}
-void PIConsole::addEmptyLine(int col, uint count) {
- tv.id = 0; tv.size = 0; tv.name = ""; tv.type = 0; tv.ptr = 0; tv.format = Normal;
- for (uint i = 0; i < count; ++i) {
- checkColumn(col);
- column(col).push_back(tv);
- }
-}
-
-
-PIString PIConsole::getString(int x, int y) {
- bool run = isRunning();
- if (run) PIThread::stop(true);
- listener->setActive(false);
- msleep(50);
-#ifdef WINDOWS
- moveTo(x - 1, y - 1);
-#else
- moveTo(x, y);
-#endif
- showCursor();
- PIByteArray ba(4096);
-#ifdef CC_VC
- int ret = scanf_s(" %s", ba.data());
-#else
- int ret = scanf(" %s", ba.data());
-#endif
- listener->setActive(true);
- if (run) start();
- if (ret >= 1) return PIString(ba);
- else return PIString();
-}
-
-
-PIString PIConsole::getString(const PIString & name) {
- piForeachC (Column & i, tabs[cur_tab].columns)
- piForeachC (Variable & j, i.variables)
- if (j.name == name)
- return getString(j.nx + 1, j.ny);
- return PIString();
-}
-
-
-#define PRINT_VAR_BODY couts(fstr(format)); int ret = couts(value); couts(fstr(PIConsole::Dec)); return ret;
-
-inline void PIConsole::printLine(const PIString & value, int dx, FormatFlags format) {
- int i = width - value.length() - dx;
-#if defined(QNX) || defined(FREE_BSD)
- --i;
-#endif
- PIString ts = fstr(format);
- couts(ts);
- if (i >= 0) ts = value + PIString(i, ' ');
- else ts = value.left(value.size() + i);
- couts(ts);
- couts(fstr(Dec));
-}
-inline int PIConsole::printValue(const PIString & value, FormatFlags format) {
- couts(fstr(format));
- int ret = couts(value);
- fstr(PIConsole::Dec);
- return ret;
-}
-inline int PIConsole::printValue(const char * value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const bool value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const int value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const long value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const llong value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const float value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const double value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const char value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const short value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const uchar value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const ushort value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const uint value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const ulong value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const ullong value, FormatFlags format) {PRINT_VAR_BODY}
-inline int PIConsole::printValue(const PISystemTime & value, FormatFlags format) {PRINT_VAR_BODY}
-
-
-
-void PIConsole::startServer(const PIString & name) {
- stopPeer();
- server_mode = true;
- peer = new PIPeer("_rcs_:" + name);
- CONNECT2(void, const PIString & , const PIByteArray &, peer, dataReceivedEvent, this, peerReceived);
- CONNECT1(void, const PIString & , peer, peerDisconnectedEvent, this, peerDisconnectedEvent);
- peer_timer->start(50.);
- serverSendInfo();
-}
-
-
-void PIConsole::stopPeer() {
- remote_clients.clear();
- peer_timer->stop();
- if (peer != 0) delete peer;
- peer = 0;
- state = Disconnected;
-}
-
-
-PIStringList PIConsole::clients() const {
- PIStringList sl;
- if (peer == 0) return sl;
- piForeachC (PIPeer::PeerInfo & i, peer->allPeers()) {
- if (i.name.left(6) != "_rcc_:") continue;
- sl << i.name.right(i.name.length() - 6);
- }
- return sl;
-}
-
-
-void PIConsole::listenServers() {
- stopPeer();
- server_mode = false;
- server_name.clear();
- randomize();
- peer = new PIPeer("_rcc_:" + PIDateTime::current().toString("hhmmssddMMyy_") + PIString::fromNumber(randomi()));
- CONNECT2(void, const PIString & , const PIByteArray &, peer, dataReceivedEvent, this, peerReceived);
- peer_timer->start(100.);
-}
-
-
-PIStringList PIConsole::availableServers() const {
- PIStringList sl;
- if (peer == 0) return sl;
- piForeachC (PIPeer::PeerInfo & i, peer->allPeers()) {
- if (i.name.left(6) != "_rcs_:") continue;
- sl << i.name.right(i.name.length() - 6);
- }
- return sl;
-}
-
-
-void PIConsole::connectToServer(const PIString & name) {
- if (peer == 0) listenServers();
- server_name = name;
-}
-
-
-void PIConsole::disconnect() {
- stopPeer();
-}
-
-
-void PIConsole::serverSendInfo() {
- if (peer == 0) return;
- PIByteArray ba;
- ba << int(0xAA);
- peer->sendToAll(ba);
-}
-
-
-void PIConsole::serverSendData() {
- if (peer == 0) return;
- PIByteArray ba;
- PIVector content;
- piForeach (Tab & t, tabs)
- piForeach (Column & c, t.columns)
- piForeach (Variable & v, c.variables)
- if (!v.isEmpty() && v.id > 0) {
- VariableContent vc;
- vc.id = v.id;
- v.writeData(vc.rdata);
- content << vc;
- }
- piForeach (RemoteClient & rc, remote_clients) {
- ba.clear();
- switch (rc.state) {
- case FetchingData:
- ba << int(0xCC) << tabs;
- //piCout << "server send const data" << rc.name << ba.size_s();
- break;
- case Committing:
- ba << int(0xDD);
- break;
- case Connected:
- ba << int(0xEE) << content;
- //piCout << "send data" << ba.size();
- break;
- default: break;
- }
- if (!ba.isEmpty())
- peer->send(rc.name, ba);
- }
-}
-
-
-PIConsole::RemoteClient & PIConsole::remoteClient(const PIString & fname) {
- piForeach (RemoteClient & i, remote_clients)
- if (i.name == fname)
- return i;
- remote_clients << RemoteClient(fname);
- return remote_clients.back();
-}
-
-
-void PIConsole::peerReceived(const PIString & from, const PIByteArray & data) {
- int type;
- PIByteArray ba(data);
- ba >> type;
- //piCout << "rec packet from" << from << "type" << PICoutManipulators::Hex << type;
- if (server_mode) {
- if (from.left(5) != "_rcc_") return;
- //PIString rcn = from.right(from.length() - 6);
- RemoteClient & rc(remoteClient(from));
- switch (type) {
- case 0xBB: // fetch const data request
- //piCout << "fetch data request from" << from << rc.state;
- if (rc.state != Connected)
- rc.state = FetchingData;
- break;
- case 0xCC: // const data commit
- //piCout << "commit from" << from;
- if (rc.state != Connected)
- rc.state = Connected;
- break;
- default: break;
- }
- } else {
- PIVector content;
- PIMap vids;
- if (from.left(5) != "_rcs_") return;
- //PIString rcn = from.right(from.length() - 6);
- switch (type) {
- case 0xAA: // new server
- //piCout << "new server" << rcn;
- break;
- case 0xCC: // const data
- //piCout << "received const data";
- state = Committing;
- ba >> tabs;
- cur_tab = tabs.isEmpty() ? -1 : 0;
- piForeach (Tab & t, tabs)
- piForeach (Column & c, t.columns)
- piForeach (Variable & v, c.variables)
- v.remote = true;
- break;
- case 0xDD: // const data commit
- //piCout << "received commit";
- state = Connected;
- break;
- case 0xEE: // dynamic data
- //piCout << "received data" << ba.size_s();
- piForeach (Tab & t, tabs)
- piForeach (Column & c, t.columns)
- piForeach (Variable & v, c.variables)
- if (!v.isEmpty() && v.id > 0)
- vids[v.id] = &v;
- ba >> content;
- piForeach (VariableContent & vc, content) {
- if (vc.id <= 0) continue;
- Variable * v = vids.at(vc.id);
- if (v == 0) continue;
- //piCout << "read" << v->name << vc.rdata.size_s();
- v->rdata = vc.rdata;
- }
- break;
- default: break;
- }
- }
-}
-
-
-void PIConsole::peerTimer(void * data, int delim) {
- if (peer == 0) return;
- //piCout << "timer" << delim;
- if (server_mode) {
- if (delim == 20)
- serverSendInfo();
- else
- serverSendData();
- } else {
- if (delim != 1 || server_name.isEmpty()) return;
- const PIPeer::PeerInfo * p = peer->getPeerByName("_rcs_:" + server_name);
- if (p == 0) return;
- PIByteArray ba;
- switch (state) {
- case Disconnected:
- peer_tm.reset();
- ba << int(0xBB);
- //piCout << "send to" << server_name << "fetch request disc";
- peer->send(p, ba);
- state = FetchingData;
- break;
- case FetchingData:
- if (peer_tm.elapsed_s() < 3.)
- return;
- peer_tm.reset();
- ba << int(0xBB);
- //piCout << "send to" << server_name << "fetch request fd";
- peer->send(p, ba);
- break;
- case Committing:
- peer_tm.reset();
- ba << int(0xCC);
- //piCout << "send to" << server_name << "committing";
- state = Connected;
- peer->send(p, ba);
- break;
- default: break;
- };
- }
-}
-
-
-void PIConsole::peerDisconnectedEvent(const PIString & name) {
- for (int i = 0; i < remote_clients.size_s(); ++i)
- if (remote_clients[i].name == name) {
- remote_clients.remove(i);
- --i;
- }
-}
diff --git a/lib/console/piscreen.cpp b/lib/console/piscreen.cpp
index 60945d17..786c1b02 100644
--- a/lib/console/piscreen.cpp
+++ b/lib/console/piscreen.cpp
@@ -480,7 +480,7 @@ void PIScreen::mouse_event(PIKbdListener::MouseEvent me) {
PIVector tl = prepareMouse(&me);
if (tl.isEmpty()) return;
piForeachR (PIScreenTile * t, tl)
- if (t->mouseEvent(me)) piBreak;
+ if (t->mouseEvent(me)) break;
}
@@ -488,7 +488,7 @@ void PIScreen::wheel_event(PIKbdListener::WheelEvent we) {
PIVector tl = prepareMouse(&we);
if (tl.isEmpty()) return;
piForeachR (PIScreenTile * t, tl)
- if (t->wheelEvent(we)) piBreak;
+ if (t->wheelEvent(we)) break;
}
diff --git a/lib/console/piterminal.cpp b/lib/console/piterminal.cpp
index 2c0da013..ce9623aa 100644
--- a/lib/console/piterminal.cpp
+++ b/lib/console/piterminal.cpp
@@ -805,7 +805,7 @@ bool PITerminal::initialize() {
if (e.startsWith("TERM=")) {
PRIVATE->term_type = termType(e.mid(5).trim().toLowerCase());
//piCout << PRIVATE->term_type;
- piBreak;
+ break;
}
pid_t fr = forkpty(&(PRIVATE->fd), pty, 0, &ws);
//piCoutObj << fr << PRIVATE->fd << pty;
diff --git a/lib/fftw/pifft_p.h b/lib/fftw/pifft_p.h
index 92c7f378..04c61169 100644
--- a/lib/fftw/pifft_p.h
+++ b/lib/fftw/pifft_p.h
@@ -24,7 +24,6 @@
#define PIFFT_P_H
#include "pivector.h"
-#include "pimutex.h"
#include "picout.h"
#if defined(PIP_FFTW) || defined(PIP_FFTWf) || defined(PIP_FFTWl) || defined(PIP_FFTWq)
# include "fftw3.h"
@@ -37,7 +36,7 @@
template
-class PIP_EXPORT PIFFTW_Private
+class PIFFTW_Private
{
public:
explicit PIFFTW_Private() {
diff --git a/lib/lua/3rd/LuaBridge/List.h b/lib/lua/3rd/LuaBridge/List.h
new file mode 100644
index 00000000..66e0d8fb
--- /dev/null
+++ b/lib/lua/3rd/LuaBridge/List.h
@@ -0,0 +1,55 @@
+// https://github.com/vinniefalco/LuaBridge
+//
+// Copyright 2018, Dmitry Tarakanov
+// SPDX-License-Identifier: MIT
+
+#pragma once
+
+#include
+
+#include
+
+namespace luabridge {
+
+template
+struct Stack >
+{
+ static void push (lua_State* L, std::list const& list)
+ {
+ lua_createtable (L, static_cast (list.size ()), 0);
+ typename std::list ::const_iterator item = list.begin ();
+ for (std::size_t i = 1; i <= list.size (); ++i)
+ {
+ lua_pushinteger (L, static_cast (i));
+ Stack ::push (L, *item);
+ lua_settable (L, -3);
+ ++item;
+ }
+ }
+
+ static std::list get (lua_State* L, int index)
+ {
+ if (!lua_istable (L, index))
+ {
+ luaL_error (L, "#%d argument must be a table", index);
+ }
+
+ std::list list;
+
+ int const absindex = lua_absindex (L, index);
+ lua_pushnil (L);
+ while (lua_next (L, absindex) != 0)
+ {
+ list.push_back (Stack ::get (L, -1));
+ lua_pop (L, 1);
+ }
+ return list;
+ }
+
+ static bool isInstance (lua_State* L, int index)
+ {
+ return lua_istable (L, index);
+ }
+};
+
+} // namespace luabridge
diff --git a/lib/lua/3rd/LuaBridge/LuaBridge.h b/lib/lua/3rd/LuaBridge/LuaBridge.h
new file mode 100644
index 00000000..866acc39
--- /dev/null
+++ b/lib/lua/3rd/LuaBridge/LuaBridge.h
@@ -0,0 +1,59 @@
+//------------------------------------------------------------------------------
+/*
+ https://github.com/vinniefalco/LuaBridge
+
+ Copyright 2019, Dmitry Tarakanov
+ Copyright 2012, Vinnie Falco
+ Copyright 2007, Nathan Reed
+
+ License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+//==============================================================================
+
+#pragma once
+
+// All #include dependencies are listed here
+// instead of in the individual header files.
+//
+
+#define LUABRIDGE_MAJOR_VERSION 2
+#define LUABRIDGE_MINOR_VERSION 3
+#define LUABRIDGE_VERSION 203
+
+#ifndef LUA_VERSION_NUM
+#error "Lua headers must be included prior to LuaBridge ones"
+#endif
+
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
diff --git a/lib/lua/3rd/LuaBridge/Map.h b/lib/lua/3rd/LuaBridge/Map.h
new file mode 100644
index 00000000..a36d269a
--- /dev/null
+++ b/lib/lua/3rd/LuaBridge/Map.h
@@ -0,0 +1,56 @@
+// https://github.com/vinniefalco/LuaBridge
+//
+// Copyright 2018, Dmitry Tarakanov
+// SPDX-License-Identifier: MIT
+
+#pragma once
+
+#include
+#include
+
+#include