Skip to content
Snippets Groups Projects
Commit 2a70f298 authored by Damien Lacoste's avatar Damien Lacoste
Browse files

Move HdbppClient and HdbppTimescaledb header to the src directory, as they are private.

change the build process to use libhdbpp as header only.
parent ca3c77d1
No related branches found
No related tags found
No related merge requests found
...@@ -38,9 +38,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) ...@@ -38,9 +38,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
# Build options # Build options
set(FETCH_LIBHDBPP_TAG "master" CACHE STRING "Libhdbpp branch/tag to clone 'master'")
option(FETCH_LIBHDBPP "Download and build using a local copy of libhdb++" ON)
option(FETCH_LIBHDBPP_TAG "When FETCH_LIBHDBPP is enabled, this is the tag fetch ('master')")
option(BUILD_UNIT_TESTS "Build unit tests" OFF) option(BUILD_UNIT_TESTS "Build unit tests" OFF)
option(BUILD_BENCHMARK_TESTS "Build benchmarking tests (Forces RELEASE build)" OFF) option(BUILD_BENCHMARK_TESTS "Build benchmarking tests (Forces RELEASE build)" OFF)
option(ENABLE_CLANG "Enable clang code and layout analysis" OFF) option(ENABLE_CLANG "Enable clang code and layout analysis" OFF)
...@@ -59,9 +56,6 @@ include(GNUInstallDirs) ...@@ -59,9 +56,6 @@ include(GNUInstallDirs)
message(STATUS "Searching for libraries...") message(STATUS "Searching for libraries...")
# Variable to contain a list of all the libs we depend on
set(TDB_LIBRARIES)
# allow pkg-config to search the CMAKE_PREFIX_PATH # allow pkg-config to search the CMAKE_PREFIX_PATH
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON) set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
list(APPEND CMAKE_PREFIX_PATH "/usr") list(APPEND CMAKE_PREFIX_PATH "/usr")
...@@ -77,11 +71,33 @@ find_package(Tango) ...@@ -77,11 +71,33 @@ find_package(Tango)
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
# Attempt to find the various libraries the project is dependent on # Find the libhdbpp headers
if(TDB_LIBRARIES) find_package(libhdbpp)
find_libraries(LIBRARIES ${TDB_LIBRARIES} SEARCH_PATHS ${LIBRARY_PATHS})
set(TDB_FOUND_LIBRARIES ${FOUND_LIBRARIES}) # If not installed then get them
endif(TDB_LIBRARIES) if(NOT libhdbpp_FOUND)
include(FetchContent)
FetchContent_Declare(
libhdbpp
GIT_REPOSITORY https://github.com/tango-controls-hdbpp/libhdbpp.git
GIT_TAG project-build
)
FetchContent_GetProperties(libhdbpp)
if(NOT libhdbpp_POPULATED)
FetchContent_Populate(libhdbpp)
add_subdirectory(${libhdbpp_SOURCE_DIR} ${libhdbpp_BINARY_DIR})
endif()
add_library(libhdbpp::libhdbpp_headers ALIAS libhdbpp_headers)
get_target_property(TEST libhdbpp::libhdbpp_headers IMPORTED)
get_target_property(TEST1 libhdbpp::libhdbpp_headers INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS ${TEST})
message(STATUS ${TEST1})
endif(NOT libhdbpp_FOUND)
# Thirdparty Integration ----------------------------------- # Thirdparty Integration -----------------------------------
...@@ -139,8 +155,8 @@ add_subdirectory(src) ...@@ -139,8 +155,8 @@ add_subdirectory(src)
add_library(libhdbpp_timescale_shared_library SHARED ${SRC_FILES}) add_library(libhdbpp_timescale_shared_library SHARED ${SRC_FILES})
target_link_libraries(libhdbpp_timescale_shared_library target_link_libraries(libhdbpp_timescale_shared_library
PUBLIC ${TDB_FOUND_LIBRARIES} pqxx_static spdlog::spdlog_header_only Threads::Threads PUBLIC libhdbpp::libhdbpp_headers
PRIVATE TangoInterfaceLibrary) PRIVATE Threads::Threads pqxx_static spdlog::spdlog_header_only TangoInterfaceLibrary)
target_include_directories(libhdbpp_timescale_shared_library target_include_directories(libhdbpp_timescale_shared_library
PUBLIC PUBLIC
...@@ -173,7 +189,8 @@ target_compile_options(libhdbpp_timescale_shared_library ...@@ -173,7 +189,8 @@ target_compile_options(libhdbpp_timescale_shared_library
add_library(libhdbpp_timescale_static_library STATIC EXCLUDE_FROM_ALL ${SRC_FILES}) add_library(libhdbpp_timescale_static_library STATIC EXCLUDE_FROM_ALL ${SRC_FILES})
target_link_libraries(libhdbpp_timescale_static_library target_link_libraries(libhdbpp_timescale_static_library
PUBLIC ${TDB_FOUND_LIBRARIES} pqxx_static spdlog Threads::Threads INTERFACE libhdbpp::libhdbpp_headers
PUBLIC pqxx_static spdlog Threads::Threads
PRIVATE TangoInterfaceLibrary) PRIVATE TangoInterfaceLibrary)
target_include_directories(libhdbpp_timescale_static_library target_include_directories(libhdbpp_timescale_static_library
...@@ -196,17 +213,57 @@ target_compile_options(libhdbpp_timescale_static_library ...@@ -196,17 +213,57 @@ target_compile_options(libhdbpp_timescale_static_library
PRIVATE "$<$<CONFIG:DEBUG>:-g>") PRIVATE "$<$<CONFIG:DEBUG>:-g>")
# Install Config ----------------------------------- # Install Config -----------------------------------
include(CMakePackageConfigHelpers)
install( install(
TARGETS libhdbpp_timescale_shared_library TARGETS libhdbpp_timescale_shared_library
EXPORT libhdbpp-timescaleTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
set(ConfigPackageLocation lib/cmake/libhdbpp-timescale)
set(Namespace libhdbpp::)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/libhdbpp-timescale/libhdbpp-timescaleConfigVersion.cmake"
VERSION ${VERSION_STRING}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT libhdbpp-timescaleTargets
FILE
"${CMAKE_CURRENT_BINARY_DIR}/libhdbpp-timescale/libhdbpp-timescaleTargets.cmake"
NAMESPACE ${Namespace}
)
# generate the config file that is includes the exports
configure_package_config_file(cmake/libhdbpp-timescaleConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/libhdbpp-timescale/libhdbpp-timescaleConfig.cmake"
INSTALL_DESTINATION
${ConfigPackageLocation}
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(EXPORT libhdbpp-timescaleTargets
FILE
libhdbpp-timescaleTargets.cmake
NAMESPACE
${Namespace}
DESTINATION
${ConfigPackageLocation}
)
install( install(
DIRECTORY ${PROJECT_SOURCE_DIR}/include/ FILES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} "${CMAKE_CURRENT_BINARY_DIR}/libhdbpp-timescale/libhdbpp-timescaleConfig.cmake"
FILES_MATCHING "${CMAKE_CURRENT_BINARY_DIR}/libhdbpp-timescale/libhdbpp-timescaleConfigVersion.cmake"
PATTERN HdbppTimescaleDb.hpp) DESTINATION
${ConfigPackageLocation}
)
# Tests ----------------------------------- # Tests -----------------------------------
if(BUILD_UNIT_TESTS) if(BUILD_UNIT_TESTS)
......
...@@ -26,7 +26,7 @@ void bmAllocateQueryBuilder(benchmark::State& state) ...@@ -26,7 +26,7 @@ void bmAllocateQueryBuilder(benchmark::State& state)
{ {
// Test - Testing the time it takes to allocate a QueryBuilder, mainly for future test // Test - Testing the time it takes to allocate a QueryBuilder, mainly for future test
// reference // reference
hdbpp_internal::LogConfigurator::initLogging(); hdbpp_internal::LogConfigurator::initLogging("test");
for (auto _ : state) for (auto _ : state)
hdbpp_internal::pqxx_conn::QueryBuilder query_builder; hdbpp_internal::pqxx_conn::QueryBuilder query_builder;
...@@ -99,7 +99,7 @@ void bmStoreDataEventQueryNoCache(benchmark::State& state) ...@@ -99,7 +99,7 @@ void bmStoreDataEventQueryNoCache(benchmark::State& state)
{ {
// TEST - Testing how long it takes to build an Insert Data Event query with // TEST - Testing how long it takes to build an Insert Data Event query with
// an empty cache (this forces the full string to be built) // an empty cache (this forces the full string to be built)
hdbpp_internal::LogConfigurator::initLogging(); hdbpp_internal::LogConfigurator::initLogging("test");
hdbpp_internal::AttributeTraits traits hdbpp_internal::AttributeTraits traits
{static_cast<Tango::AttrWriteType>(state.range(0)), Tango::SCALAR, Tango::DEV_DOUBLE}; {static_cast<Tango::AttrWriteType>(state.range(0)), Tango::SCALAR, Tango::DEV_DOUBLE};
...@@ -119,7 +119,7 @@ void bmStoreDataEventQueryCache(benchmark::State& state) ...@@ -119,7 +119,7 @@ void bmStoreDataEventQueryCache(benchmark::State& state)
{ {
// TEST - Testing the full lookup for an Insert Data QueryEvent query when the cache // TEST - Testing the full lookup for an Insert Data QueryEvent query when the cache
// map is fully populated // map is fully populated
hdbpp_internal::LogConfigurator::initLogging(); hdbpp_internal::LogConfigurator::initLogging("test");
hdbpp_internal::AttributeTraits traits hdbpp_internal::AttributeTraits traits
{static_cast<Tango::AttrWriteType>(state.range(0)), Tango::SCALAR, Tango::DEV_DOUBLE}; {static_cast<Tango::AttrWriteType>(state.range(0)), Tango::SCALAR, Tango::DEV_DOUBLE};
......
@PACKAGE_INIT@
find_package(libhdbpp)
include("${CMAKE_CURRENT_LIST_DIR}/libhdbpp-timescaleTargets.cmake")
set(BACKEND_TARGET libhdbpp::libhdbpp_timescale_shared_library)
...@@ -9,17 +9,9 @@ set(LOCAL_SRC_FILES ...@@ -9,17 +9,9 @@ set(LOCAL_SRC_FILES
${CMAKE_CURRENT_SOURCE_DIR}/LibUtils.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LibUtils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DbConnection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/DbConnection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/QueryBuilder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/QueryBuilder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/PqxxExtension.cpp) ${CMAKE_CURRENT_SOURCE_DIR}/PqxxExtension.cpp
${CMAKE_CURRENT_SOURCE_DIR}/HdbppTimescaleDb.cpp
if(NOT BYPASS_LIBHDBPP)
set(LOCAL_SRC_FILES ${LOCAL_SRC_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/HdbppTimescaleDb.cpp)
endif()
if(BYPASS_LIBHDBPP)
set(LOCAL_SRC_FILES ${LOCAL_SRC_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/HdbClient.cpp) ${CMAKE_CURRENT_SOURCE_DIR}/HdbClient.cpp)
endif()
set(SRC_FILES set(SRC_FILES
${SRC_FILES} ${SRC_FILES}
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "HdbppTimescaleDbApi.hpp" #include "HdbppTimescaleDbApi.hpp"
#include <hdb++/HdbClient.h> #include "HdbClient.h"
using namespace std; using namespace std;
......
/* Copyright (C) : 2014-2019
European Synchrotron Radiation Facility
BP 220, Grenoble 38043, FRANCE
This file is part of libhdb++timescale.
libhdb++timescale is free software: you can redistribute it and/or modify
it under the terms of the Lesser GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libhdb++timescale 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 Lesser
GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with libhdb++timescale. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _HDBPP_TIMESCALE_CLIENT_HPP
#define _HDBPP_TIMESCALE_CLIENT_HPP
#include "hdb++/AbstractDB.h"
#include <memory>
#include <string>
#include <vector>
namespace hdbpp
{
class HdbClient : public AbstractDB
{
public:
HdbClient(const string &id, const std::vector<std::string> &configuration);
virtual ~HdbClient() {}
// Inserts an attribute archive event for the EventData into the database. If the attribute
// does not exist in the database, then an exception will be raised. If the attr_value
// field of the data parameter if empty, then the attribute is in an error state
// and the error message will be archived.
void insert_event(Tango::EventData *event, const HdbEventDataType &data_type) override;
// Insert multiple attribute archive events. Any attributes that do not exist will
// cause an exception. On failure the fall back is to insert events individually
void insert_events(std::vector<std::tuple<Tango::EventData *, HdbEventDataType>> events) override;
// Inserts the attribute configuration data (Tango Attribute Configuration event data)
// into the database. The attribute must be configured to be stored in HDB++,
// otherwise an exception will be thrown.
void insert_param_event(Tango::AttrConfEventData *data, const HdbEventDataType &data_type) override;
// Add an attribute to the database. Trying to add an attribute that already exists will
// cause an exception
void add_attribute(const std::string &name, int type, int format, int write_type) override;
// Update the attribute ttl. The attribute must have been configured to be stored in
// HDB++, otherwise an exception is raised
void update_ttl(const std::string &name, unsigned int ttl) override;
// Inserts a history event for the attribute name passed to the function. The attribute
// must have been configured to be stored in HDB++, otherwise an exception is raised.
void insert_history_event(const std::string &name, unsigned char event) override;
// Check what hdbpp features this library supports.
bool supported(HdbppFeatures feature) override;
private:
std::unique_ptr<AbstractDB> _db;
};
} // namespace hdbpp
#endif // _HDBPP_TIMESCALE_CLIENT_HPP
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
You should have received a copy of the Lesser GNU General Public License You should have received a copy of the Lesser GNU General Public License
along with libhdb++timescale. If not, see <http://www.gnu.org/licenses/>. */ along with libhdb++timescale. If not, see <http://www.gnu.org/licenses/>. */
#include "hdb++/HdbppTimescaleDb.hpp" #include "HdbppTimescaleDb.hpp"
#include "HdbppTimescaleDbApi.hpp" #include "HdbppTimescaleDbApi.hpp"
......
File moved
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
hdbpp_internal::LogConfigurator::initLogging(); hdbpp_internal::LogConfigurator::initLogging("tests");
//hdbpp_internal::LogConfigurator::initConsoleLogging(); //hdbpp_internal::LogConfigurator::initConsoleLogging("tests");
hdbpp_internal::LogConfigurator::setLoggingLevel(spdlog::level::err); hdbpp_internal::LogConfigurator::setLoggingLevel(spdlog::level::err);
int result = Catch::Session().run(argc, argv); int result = Catch::Session().run(argc, argv);
hdbpp_internal::LogConfigurator::shutdownLogging(); hdbpp_internal::LogConfigurator::shutdownLogging("tests");
return result; return result;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment