Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
gtest/*
googletest/*
build/*
tests/*
fail-under-line: 80
html-out: coverage.html
html-details: true
Expand Down
74 changes: 62 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,82 @@ endif()
# ---------------------------------------------------------------------------------------
# Build the library
# ---------------------------------------------------------------------------------------
add_library(datamanagement INTERFACE)
set(DATAMANAGEMENT_SRCS
src/modeldata/model_data.cpp
src/source/csv_source.cpp
src/source/db_source.cpp
src/utils/logging.cpp
)

if(DATAMANAGEMENT_BUILD_SHARED_LIBS)
if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
list(APPEND DATAMANAGEMENT_SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif()
add_library(datamanagement SHARED ${DATAMANAGEMENT_SRCS} ${DATAMANAGEMENT_ALL_HEADERS})
target_compile_definitions(datamanagement PUBLIC DATAMANAGEMENT_SHARED_LIB)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(datamanagement PUBLIC $<$<AND:$<CXX_COMPILER_ID:MSVC>,$<NOT:$<COMPILE_LANGUAGE:CUDA>>>:/wd4251
/wd4275>)
endif()
else()
add_library(datamanagement STATIC ${DATAMANAGEMENT_SRCS} ${DATAMANAGEMENT_ALL_HEADERS})
endif()

# ---------------------------------------------------------------------------------------
# Alias for importing
# ---------------------------------------------------------------------------------------
add_library(datamanagement::datamanagement ALIAS datamanagement)

set(DATAMANAGEMENT_INCLUDES_LEVEL "")
if(DATAMANAGEMENT_SYSTEM_INCLUDES)
set(DATAMANAGEMENT_INCLUDES_LEVEL "SYSTEM")
endif()

target_compile_definitions(datamanagement PUBLIC DATAMANAGEMENT_COMPILED_LIB)
target_include_directories(datamanagement ${DATAMANAGEMENT_INCLUDES_LEVEL} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>")

option(BUILD_TESTS "enable datamanagement unit tests" OFF)
if (NOT BUILD_TESTS STREQUAL OFF)
add_subdirectory(tests)
endif()

target_include_directories(${PROJECT_NAME}
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>
target_compile_definitions(datamanagement PUBLIC DATAMANAGEMENT_COMPILED_LIB)
target_include_directories(datamanagement ${DATAMANAGEMENT_INCLUDES_LEVEL}
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>"
)

# ---------------------------------------------------------------------------------------
# Link Dependencies
# ---------------------------------------------------------------------------------------
include(cmake/MakeDependenciesAvailable.cmake)

target_link_libraries(${PROJECT_NAME}
INTERFACE
SQLiteCpp
Boost::boost
spdlog::spdlog
Eigen3::Eigen
)
if (DATAMANAGEMENT_CALCULATE_COVERAGE)
target_link_libraries(datamanagement
PUBLIC
SQLiteCpp
Eigen3::Eigen
PRIVATE
spdlog::spdlog
Boost::boost
gcov
)
else()
target_link_libraries(datamanagement
PUBLIC
SQLiteCpp
Eigen3::Eigen
PRIVATE
spdlog::spdlog
Boost::boost
)
endif()

set_target_properties(datamanagement PROPERTIES VERSION ${DATAMANAGEMENT_VERSION} SOVERSION ${DATAMANAGEMENT_VERSION_MAJOR}.${DATAMANAGEMENT_VERSION_MINOR})

Expand Down
17 changes: 6 additions & 11 deletions cmake/LoadEigen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@ message(CHECK_START "Fetching Eigen3...")
list(APPEND CMAKE_MESSAGE_INDENT " ")

FetchContent_Declare(
Eigen
Eigen3
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG master
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
GIT_TAG "3.4.0"
FIND_PACKAGE_ARGS NAMES Eigen3
)
# note: To disable eigen tests,
# you should put this code in a add_subdirectory to avoid to change
# BUILD_TESTING for your own project too since variables are directory
# scoped
set(BUILD_TESTING OFF)

# Turn off Eigen Testing and Docs
set(EIGEN_BUILD_TESTING OFF)
set(EIGEN_MPL2_ONLY ON)
set(EIGEN_BUILD_PKGCONFIG OFF)
set(EIGEN_BUILD_DOC OFF)
set(EIGEN_MPL2_ONLY ON)

list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "Eigen3 Fetched")
1 change: 1 addition & 0 deletions cmake/LoadSpdlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ FetchContent_Declare(
GIT_TAG v1.x
GIT_PROGRESS TRUE
)
set(SPDLOG_INSTALL ON)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "spdlog Fetched")
4 changes: 2 additions & 2 deletions cmake/MakeDependenciesAvailable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ include(cmake/LoadEigen.cmake)
include(cmake/LoadSpdlog.cmake)

if(DATAMANAGEMENT_BUILD_TESTS STREQUAL "OFF")
FetchContent_MakeAvailable(Eigen SQLiteCpp Boost spdlog)
FetchContent_MakeAvailable(Eigen3 SQLiteCpp Boost spdlog)
elseif(DATAMANAGEMENT_BUILD_TESTS STREQUAL "ON")
include(cmake/LoadGtest.cmake)
FetchContent_MakeAvailable(Eigen SQLiteCpp Boost spdlog googletest)
FetchContent_MakeAvailable(Eigen3 SQLiteCpp Boost spdlog googletest)
include(GoogleTest)
endif()
2 changes: 1 addition & 1 deletion cmake/datamanagement.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Description: Syndemics Data Management
URL: https://github.com/SyndemicsLab
Version: @DATAMANAGEMENT_VERSION@
CFlags: -I${includedir} @PKG_CONFIG_DEFINES@
Libs: -L${libdir} -lspdlog -lboost
Libs: -L${libdir} -lspdlog -lboost -libeigen -libsqlitecpp
Requires: @PKG_CONFIG_REQUIRES@
3 changes: 1 addition & 2 deletions include/datamanagement/datamanagement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created Date: Th Feb 2025 //
// Author: Matthew Carroll //
// ----- //
// Last Modified: Thu Feb 20 2025 //
// Last Modified: 2025-05-01 //
// Modified By: Matthew Carroll //
// ----- //
// Copyright (c) 2025 Syndemics Lab at Boston Medical Center //
Expand All @@ -18,7 +18,6 @@
#define DATAMANAGEMENT_DATAMANAGEMENT_HPP_

#include <datamanagement/modeldata/model_data.hpp>
#include <datamanagement/source/config.hpp>
#include <datamanagement/source/csv_source.hpp>
#include <datamanagement/source/db_source.hpp>

Expand Down
61 changes: 14 additions & 47 deletions include/datamanagement/modeldata/model_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created Date: Th Feb 2025 //
// Author: Matthew Carroll //
// ----- //
// Last Modified: 2025-04-30 //
// Last Modified: 2025-05-01 //
// Modified By: Matthew Carroll //
// ----- //
// Copyright (c) 2025 Syndemics Lab at Boston Medical Center //
Expand All @@ -17,66 +17,33 @@
#ifndef DATAMANAGEMENT_MODELDATA_MODELDATA_HPP_
#define DATAMANAGEMENT_MODELDATA_MODELDATA_HPP_

#include <filesystem>
#include <memory>
#include <string>
#include <vector>

#include <datamanagement/source/config.hpp>
#include <datamanagement/source/csv_source.hpp>
#include <datamanagement/source/db_source.hpp>

namespace datamanagement {
class ModelData {
private:
datamanagement::source::Config config;
std::unordered_map<std::string, datamanagement::source::CSVSource>
_csv_sources = {};
std::unordered_map<std::string, datamanagement::source::DBSource>
_db_sources = {};

public:
ModelData(const std::string &cfgfile) : config(cfgfile) {}
~ModelData() = default;
datamanagement::source::Config GetConfig() const { return config; }
virtual ~ModelData() = default;
virtual std::string GetFromConfig(const std::string &key) const = 0;

virtual std::vector<std::string>
GetConfigSectionCategories(const std::string &section) const = 0;

virtual void AddSource(const std::string &path) = 0;

void AddSource(const std::string &path) {
std::filesystem::path p = path;
if (p.extension() == ".csv") {
datamanagement::source::CSVSource s;
_csv_sources[p.stem()] = std::move(s);
_csv_sources[p.stem()].ConnectToFile(path);
} else if (p.extension() == ".db") {
datamanagement::source::DBSource s;
_db_sources[p.stem()] = std::move(s);
_db_sources[p.stem()].SetDatabasePath(path);
} else {
// Not a valid source file
}
}
virtual std::vector<std::string> GetCSVSourceNames() const = 0;
virtual std::vector<std::string> GetDBSourceNames() const = 0;

std::vector<std::string> GetCSVSourceNames() const {
std::vector<std::string> names = {};
for (const auto &[k, v] : _csv_sources) {
names.push_back(k);
}
return names;
}
std::vector<std::string> GetDBSourceNames() const {
std::vector<std::string> names = {};
for (const auto &[k, v] : _db_sources) {
names.push_back(k);
}
return names;
}
virtual source::CSVSource &GetCSVSource(const std::string &name) = 0;

datamanagement::source::CSVSource &GetCSVSource(const std::string &name) {
return _csv_sources[name];
}
virtual source::DBSource &GetDBSource(const std::string &name) = 0;

datamanagement::source::DBSource &GetDBSource(const std::string &name) {
return _db_sources[name];
}
static std::unique_ptr<ModelData>
Create(const std::string &config, const std::string &log_name = "console");
};
} // namespace datamanagement

Expand Down
55 changes: 0 additions & 55 deletions include/datamanagement/source/config.hpp

This file was deleted.

Loading
Loading