From 8b0b40b6c5b1e264fdf352bb129ded88ff49e28b Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Sat, 11 Jul 2020 17:29:10 +0200 Subject: [PATCH] dummy lib --- readLib/CMakeLists.txt | 19 ++++++++++++++----- readLib/corsika_data/Interface.h | 5 ++--- readLib/source/Interface.boost.cc | 3 +++ readLib/source/Interface.dummy.cc | 23 +++++++++++++++++++++++ 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 readLib/source/Interface.dummy.cc diff --git a/readLib/CMakeLists.txt b/readLib/CMakeLists.txt index a18b2cf..f6155ac 100644 --- a/readLib/CMakeLists.txt +++ b/readLib/CMakeLists.txt @@ -1,13 +1,22 @@ find_package (Boost COMPONENTS iostreams REQUIRED) -set ( - files - source/Interface.boost.cc - ) +if (Boost_iostreams_FOUND) + set ( + files + source/Interface.boost.cc + ) +else (Boost_iostreams_FOUND) + set ( + files + source/Interface.dummy.cc + ) +endif (Boost_iostreams_FOUND) add_library(libCorsikaData STATIC ${files}) -target_link_libraries(libCorsikaData PUBLIC Boost::iostreams) +if (Boost_iostreams_FOUND) + target_link_libraries(libCorsikaData PUBLIC Boost::iostreams) +endif (Boost_iostreams_FOUND) set_target_properties ( libCorsikaData diff --git a/readLib/corsika_data/Interface.h b/readLib/corsika_data/Interface.h index c028ab0..812bd09 100644 --- a/readLib/corsika_data/Interface.h +++ b/readLib/corsika_data/Interface.h @@ -11,8 +11,7 @@ namespace corsika_data { void CorDataCloseFile(); double CorDataNextNumber(); int CorDataNextText(std::string& data); - bool CorDataCanDeCompress() { return true; } - + bool CorDataCanDeCompress(); // the fortran interface functions extern "C" { @@ -21,7 +20,7 @@ namespace corsika_data { void cordataclosefile_(); double cordatanextnumber_(); int cordatanexttext_(char* data, int length); - int cordatacandecompress() { return 1; } + int cordatacandecompress(); } } diff --git a/readLib/source/Interface.boost.cc b/readLib/source/Interface.boost.cc index 4515c5b..3f4f0fe 100644 --- a/readLib/source/Interface.boost.cc +++ b/readLib/source/Interface.boost.cc @@ -59,6 +59,8 @@ namespace corsika_data { data[i] = STR[i]; return 0; } + bool CorDataCanDeCompress() { return true; } + extern "C" { @@ -75,5 +77,6 @@ namespace corsika_data { void cordataclosefile_() { global_DataFile.Close(); } + int cordatacandecompress() { return 1; } } } diff --git a/readLib/source/Interface.dummy.cc b/readLib/source/Interface.dummy.cc new file mode 100644 index 0000000..80b4ed3 --- /dev/null +++ b/readLib/source/Interface.dummy.cc @@ -0,0 +1,23 @@ +#include <string> +#include <stdexcept> + +namespace corsika_data { + + // the c++ interface functions + void CorDataOpenFile(char*) { std::runtime_error("Cannot read compressed data files with dummy library."); } + void CorDataFillArray(double*, const int&) { std::runtime_error("Cannot read compressed data files with dummy library."); } + void CorDataCloseFile() { std::runtime_error("Cannot read compressed data files with dummy library."); } + double CorDataNextNumber() { std::runtime_error("Cannot read compressed data files with dummy library."); return 0; } + int CorDataNextText(std::string&) { std::runtime_error("Cannot read compressed data files with dummy library."); return 0; } + bool CorDataCanDeCompress() { return false; } + + // the fortran interface functions + extern "C" { + void cordataopenfile_(char* name) { CorDataOpenFile(name); } + void cordatafillarray_(double* data, const int& length) { CorDataFillArray(data,length); } + void cordataclosefile_() { CorDataCloseFile(); } + double cordatanextnumber_() { return CorDataNextNumber(); } + int cordatanexttext_(char* data) { std::runtime_error("Cannot read compressed data files with dummy library."); return 0; } + int cordatacandecompress() { return 0; } + } +} -- GitLab