diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 0cab49175d..1ecddf3b57 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -104,16 +104,17 @@ jobs: # run: ctest -V # working-directory: ${{ runner.workspace }}/_build - - name: Pack - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - retry_on: error - timeout_minutes: 3 - command: cd ${{ runner.workspace }}/_build && cpack -G DragNDrop +# Currently (2024-11-28) packing very often fails under macos +# - name: Pack +# uses: nick-fields/retry@v2 +# with: +# max_attempts: 3 +# retry_on: error +# timeout_minutes: 3 +# command: cd ${{ runner.workspace }}/_build && cpack -G DragNDrop - - name: Upload DMG - uses: actions/upload-artifact@v4 - with: - name: macos-dmg - path: ${{ runner.workspace }}/_build/_deploy/*.dmg +# - name: Upload DMG +# uses: actions/upload-artifact@v4 +# with: +# name: macos-dmg +# path: ${{ runner.workspace }}/_build/_deploy/*.dmg diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index faaedb375b..c410807df0 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -84,7 +84,6 @@ jobs: git submodule deinit thirdparty/hdf5/hdf5 git submodule deinit thirdparty/libssh2/libssh2 git submodule deinit thirdparty/protobuf/protobuf - git submodule deinit thirdparty/zlib/zlib git submodule update - name: Create venv for building docs diff --git a/.github/workflows/clang-tidy-review-post-comments.yml b/.github/workflows/clang-tidy-review-post-comments.yml index e9fcc46531..13da89510d 100644 --- a/.github/workflows/clang-tidy-review-post-comments.yml +++ b/.github/workflows/clang-tidy-review-post-comments.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: ZedThree/clang-tidy-review/post@v0.14.0 + - uses: ZedThree/clang-tidy-review/post@v0.20.1 # lgtm_comment_body, max_comments, and annotations need to be set on the posting workflow in a split setup with: # adjust options as necessary diff --git a/.github/workflows/clang-tidy-review.yml b/.github/workflows/clang-tidy-review.yml index e283dcff89..36699b3c09 100644 --- a/.github/workflows/clang-tidy-review.yml +++ b/.github/workflows/clang-tidy-review.yml @@ -26,7 +26,7 @@ jobs: fetch-depth: 0 - name: Run clang-tidy - uses: ZedThree/clang-tidy-review@v0.14.0 + uses: ZedThree/clang-tidy-review@v0.20.1 id: review with: build_dir: _build @@ -75,4 +75,4 @@ jobs: -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu cmake --build _build - - uses: ZedThree/clang-tidy-review/upload@v0.14.0 + - uses: ZedThree/clang-tidy-review/upload@v0.20.1 diff --git a/.gitmodules b/.gitmodules index 26e90d5cf5..758657d496 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,9 +22,6 @@ [submodule "thirdparty/curl"] path = thirdparty/curl/curl url = https://github.com/curl/curl.git -[submodule "thirdparty/zlib"] - path = thirdparty/zlib/zlib - url = https://github.com/madler/zlib.git [submodule "thirdparty/libssh2"] path = thirdparty/libssh2/libssh2 url = https://github.com/libssh2/libssh2.git diff --git a/app/meas_cutter/CMakeLists.txt b/app/meas_cutter/CMakeLists.txt index 637b0783c8..2c41c73ab6 100644 --- a/app/meas_cutter/CMakeLists.txt +++ b/app/meas_cutter/CMakeLists.txt @@ -55,7 +55,7 @@ target_include_directories(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} yaml-cpp::yaml-cpp tclap::tclap eCAL::ecal-utils - eCAL::measurement_hdf5 + eCAL::hdf5 Threads::Threads) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/app/meas_cutter/src/config_file_parser.h b/app/meas_cutter/src/config_file_parser.h index 4efa8e3583..e545b80c86 100644 --- a/app/meas_cutter/src/config_file_parser.h +++ b/app/meas_cutter/src/config_file_parser.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include #include -#define YAML_CPP_STATIC_DEFINE +//#define YAML_CPP_STATIC_DEFINE // set by CMake #include #include "utils.h" diff --git a/app/meas_cutter/src/measurement_exporter.cpp b/app/meas_cutter/src/measurement_exporter.cpp index 32743aac5f..115c454cb2 100644 --- a/app/meas_cutter/src/measurement_exporter.cpp +++ b/app/meas_cutter/src/measurement_exporter.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,10 +18,9 @@ */ #include "measurement_exporter.h" -#include MeasurementExporter::MeasurementExporter(): - _writer(std::make_unique()) + _writer(std::make_unique()) { } @@ -29,7 +28,7 @@ void MeasurementExporter::setPath(const std::string& path, const std::string& ba { _root_output_path = EcalUtils::Filesystem::CleanPath(path); _output_path = EcalUtils::Filesystem::CleanPath(_root_output_path + EcalUtils::Filesystem::NativeSeparator(EcalUtils::Filesystem::OsStyle::Current) + eCALMeasCutterUtils::kDefaultFolderOutput, EcalUtils::Filesystem::OsStyle::Current); - if (!_writer->Open(_output_path)) + if (!_writer->Open(_output_path, eCAL::eh5::v2::eAccessType::CREATE)) { throw ExporterException("Unable to create HDF5 protobuf output path " + path + "."); } @@ -76,10 +75,10 @@ void MeasurementExporter::setData(eCALMeasCutterUtils::Timestamp timestamp, cons const auto sender_timestamp = (iter != meta_data.end()) ? iter->second.sender_timestamp : static_cast(0); iter = meta_data.find(eCALMeasCutterUtils::MetaDatumKey::SENDER_ID); - const auto sender_id = (iter != meta_data.end()) ? iter->second.sender_id : static_cast(0); + const auto sender_id = (iter != meta_data.end()) ? iter->second.sender_id : 0; iter = meta_data.find(eCALMeasCutterUtils::MetaDatumKey::SENDER_CLOCK); - const auto sender_clock = (iter != meta_data.end()) ? iter->second.sender_clock : static_cast(0); + const auto sender_clock = (iter != meta_data.end()) ? iter->second.sender_clock : 0; if (!_writer->AddEntryToFile(payload.data(), payload.size(), sender_timestamp, timestamp, _current_channel_name, sender_id, sender_clock)) { diff --git a/app/meas_cutter/src/measurement_exporter.h b/app/meas_cutter/src/measurement_exporter.h index 3d8c51334d..eea8290381 100644 --- a/app/meas_cutter/src/measurement_exporter.h +++ b/app/meas_cutter/src/measurement_exporter.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,14 @@ */ #pragma once + #include -#include #include +#include +#include +#include -#include +#include #include #include "utils.h" @@ -43,7 +46,7 @@ class MeasurementExporter std::string getRootOutputPath() const; private: - std::unique_ptr _writer; + std::unique_ptr _writer; std::string _current_channel_name; std::string _output_path; std::string _root_output_path; diff --git a/app/meas_cutter/src/measurement_importer.cpp b/app/meas_cutter/src/measurement_importer.cpp index 8394ddb582..62ab0eb102 100644 --- a/app/meas_cutter/src/measurement_importer.cpp +++ b/app/meas_cutter/src/measurement_importer.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,10 +18,10 @@ */ #include "measurement_importer.h" -#include +#include MeasurementImporter::MeasurementImporter() : - _reader(std::make_unique()), + _reader(std::make_unique()), _current_opened_channel_data() { } diff --git a/app/meas_cutter/src/measurement_importer.h b/app/meas_cutter/src/measurement_importer.h index 0c20f3f5af..bd40390780 100644 --- a/app/meas_cutter/src/measurement_importer.h +++ b/app/meas_cutter/src/measurement_importer.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,14 +18,16 @@ */ #pragma once -#include #include -#include #include -#include +#include +#include +#include +#include +#include #include -#include +#include #include "utils.h" @@ -53,7 +55,7 @@ class MeasurementImporter private: bool isEcalMeasFile(const std::string& path); bool isProtoChannel(const eCAL::experimental::measurement::base::DataTypeInformation& channel_info); - std::unique_ptr _reader; + std::unique_ptr _reader; eCALMeasCutterUtils::ChannelData _current_opened_channel_data; std::string _loaded_path; eCALMeasCutterUtils::ChannelNameSet _channel_names; diff --git a/app/meas_cutter/src/utils.h b/app/meas_cutter/src/utils.h index 9d40dee26f..0523391c10 100644 --- a/app/meas_cutter/src/utils.h +++ b/app/meas_cutter/src/utils.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ #include #include -#define YAML_CPP_STATIC_DEFINE +//#define YAML_CPP_STATIC_DEFINE // set by CMake #include "yaml-cpp/yaml.h" #include @@ -312,10 +312,10 @@ namespace eCALMeasCutterUtils { Timestamp receiver_timestamp; Timestamp sender_timestamp; - uint64_t sender_id; - uint64_t sender_clock; + int64_t sender_id; + int64_t sender_clock; - std::array __union_size; + std::array __union_size; }; typedef std::unordered_map MetaData; diff --git a/app/mon/mon_cli/src/ecal_mon_cli.cpp b/app/mon/mon_cli/src/ecal_mon_cli.cpp index e27fd7ed20..d961546d5d 100644 --- a/app/mon/mon_cli/src/ecal_mon_cli.cpp +++ b/app/mon/mon_cli/src/ecal_mon_cli.cpp @@ -209,7 +209,7 @@ int main(int argc, char** argv) } // initialize eCAL API - eCAL::Initialize(0, nullptr, "eCALMon CLI", eCAL::Init::All); + eCAL::Initialize("eCALMon CLI", eCAL::Init::All); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "Running"); @@ -351,15 +351,6 @@ void ProcProto(const std::string& topic_name, int msg_count) // sleep 1000 ms std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - // get topic type - eCAL::SDataTypeInformation topic_info; - eCAL::Registration::GetTopicDataTypeInformation(topic_name, topic_info); - if(topic_info.name.empty()) - { - std::cout << "could not get type name for topic " << topic_name << std::endl; - return; - } - // create dynamic subscribers for receiving and decoding messages and assign callback eCAL::protobuf::CDynamicSubscriber sub(topic_name); std::atomic cnt(msg_count); diff --git a/app/mon/mon_gui/src/ecalmon.cpp b/app/mon/mon_gui/src/ecalmon.cpp index e059e2975e..f9edf8ddb9 100644 --- a/app/mon/mon_gui/src/ecalmon.cpp +++ b/app/mon/mon_gui/src/ecalmon.cpp @@ -71,7 +71,7 @@ Ecalmon::Ecalmon(QWidget *parent) , monitor_error_counter_(0) { // Just make sure that eCAL is initialized - eCAL::Initialize(0, nullptr, "eCALMon", eCAL::Init::Default | eCAL::Init::Monitoring); + eCAL::Initialize("eCALMon", eCAL::Init::Default | eCAL::Init::Monitoring); eCAL::Monitoring::SetFilterState(false); eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "Running"); diff --git a/app/mon/mon_gui/src/widgets/about_dialog/about_dialog.cpp b/app/mon/mon_gui/src/widgets/about_dialog/about_dialog.cpp index 8ae7f4d1a0..c0e5b8c508 100644 --- a/app/mon/mon_gui/src/widgets/about_dialog/about_dialog.cpp +++ b/app/mon/mon_gui/src/widgets/about_dialog/about_dialog.cpp @@ -32,7 +32,7 @@ AboutDialog::AboutDialog(QWidget *parent) ui_.version_label->setText("Version: " + QString(EcalmonGlobals::VERSION_STRING)); ui_.ecalversion_label->setText("eCAL " + QString(ECAL_VERSION) + " (" + QString(ECAL_DATE) + ")"); - ui_.ecal_runtime_version_string_label->setText(QString(eCAL::GetVersionString()) + " (" + QString(eCAL::GetVersionDateString()) + ")"); + ui_.ecal_runtime_version_string_label->setText(QString::fromStdString(eCAL::GetVersionString()) + " (" + QString::fromStdString(eCAL::GetVersionDateString()) + ")"); ui_.ecal_compiletime_versin_string_label->setText(QString(ECAL_VERSION) + " (" + QString(ECAL_DATE) + ")"); ui_.qt_runtime_version_string_label->setText(QString(qVersion())); ui_.qt_compiletime_version_string_label->setText(QString(QT_VERSION_STR)); diff --git a/app/mon/mon_plugins/capnproto_reflection/src/plugin_widget.cpp b/app/mon/mon_plugins/capnproto_reflection/src/plugin_widget.cpp index 77dd0f0124..f028405537 100644 --- a/app/mon/mon_plugins/capnproto_reflection/src/plugin_widget.cpp +++ b/app/mon/mon_plugins/capnproto_reflection/src/plugin_widget.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ PluginWidget::PluginWidget(const QString& topic_name, const QString& topic_type, // Add eCAL Callbacks subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_2, std::placeholders::_3)); - //subscriber_.AddErrorCallback(std::bind(&PluginWidget::onProtoErrorCallback, this, std::placeholders::_1)); + subscriber_.AddErrorCallback(std::bind(&PluginWidget::onProtoErrorCallback, this, std::placeholders::_1)); // Button connections connect(ui_.expand_button, &QPushButton::clicked, [this]() { tree_view_->expandAll(); }); @@ -323,13 +323,13 @@ void PluginWidget::onResume() { // Add eCAL Callbacks subscriber_.AddReceiveCallback(std::bind(&PluginWidget::onProtoMessageCallback, this, std::placeholders::_2, std::placeholders::_3)); - //subscriber_.AddErrorCallback(std::bind(&PluginWidget::onProtoErrorCallback, this, std::placeholders::_1)); + subscriber_.AddErrorCallback(std::bind(&PluginWidget::onProtoErrorCallback, this, std::placeholders::_1)); } void PluginWidget::onPause() { subscriber_.RemReceiveCallback(); - //subscriber_.RemErrorCallback(); + subscriber_.RemErrorCallback(); } QWidget* PluginWidget::getWidget() diff --git a/app/mon/mon_plugins/raw_data_reflection/src/plugin_widget.cpp b/app/mon/mon_plugins/raw_data_reflection/src/plugin_widget.cpp index 31c3d1afb3..8b4c4b13ad 100644 --- a/app/mon/mon_plugins/raw_data_reflection/src/plugin_widget.cpp +++ b/app/mon/mon_plugins/raw_data_reflection/src/plugin_widget.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,12 @@ PluginWidget::PluginWidget(const QString& topic_name, const QString&, QWidget* p ui_.content_layout->addWidget(frame); // Connect the eCAL Subscriber - subscriber_.AddReceiveCallback(std::bind(&PluginWidget::ecalMessageReceivedCallback, this, std::placeholders::_2)); + subscriber_.AddReceiveCallback([this](const eCAL::Registration::STopicId& /*topic_id*/, + const eCAL::SDataTypeInformation& /*data_type_info*/, + const eCAL::SReceiveCallbackData& callback_data) + { + ecalMessageReceivedCallback(callback_data); + }); } PluginWidget::~PluginWidget() @@ -67,12 +72,12 @@ PluginWidget::~PluginWidget() subscriber_.RemReceiveCallback(); } -void PluginWidget::ecalMessageReceivedCallback(const struct eCAL::SReceiveCallbackData* callback_data) +void PluginWidget::ecalMessageReceivedCallback(const eCAL::SReceiveCallbackData& callback_data) { std::lock_guard message_lock(message_mutex_); - last_message_ = QByteArray(static_cast(callback_data->buf), callback_data->size); + last_message_ = QByteArray(static_cast(callback_data.buf), callback_data.size); - last_message_publish_timestamp_ = eCAL::Time::ecal_clock::time_point(std::chrono::microseconds(callback_data->time)); + last_message_publish_timestamp_ = eCAL::Time::ecal_clock::time_point(std::chrono::microseconds(callback_data.time)); received_message_counter_++; new_msg_available_ = true; @@ -128,7 +133,13 @@ void PluginWidget::onUpdate() void PluginWidget::onResume() { - subscriber_.AddReceiveCallback(std::bind(&PluginWidget::ecalMessageReceivedCallback, this, std::placeholders::_2)); + // (Re)Connect the eCAL Subscriber + subscriber_.AddReceiveCallback([this](const eCAL::Registration::STopicId& /*topic_id*/, + const eCAL::SDataTypeInformation& /*data_type_info*/, + const eCAL::SReceiveCallbackData& callback_data) + { + ecalMessageReceivedCallback(callback_data); + }); } void PluginWidget::onPause() diff --git a/app/mon/mon_plugins/raw_data_reflection/src/plugin_widget.h b/app/mon/mon_plugins/raw_data_reflection/src/plugin_widget.h index d2491849d4..72bd872525 100644 --- a/app/mon/mon_plugins/raw_data_reflection/src/plugin_widget.h +++ b/app/mon/mon_plugins/raw_data_reflection/src/plugin_widget.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ private slots: bool new_msg_available_; int received_message_counter_; - void ecalMessageReceivedCallback(const struct eCAL::SReceiveCallbackData* callback_data); + void ecalMessageReceivedCallback(const eCAL::SReceiveCallbackData& callback_data); #if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) static QString bytesToHex(const QByteArray& byte_array, char separator = '\0'); diff --git a/app/mon/mon_plugins/string_reflection/src/plugin_widget.h b/app/mon/mon_plugins/string_reflection/src/plugin_widget.h index ae99943f77..f09c455b1f 100644 --- a/app/mon/mon_plugins/string_reflection/src/plugin_widget.h +++ b/app/mon/mon_plugins/string_reflection/src/plugin_widget.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,12 +56,12 @@ private slots: QTextEdit* text_edit_; eCAL::string::CSubscriber subscriber_; - std::string last_message_; - eCAL::Time::ecal_clock::time_point last_message_publish_timestamp_; - std::mutex message_mutex_; + std::string last_message_; + eCAL::Time::ecal_clock::time_point last_message_publish_timestamp_; + std::mutex message_mutex_; - bool new_msg_available_; - int received_message_counter_; + bool new_msg_available_; + int received_message_counter_; void ecalMessageReceivedCallback(const std::string& message, long long publish_timestamp_usecs); }; diff --git a/app/mon/mon_tui/src/main.cpp b/app/mon/mon_tui/src/main.cpp index ec360131ca..b5c1007af2 100644 --- a/app/mon/mon_tui/src/main.cpp +++ b/app/mon/mon_tui/src/main.cpp @@ -32,7 +32,7 @@ int main(int argc, char** argv) { auto args = ParseArgs(argc, argv); - auto status = eCAL::Initialize(0, nullptr, "eCALMon TUI", eCAL::Init::Default | eCAL::Init::Monitoring); + auto status = eCAL::Initialize("eCALMon TUI", eCAL::Init::Default | eCAL::Init::Monitoring); if (status == -1) std::cerr << "Failed to init" << std::endl; eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "Running"); eCAL::Monitoring::SetFilterState(false); diff --git a/app/play/play_core/CMakeLists.txt b/app/play/play_core/CMakeLists.txt index 29de1b037d..f99d6aed54 100644 --- a/app/play/play_core/CMakeLists.txt +++ b/app/play/play_core/CMakeLists.txt @@ -1,6 +1,6 @@ # ========================= eCAL LICENSE ================================= # -# Copyright (C) 2016 - 2019 Continental Corporation +# Copyright (C) 2016 - 2024 Continental Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC eCAL::core_protobuf eCAL::app_pb eCAL::ecaltime_pb - eCAL::measurement_hdf5 + eCAL::hdf5 ) target_link_libraries(${PROJECT_NAME} PRIVATE diff --git a/app/play/play_core/include/ecal_play.h b/app/play/play_core/include/ecal_play.h index ad07a767e2..95e8823b9d 100644 --- a/app/play/play_core/include/ecal_play.h +++ b/app/play/play_core/include/ecal_play.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -298,6 +298,15 @@ class EcalPlay **/ std::string GetChannelType(const std::string& channel_name) const; + /** + * @brief Gets the encoding of the given channel + * + * @param channel_name channel name + * + * @return channel type +**/ + std::string GetChannelEncoding(const std::string& channel_name) const; + void CalculateEstimatedSizeForChannels() const; /** diff --git a/app/play/play_core/src/ecal_play.cpp b/app/play/play_core/src/ecal_play.cpp index 45d9608688..5c905e2a0c 100644 --- a/app/play/play_core/src/ecal_play.cpp +++ b/app/play/play_core/src/ecal_play.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,16 +19,16 @@ #include "ecal_play.h" -#include +#include +#include #include +#include +#include #include -#include -#include #include "ecal_play_logger.h" #include "play_thread.h" -#include - +#include #include #include #include @@ -37,7 +37,7 @@ EcalPlay::EcalPlay() { LogAppNameVersion(); - eCAL::Initialize(0, nullptr, "eCALPlay"); + eCAL::Initialize("eCALPlay"); play_thread_ = std::make_unique(); play_thread_->Start(); @@ -58,7 +58,7 @@ bool EcalPlay::LoadMeasurement(const std::string& path) { EcalPlayLogger::Instance()->info("Loading measurement..."); - std::shared_ptr measurement(std::make_shared()); + std::shared_ptr measurement(std::make_shared()); std::string meas_dir; // The directory of the measurement std::string path_to_load; // The actual path we load the measurement from. May be a directory or a .hdf5 file @@ -129,7 +129,7 @@ bool EcalPlay::LoadMeasurement(const std::string& path) void EcalPlay::CloseMeasurement() { description_ = ""; - play_thread_->SetMeasurement(std::shared_ptr(nullptr)); + play_thread_->SetMeasurement(std::shared_ptr(nullptr)); measurement_path_ = ""; clearScenariosPath(); channel_mapping_path_ = ""; @@ -224,6 +224,11 @@ std::string EcalPlay::GetChannelType(const std::string& channel_name) const return play_thread_->GetChannelType(channel_name); } +std::string EcalPlay::GetChannelEncoding(const std::string& channel_name) const +{ + return play_thread_->GetChannelEncoding(channel_name); +} + void EcalPlay::CalculateEstimatedSizeForChannels() const { play_thread_->CalculateEstimatedSizeForChannels(); diff --git a/app/play/play_core/src/measurement_container.cpp b/app/play/play_core/src/measurement_container.cpp index fbd80a6d51..4909d5cef9 100644 --- a/app/play/play_core/src/measurement_container.cpp +++ b/app/play/play_core/src/measurement_container.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +20,13 @@ #include "measurement_container.h" #include -#include +#include #include #include #include -MeasurementContainer::MeasurementContainer(std::shared_ptr hdf5_meas, const std::string& meas_dir, bool use_receive_timestamp) +MeasurementContainer::MeasurementContainer(std::shared_ptr hdf5_meas, const std::string& meas_dir, bool use_receive_timestamp) : hdf5_meas_ (hdf5_meas) , meas_dir_ (meas_dir) , use_receive_timestamp_ (use_receive_timestamp) @@ -311,9 +311,12 @@ double MeasurementContainer::GetMaxTimestampOfChannel(const std::string& channel std::string MeasurementContainer::GetChannelType(const std::string& channel_name) const { - // This function needs to also return the proper datatypes information! To clean up. - auto datatype_information = hdf5_meas_->GetChannelDataTypeInformation(channel_name); - return eCAL::Util::CombinedTopicEncodingAndType(datatype_information.encoding, datatype_information.name); + return hdf5_meas_->GetChannelDataTypeInformation(channel_name).name; +} + +std::string MeasurementContainer::GetChannelEncoding(const std::string& channel_name) const +{ + return hdf5_meas_->GetChannelDataTypeInformation(channel_name).encoding; } size_t MeasurementContainer::GetChannelCumulativeEstimatedSize(const std::string& channel_name) const diff --git a/app/play/play_core/src/measurement_container.h b/app/play/play_core/src/measurement_container.h index fa5cd691ff..1925da8ce8 100644 --- a/app/play/play_core/src/measurement_container.h +++ b/app/play/play_core/src/measurement_container.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,14 +24,14 @@ #include #include -#include +#include #include "continuity_report.h" class MeasurementContainer { public: - MeasurementContainer(std::shared_ptr hdf5_meas, const std::string& meas_dir = "", bool use_receive_timestamp = true); + MeasurementContainer(std::shared_ptr hdf5_meas, const std::string& meas_dir = "", bool use_receive_timestamp = true); ~MeasurementContainer(); void CreatePublishers(); @@ -60,6 +60,7 @@ class MeasurementContainer double GetMinTimestampOfChannel(const std::string& channel_name) const; double GetMaxTimestampOfChannel(const std::string& channel_name) const; std::string GetChannelType(const std::string& channel_name) const; + std::string GetChannelEncoding(const std::string& channel_name) const; size_t GetChannelCumulativeEstimatedSize(const std::string& channel_name) const; std::map GetChannelMapping() const; @@ -108,7 +109,7 @@ class MeasurementContainer PublisherInfo* publisher_info_; }; - std::shared_ptr hdf5_meas_; + std::shared_ptr hdf5_meas_; std::string meas_dir_; bool use_receive_timestamp_; diff --git a/app/play/play_core/src/play_thread.cpp b/app/play/play_core/src/play_thread.cpp index 3bf3a3f2c1..6e4de55d9a 100644 --- a/app/play/play_core/src/play_thread.cpp +++ b/app/play/play_core/src/play_thread.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -576,7 +576,7 @@ void PlayThread::LogChannelMapping(const std::map& cha //// Measurement //// //////////////////////////////////////////////////////////////////////////////// -void PlayThread::SetMeasurement(const std::shared_ptr& measurement, const std::string& path) +void PlayThread::SetMeasurement(const std::shared_ptr& measurement, const std::string& path) { std::unique_ptr new_measurment_container; @@ -763,6 +763,19 @@ std::string PlayThread::GetChannelType(const std::string& channel_name) } } +std::string PlayThread::GetChannelEncoding(const std::string& channel_name) +{ + std::shared_lock measurement_lock(measurement_mutex_); + if (measurement_container_) + { + return measurement_container_->GetChannelEncoding(channel_name); + } + else + { + return std::string(""); + } +} + void PlayThread::CalculateEstimatedSizeForChannels() { std::shared_lock measurement_lock(measurement_mutex_); diff --git a/app/play/play_core/src/play_thread.h b/app/play/play_core/src/play_thread.h index 5e782f3b0e..23c2d34342 100644 --- a/app/play/play_core/src/play_thread.h +++ b/app/play/play_core/src/play_thread.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,7 +79,7 @@ class PlayThread : public InterruptibleThread * @param measurement The new measurement * @param path The (optional) path from where the measurement was loaded */ - void SetMeasurement(const std::shared_ptr& measurement, const std::string& path = ""); + void SetMeasurement(const std::shared_ptr& measurement, const std::string& path = ""); /** * @brief Returns whether a measurement has successfully been loaded @@ -157,6 +157,15 @@ class PlayThread : public InterruptibleThread **/ std::string GetChannelType(const std::string& channel_name); + /** + * @brief Gets the data type of the given channel + * + * @param channel_name channel name + * + * @return channel type + **/ + std::string GetChannelEncoding(const std::string& channel_name); + void CalculateEstimatedSizeForChannels(); /** diff --git a/app/play/play_gui/src/main.cpp b/app/play/play_gui/src/main.cpp index 91fcb1618b..48c6afb939 100644 --- a/app/play/play_gui/src/main.cpp +++ b/app/play/play_gui/src/main.cpp @@ -159,7 +159,7 @@ int main(int argc, char *argv[]) ////////////////////////////////////////////////////////////////////////////// // Just make sure that eCAL is initialized - eCAL::Initialize(0, nullptr, "eCALPlayGUI", eCAL::Init::Default | eCAL::Init::Publisher | eCAL::Init::Service | eCAL::Init::Monitoring); + eCAL::Initialize("eCALPlayGUI", eCAL::Init::Default | eCAL::Init::Publisher | eCAL::Init::Service | eCAL::Init::Monitoring); // For linux big measurements require more file descriptors than the default value #ifdef ECAL_OS_LINUX diff --git a/app/play/play_gui/src/q_ecal_play.cpp b/app/play/play_gui/src/q_ecal_play.cpp index b9c87383a5..7cf7084a94 100644 --- a/app/play/play_gui/src/q_ecal_play.cpp +++ b/app/play/play_gui/src/q_ecal_play.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,6 +128,11 @@ std::string QEcalPlay::channelType(const std::string& channel_name) const return ecal_play_.GetChannelType(channel_name); } +std::string QEcalPlay::channelEncoding(const std::string& channel_name) const +{ + return ecal_play_.GetChannelEncoding(channel_name); +} + size_t QEcalPlay::channelCumulativeEstimatedSize(const std::string& channel_name) const { return ecal_play_.GetChannelCumulativeEstimatedSize(channel_name); diff --git a/app/play/play_gui/src/q_ecal_play.h b/app/play/play_gui/src/q_ecal_play.h index a47210984e..c078ff7913 100644 --- a/app/play/play_gui/src/q_ecal_play.h +++ b/app/play/play_gui/src/q_ecal_play.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,6 +59,7 @@ class QEcalPlay : public QObject double minTimestampOfChannel(const std::string& channel_name) const; double maxTimestampOfChannel(const std::string& channel_name) const; std::string channelType(const std::string& channel_name) const; + std::string channelEncoding(const std::string& channel_name) const; size_t channelCumulativeEstimatedSize(const std::string& channel_name) const; std::map createContinuityReport() const; std::map messageCounters() const; diff --git a/app/play/play_gui/src/widgets/about_dialog/about_dialog.cpp b/app/play/play_gui/src/widgets/about_dialog/about_dialog.cpp index 38b938a9fa..13909f2953 100644 --- a/app/play/play_gui/src/widgets/about_dialog/about_dialog.cpp +++ b/app/play/play_gui/src/widgets/about_dialog/about_dialog.cpp @@ -32,7 +32,7 @@ AboutDialog::AboutDialog(QWidget *parent) ui_.version_label->setText("Version: " + QString(EcalPlayGlobals::VERSION_STRING)); ui_.ecalversion_label->setText("eCAL " + QString(ECAL_VERSION) + " (" + QString(ECAL_DATE) + ")"); - ui_.ecal_runtime_version_string_label->setText(QString(eCAL::GetVersionString()) + " (" + QString(eCAL::GetVersionDateString()) + ")"); + ui_.ecal_runtime_version_string_label->setText(QString::fromStdString(eCAL::GetVersionString()) + " (" + QString::fromStdString(eCAL::GetVersionDateString()) + ")"); ui_.ecal_compiletime_versin_string_label->setText(QString(ECAL_VERSION) + " (" + QString(ECAL_DATE) + ")"); ui_.qt_runtime_version_string_label->setText(QString(qVersion())); ui_.qt_compiletime_version_string_label->setText(QString(QT_VERSION_STR)); diff --git a/app/play/play_gui/src/widgets/channel_widget/channel_widget.cpp b/app/play/play_gui/src/widgets/channel_widget/channel_widget.cpp index c7564a8262..33ea84048b 100644 --- a/app/play/play_gui/src/widgets/channel_widget/channel_widget.cpp +++ b/app/play/play_gui/src/widgets/channel_widget/channel_widget.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -600,7 +600,7 @@ void ChannelWidget::setInitButtonToDeInit() void ChannelWidget::autoSizeColumns() { - ChannelTreeItem* dummy_item = new ChannelTreeItem("CameraSensorMapFusionCAF___", "Dummy_type", 99999999, 99999999.0, 99999999.0, 99999999, 99999999, 99999999); + ChannelTreeItem* dummy_item = new ChannelTreeItem("CameraSensorMapFusionCAF___", "proto", "Dummy_type", 99999999, 99999999.0, 99999999.0, 99999999, 99999999, 99999999); channel_model_->insertItem(dummy_item); for (int i = 0; i < channel_model_->columnCount(); i++) diff --git a/app/play/play_gui/src/widgets/models/channel_tree_item.cpp b/app/play/play_gui/src/widgets/models/channel_tree_item.cpp index 04bc8aa871..9dd3acfed0 100644 --- a/app/play/play_gui/src/widgets/models/channel_tree_item.cpp +++ b/app/play/play_gui/src/widgets/models/channel_tree_item.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,12 +40,13 @@ ChannelTreeItem::ChannelTreeItem(const QString& source_name) , duration_(0) {} -ChannelTreeItem::ChannelTreeItem(const QString& source_name, const QString& channel_type, size_t total_channel_size, +ChannelTreeItem::ChannelTreeItem(const QString& source_name, const QString& channel_encoding, const QString& channel_type, size_t total_channel_size, double min_channel_timestamp, double max_channel_timestamp, long long expected_frames, long long existing_frames, double duration) : QAbstractTreeItem() , enabled_(true) , source_name_(source_name) , target_name_(source_name) + , channel_encoding_(channel_encoding) , channel_type_(channel_type) , total_channel_size_(total_channel_size) , min_channel_timestamp_(min_channel_timestamp) @@ -76,6 +77,8 @@ QVariant ChannelTreeItem::data(Columns column, Qt::ItemDataRole role) const return source_name_; case ChannelTreeItem::Columns::TARGET_CHANNEL_NAME: return target_name_; + case ChannelTreeItem::Columns::CHANNEL_ENCODING: + return channel_encoding_; case ChannelTreeItem::Columns::CHANNEL_TYPE: return channel_type_; case ChannelTreeItem::Columns::TOTAL_CHANNEL_SIZE: diff --git a/app/play/play_gui/src/widgets/models/channel_tree_item.h b/app/play/play_gui/src/widgets/models/channel_tree_item.h index eb143bf37f..95d987444f 100644 --- a/app/play/play_gui/src/widgets/models/channel_tree_item.h +++ b/app/play/play_gui/src/widgets/models/channel_tree_item.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ class ChannelTreeItem : public QAbstractTreeItem SOURCE_CHANNEL_NAME, TARGET_CHANNEL_NAME, + CHANNEL_ENCODING, CHANNEL_TYPE, TOTAL_CHANNEL_SIZE, @@ -47,7 +48,7 @@ class ChannelTreeItem : public QAbstractTreeItem }; ChannelTreeItem(const QString& source_name); - ChannelTreeItem(const QString& source_name, const QString& channel_type, size_t total_channel_size, + ChannelTreeItem(const QString& source_name, const QString& channel_encoding, const QString& channel_type, size_t total_channel_size, double min_channel_timestamp, double max_channel_timestamp, long long expected_frames, long long existing_frames, double duration); ~ChannelTreeItem(); @@ -76,6 +77,7 @@ class ChannelTreeItem : public QAbstractTreeItem QString source_name_; QString target_name_; + QString channel_encoding_; QString channel_type_; size_t total_channel_size_; diff --git a/app/play/play_gui/src/widgets/models/channel_tree_model.cpp b/app/play/play_gui/src/widgets/models/channel_tree_model.cpp index 0be7a1cee7..42f8c1fc88 100644 --- a/app/play/play_gui/src/widgets/models/channel_tree_model.cpp +++ b/app/play/play_gui/src/widgets/models/channel_tree_model.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -237,9 +237,10 @@ void ChannelTreeModel::reload() double minTimestamp = QEcalPlay::instance()->minTimestampOfChannel(name); double maxTimestamp = QEcalPlay::instance()->maxTimestampOfChannel(name); std::string channel_type = QEcalPlay::instance()->channelType(name); + std::string channel_encoding = QEcalPlay::instance()->channelEncoding(name); size_t total_channel_size = QEcalPlay::instance()->channelCumulativeEstimatedSize(name); - ChannelTreeItem* channel_item = new ChannelTreeItem(name.c_str(), channel_type.c_str(), total_channel_size, + ChannelTreeItem* channel_item = new ChannelTreeItem(name.c_str(), channel_encoding.c_str(), channel_type.c_str(), total_channel_size, minTimestamp, maxTimestamp, expected_frames, existing_frames, duration); new_channel_list.push_back(channel_item); } diff --git a/app/play/play_gui/src/widgets/models/channel_tree_model.h b/app/play/play_gui/src/widgets/models/channel_tree_model.h index 12a62c5df4..abb06b6277 100644 --- a/app/play/play_gui/src/widgets/models/channel_tree_model.h +++ b/app/play/play_gui/src/widgets/models/channel_tree_model.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ class ChannelTreeModel : public QAbstractTreeModel { ENABLED, CHANNEL_NAME, + CHANNEL_ENCODING, CHANNEL_TYPE, TOTAL_CHANNEL_SIZE, @@ -82,6 +83,7 @@ class ChannelTreeModel : public QAbstractTreeModel { { Columns::ENABLED, ""} , { Columns::CHANNEL_NAME, "Channel" } , + { Columns::CHANNEL_ENCODING, "Channel encoding"}, { Columns::CHANNEL_TYPE, "Channel type"}, { Columns::MESSAGE_COUNTER, "Published messages" } , { Columns::TOTAL_CHANNEL_SIZE, "Total estimated channel size" } , @@ -98,6 +100,7 @@ class ChannelTreeModel : public QAbstractTreeModel { { Columns::ENABLED, (int)ChannelTreeItem::Columns::ENABLED }, { Columns::CHANNEL_NAME, (int)ChannelTreeItem::Columns::SOURCE_CHANNEL_NAME }, + { Columns::CHANNEL_ENCODING, (int)ChannelTreeItem::Columns::CHANNEL_ENCODING}, { Columns::CHANNEL_TYPE, (int)ChannelTreeItem::Columns::CHANNEL_TYPE}, { Columns::TOTAL_CHANNEL_SIZE, (int)ChannelTreeItem::Columns::TOTAL_CHANNEL_SIZE}, { Columns::MESSAGE_COUNTER, -1 }, diff --git a/app/rec/rec_client_core/CMakeLists.txt b/app/rec/rec_client_core/CMakeLists.txt index f0eda371be..0037e5ce0b 100644 --- a/app/rec/rec_client_core/CMakeLists.txt +++ b/app/rec/rec_client_core/CMakeLists.txt @@ -1,6 +1,6 @@ # ========================= eCAL LICENSE ================================= # -# Copyright (C) 2016 - 2019 Continental Corporation +# Copyright (C) 2016 - 2024 Continental Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ target_link_libraries(${PROJECT_NAME} eCAL::core_pb eCAL::app_pb PRIVATE - eCAL::measurement_hdf5 + eCAL::hdf5 ThreadingUtils Threads::Threads eCAL::ecal-utils diff --git a/app/rec/rec_client_core/src/ecal_rec.cpp b/app/rec/rec_client_core/src/ecal_rec.cpp index 87d83d1ea7..f699e2f981 100644 --- a/app/rec/rec_client_core/src/ecal_rec.cpp +++ b/app/rec/rec_client_core/src/ecal_rec.cpp @@ -36,7 +36,7 @@ namespace eCAL EcalRec::EcalRec() { - eCAL::Initialize(0, nullptr, "eCALRecClient", eCAL::Init::Default | eCAL::Init::Monitoring); + eCAL::Initialize("eCALRecClient", eCAL::Init::Default | eCAL::Init::Monitoring); eCAL::Monitoring::SetFilterState(false); recorder_ = std::make_unique(); diff --git a/app/rec/rec_client_core/src/job/hdf5_writer_thread.cpp b/app/rec/rec_client_core/src/job/hdf5_writer_thread.cpp index a84d47e3f5..10065714cb 100644 --- a/app/rec/rec_client_core/src/job/hdf5_writer_thread.cpp +++ b/app/rec/rec_client_core/src/job/hdf5_writer_thread.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ */ #include "hdf5_writer_thread.h" -#include #include "rec_client_core/ecal_rec_logger.h" @@ -42,7 +41,7 @@ namespace eCAL , new_topic_info_map_available_(true) , flushing_ (false) { - hdf5_writer_ = std::make_unique(); + hdf5_writer_ = std::make_unique(); } Hdf5WriterThread::~Hdf5WriterThread() @@ -186,7 +185,7 @@ namespace eCAL frame->data_.size(), std::chrono::duration_cast(frame->ecal_publish_time_.time_since_epoch()).count(), std::chrono::duration_cast(frame->ecal_receive_time_.time_since_epoch()).count(), - frame->topic_name_, + frame->topic_name_, frame->id_, frame->clock_ )) @@ -265,7 +264,7 @@ namespace eCAL #endif // NDEBUG std::unique_lock hdf5_writer_lock(hdf5_writer_mutex_); - if (hdf5_writer_->Open(hdf5_dir)) + if (hdf5_writer_->Open(hdf5_dir, eCAL::eh5::v2::eAccessType::CREATE)) { #ifndef NDEBUG EcalRecLogger::Instance()->debug("Hdf5WriterThread::Open(): Successfully opened HDF5-Writer with path \"" + hdf5_dir + "\""); diff --git a/app/rec/rec_client_core/src/job/hdf5_writer_thread.h b/app/rec/rec_client_core/src/job/hdf5_writer_thread.h index 042b64eeba..91e3982c42 100644 --- a/app/rec/rec_client_core/src/job/hdf5_writer_thread.h +++ b/app/rec/rec_client_core/src/job/hdf5_writer_thread.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #pragma once #include -#include +#include #include #include @@ -94,7 +94,7 @@ namespace eCAL mutable RecHdf5JobStatus last_status_; mutable std::mutex hdf5_writer_mutex_; - std::unique_ptr hdf5_writer_; + std::unique_ptr hdf5_writer_; std::atomic flushing_; diff --git a/app/rec/rec_gui/src/main.cpp b/app/rec/rec_gui/src/main.cpp index 4f4e8ff9b7..893aeb73a9 100644 --- a/app/rec/rec_gui/src/main.cpp +++ b/app/rec/rec_gui/src/main.cpp @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) } // Just make sure that eCAL is initialized - eCAL::Initialize(0, nullptr, "eCALRecGUI", eCAL::Init::Default | eCAL::Init::Service | eCAL::Init::Monitoring); + eCAL::Initialize("eCALRecGUI", eCAL::Init::Default | eCAL::Init::Service | eCAL::Init::Monitoring); eCAL::Monitoring::SetFilterState(false); EcalRecGui* w = new EcalRecGui(); diff --git a/app/rec/rec_gui/src/widgets/about_dialog/about_dialog.cpp b/app/rec/rec_gui/src/widgets/about_dialog/about_dialog.cpp index a02cfc0d66..3126a1193a 100644 --- a/app/rec/rec_gui/src/widgets/about_dialog/about_dialog.cpp +++ b/app/rec/rec_gui/src/widgets/about_dialog/about_dialog.cpp @@ -32,7 +32,7 @@ AboutDialog::AboutDialog(QWidget *parent) ui_.version_label->setText("Version: " + QString(ECAL_REC_VERSION_STRING)); ui_.ecalversion_label->setText("eCAL " + QString(ECAL_VERSION) + " (" + QString(ECAL_DATE) + ")"); - ui_.ecal_runtime_version_string_label->setText(QString(eCAL::GetVersionString()) + " (" + QString(eCAL::GetVersionDateString()) + ")"); + ui_.ecal_runtime_version_string_label->setText(QString::fromStdString(eCAL::GetVersionString()) + " (" + QString::fromStdString(eCAL::GetVersionDateString()) + ")"); ui_.ecal_compiletime_versin_string_label->setText(QString(ECAL_VERSION) + " (" + QString(ECAL_DATE) + ")"); ui_.qt_runtime_version_string_label->setText(QString(qVersion())); ui_.qt_compiletime_version_string_label->setText(QString(QT_VERSION_STR)); diff --git a/app/rec/rec_server_cli/src/ecal_rec_server_cli.cpp b/app/rec/rec_server_cli/src/ecal_rec_server_cli.cpp index cea9f6550a..099da95d24 100644 --- a/app/rec/rec_server_cli/src/ecal_rec_server_cli.cpp +++ b/app/rec/rec_server_cli/src/ecal_rec_server_cli.cpp @@ -330,14 +330,14 @@ int main(int argc, char** argv) /************************************************************************/ if (remote_control_arg.isSet()) // Remote-control-mode { - eCAL::Initialize(argc, argv, "eCALRec-Remote", eCAL::Init::All); + eCAL::Initialize("eCALRec-Remote", eCAL::Init::All); eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "Running"); remote_rec_server_service = std::make_shared>(); } else // Non-remote control mode { - eCAL::Initialize(argc, argv, "eCALRec", eCAL::Init::All); + eCAL::Initialize("eCALRec", eCAL::Init::All); rec_server_instance = std::make_shared(); diff --git a/app/rec/rec_server_core/src/rec_server_impl.cpp b/app/rec/rec_server_core/src/rec_server_impl.cpp index 30962b668d..90824dd5af 100644 --- a/app/rec/rec_server_core/src/rec_server_impl.cpp +++ b/app/rec/rec_server_core/src/rec_server_impl.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ namespace eCAL settings_.ClearHostFilter(); // There is no global host filter // Initialize eCAL - eCAL::Initialize(0, nullptr, "", eCAL::Init::Default | eCAL::Init::Monitoring); + eCAL::Initialize("", eCAL::Init::Default | eCAL::Init::Monitoring); // Start FTP Server ftp_server_->start(5); diff --git a/app/rec/rec_tests/rec_rpc_tests/src/external_ecal_rec.cpp b/app/rec/rec_tests/rec_rpc_tests/src/external_ecal_rec.cpp index a10e85d405..0c28c4a9ee 100644 --- a/app/rec/rec_tests/rec_rpc_tests/src/external_ecal_rec.cpp +++ b/app/rec/rec_tests/rec_rpc_tests/src/external_ecal_rec.cpp @@ -38,7 +38,7 @@ ExternalEcalRecInstance::ExternalEcalRecInstance(bool gui) { ecal_rec_cli_instance_lock.lock(); - eCAL::Initialize({}, "Ecal Rec Tester"); + eCAL::Initialize("Ecal Rec Tester"); remote_rec_server_service = std::make_shared>(); remote_rec_server_service->SetHostName(eCAL::Process::GetHostName()); diff --git a/app/sys/sys_cli/src/ecalsys_cli.cpp b/app/sys/sys_cli/src/ecalsys_cli.cpp index 5534dba572..8df947597f 100644 --- a/app/sys/sys_cli/src/ecalsys_cli.cpp +++ b/app/sys/sys_cli/src/ecalsys_cli.cpp @@ -237,14 +237,14 @@ int main(int argc, char** argv) /************************************************************************/ if (remote_control_arg.isSet()) // Remote-control-mode { - eCAL::Initialize(0, nullptr, "eCALSys-Remote", eCAL::Init::All); + eCAL::Initialize("eCALSys-Remote", eCAL::Init::All); eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "Running"); remote_ecalsys_service = std::make_shared>(); } else // Non-remote control mode { - eCAL::Initialize(0, nullptr, "eCALSys", eCAL::Init::All); + eCAL::Initialize("eCALSys", eCAL::Init::All); eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "Running"); ecalsys_instance = std::make_shared(); diff --git a/app/sys/sys_client_cli/src/ecal_sys_client_cli.cpp b/app/sys/sys_client_cli/src/ecal_sys_client_cli.cpp index c965f4e0e5..60d5480556 100644 --- a/app/sys/sys_client_cli/src/ecal_sys_client_cli.cpp +++ b/app/sys/sys_client_cli/src/ecal_sys_client_cli.cpp @@ -113,7 +113,7 @@ int main(int argc, char** argv) logger->info("eCAL Sys Client was started with " + accept_security_risk_arg.longID() + ". Not displaying security warning."); } - eCAL::Initialize(argc, argv, "eCALSysClient", eCAL::Init::Default | eCAL::Init::Monitoring); + eCAL::Initialize("eCALSysClient", eCAL::Init::Default | eCAL::Init::Monitoring); // Print System information std::string config_string; diff --git a/app/sys/sys_gui/src/main.cpp b/app/sys/sys_gui/src/main.cpp index 6327d8884c..88f1415137 100644 --- a/app/sys/sys_gui/src/main.cpp +++ b/app/sys/sys_gui/src/main.cpp @@ -144,7 +144,7 @@ int main(int argc, char *argv[]) ////////////////////////////////////////////////////////////////////////////// // Just make sure that eCAL is initialized - eCAL::Initialize(argc, argv, "eCALSysGUI", eCAL::Init::All); + eCAL::Initialize("eCALSysGUI", eCAL::Init::All); ////////////////////////////////////// // --config diff --git a/app/sys/sys_gui/src/widgets/about_dialog/about_dialog.cpp b/app/sys/sys_gui/src/widgets/about_dialog/about_dialog.cpp index 0cdaa04efa..0651dfb7c4 100644 --- a/app/sys/sys_gui/src/widgets/about_dialog/about_dialog.cpp +++ b/app/sys/sys_gui/src/widgets/about_dialog/about_dialog.cpp @@ -32,7 +32,7 @@ AboutDialog::AboutDialog(QWidget *parent) ui_.version_label->setText("Version: " + QString(ECAL_SYS_VERSION_STRING)); ui_.ecalversion_label->setText("eCAL " + QString(ECAL_VERSION) + " (" + QString(ECAL_DATE) + ")"); - ui_.ecal_runtime_version_string_label->setText(QString(eCAL::GetVersionString()) + " (" + QString(eCAL::GetVersionDateString()) + ")"); + ui_.ecal_runtime_version_string_label->setText(QString::fromStdString(eCAL::GetVersionString()) + " (" + QString::fromStdString(eCAL::GetVersionDateString()) + ")"); ui_.ecal_compiletime_versin_string_label->setText(QString(ECAL_VERSION) + " (" + QString(ECAL_DATE) + ")"); ui_.qt_runtime_version_string_label->setText(QString(qVersion())); ui_.qt_compiletime_version_string_label->setText(QString(QT_VERSION_STR)); diff --git a/app/util/config/src/ecal_config.cpp b/app/util/config/src/ecal_config.cpp index a5bdc4db41..bd12ace599 100644 --- a/app/util/config/src/ecal_config.cpp +++ b/app/util/config/src/ecal_config.cpp @@ -23,10 +23,10 @@ #include -int main(int argc, char** argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "eCALConfig"); + eCAL::Initialize("eCALConfig"); // print config eCAL::Process::DumpConfig(); diff --git a/app/util/launcher/src/about_dialog.cpp b/app/util/launcher/src/about_dialog.cpp index 4a1470113c..44512e3dbf 100644 --- a/app/util/launcher/src/about_dialog.cpp +++ b/app/util/launcher/src/about_dialog.cpp @@ -31,7 +31,7 @@ AboutDialog::AboutDialog(QWidget *parent) ui_.version_label->setText("Version: " + QString("2.3.0")); ui_.ecalversion_label->setText("eCAL " + QString(ECAL_VERSION) + " (" + QString(ECAL_DATE) + ")"); - ui_.ecal_runtime_version_string_label->setText(QString(eCAL::GetVersionString()) + " (" + QString(eCAL::GetVersionDateString()) + ")"); + ui_.ecal_runtime_version_string_label->setText(QString::fromStdString(eCAL::GetVersionString()) + " (" + QString::fromStdString(eCAL::GetVersionDateString()) + ")"); ui_.ecal_compiletime_versin_string_label->setText(QString(ECAL_VERSION) + " (" + QString(ECAL_DATE) + ")"); ui_.qt_runtime_version_string_label->setText(QString(qVersion())); ui_.qt_compiletime_version_string_label->setText(QString(QT_VERSION_STR)); diff --git a/app/util/stop/src/ecal_stop.cpp b/app/util/stop/src/ecal_stop.cpp index b775fe182c..3928fb5311 100644 --- a/app/util/stop/src/ecal_stop.cpp +++ b/app/util/stop/src/ecal_stop.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,10 @@ #include -int main(int argc, char** argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "eCALStop", eCAL::Init::All); + eCAL::Initialize("eCALStop", eCAL::Init::All); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "Running"); @@ -46,19 +46,37 @@ int main(int argc, char** argv) } eCAL::Process::SleepMS(500); - // shut down local user processes - std::cout << "--------------------------------------" << std::endl; - std::cout << "Shutdown local eCAL user processes." << std::endl; - std::cout << "--------------------------------------" << std::endl; - eCAL::Util::ShutdownProcesses(); - std::cout << std::endl; + eCAL::Monitoring::SMonitoring monitoring; + eCAL::Monitoring::GetMonitoring(monitoring, eCAL::Monitoring::Entity::Process); + const std::string host_name(eCAL::Process::GetHostName()); - // shut down local eCAL core - std::cout << "--------------------------------------" << std::endl; - std::cout << "Shutdown local eCAL core components." << std::endl; - std::cout << "--------------------------------------" << std::endl; - eCAL::Util::ShutdownCore(); - std::cout << std::endl; + for (const auto& process : monitoring.processes) + { + // filter out eCAL system processes + const std::string uname = process.uname; + if ( (uname != "eCALConfig") + && (uname != "eCALMon") + && (uname != "eCALMon CLI") + && (uname != "eCALMon TUI") + && (uname != "eCALPlay") + && (uname != "eCALPlayGUI") + && (uname != "eCALRec") + && (uname != "eCALRecGUI") + && (uname != "eCALRecClient") + && (uname != "eCALRec-Remote") + && (uname != "eCALRec-Server") + && (uname != "eCALSys") + && (uname != "eCALSysGUI") + && (uname != "eCALSysClient") + && (uname != "eCALSys-Remote") + && (uname != "eCALStop") + && (process.hname == host_name) + ) + { + std::cout << "Stopping process " << process.pname << " (" << process.pid << ")" << std::endl; + eCAL::Util::ShutdownProcess(process.pid); + } + } // finalize eCAL API eCAL::Finalize(); diff --git a/contrib/ecalhdf5/CMakeLists.txt b/contrib/ecalhdf5/CMakeLists.txt index d5285101c1..37b87df48f 100644 --- a/contrib/ecalhdf5/CMakeLists.txt +++ b/contrib/ecalhdf5/CMakeLists.txt @@ -1,6 +1,6 @@ # ========================= eCAL LICENSE ================================= # -# Copyright (C) 2016 - 2019 Continental Corporation +# Copyright (C) 2016 - 2024 Continental Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,7 +29,10 @@ else() endif() set(ecalhdf5_src - src/eh5_meas.cpp + src/datatype_helper.cpp + src/datatype_helper.h + src/eh5_meas_api_v2.cpp + src/eh5_meas_api_v3.cpp src/eh5_meas_dir.cpp src/eh5_meas_dir.h src/eh5_meas_file_v1.cpp @@ -42,9 +45,15 @@ set(ecalhdf5_src src/eh5_meas_file_v4.h src/eh5_meas_file_v5.cpp src/eh5_meas_file_v5.h + src/eh5_meas_file_v6.cpp + src/eh5_meas_file_v6.h src/eh5_meas_file_writer_v5.cpp src/eh5_meas_file_writer_v5.h + src/eh5_meas_file_writer_v6.cpp + src/eh5_meas_file_writer_v6.h src/eh5_meas_impl.h + src/hdf5_helper.h + src/hdf5_helper.cpp src/escape.cpp src/escape.h ) @@ -52,6 +61,8 @@ set(ecalhdf5_src set(ecalhdf5_header_base include/ecalhdf5/eh5_defs.h include/ecalhdf5/eh5_meas.h + include/ecalhdf5/eh5_meas_api_v2.h + include/ecalhdf5/eh5_meas_api_v3.h include/ecalhdf5/eh5_types.h ) @@ -67,7 +78,10 @@ target_include_directories(${PROJECT_NAME} target_compile_definitions(${PROJECT_NAME} PRIVATE - $<$:_UNICODE>) + $<$:_UNICODE> + PUBLIC + ECAL_EH5_API_VERSION=2 + ) target_compile_options(${PROJECT_NAME} PRIVATE diff --git a/contrib/ecalhdf5/include/ecalhdf5/eh5_defs.h b/contrib/ecalhdf5/include/ecalhdf5/eh5_defs.h index 3208ffc1fe..a05f6c027b 100644 --- a/contrib/ecalhdf5/include/ecalhdf5/eh5_defs.h +++ b/contrib/ecalhdf5/include/ecalhdf5/eh5_defs.h @@ -1,6 +1,6 @@ ;/* ========================= eCAL LICENSE ================================= ; * -; * Copyright (C) 2016 - 2019 Continental Corporation +; * Copyright (C) 2016 - 2024 Continental Corporation ; * ; * Licensed under the Apache License, Version 2.0 (the "License"); ; * you may not use this file except in compliance with the License. @@ -25,13 +25,13 @@ #pragma once ;/* version parsed out into numeric values */ -#define ECAL_HDF5_VERSION_MAJOR 2 //!< eCAL HDF5 major version -#define ECAL_HDF5_VERSION_MINOR 1 //!< eCAL HDF5 minor version +#define ECAL_HDF5_VERSION_MAJOR 3 //!< eCAL HDF5 major version +#define ECAL_HDF5_VERSION_MINOR 0 //!< eCAL HDF5 minor version #define ECAL_HDF5_VERSION_PATCH 0 //!< eCAL HDF5 patch version ;/* version as string */ -#define ECAL_HDF5_VERSION "v.2.1.0.20180329" //!< eCAL HDF5 version string -#define ECAL_HDF5_DATE "29.03.2018" //!< eCAL HDF5 version date +#define ECAL_HDF5_VERSION "v.3.0.0.20241203" //!< eCAL HDF5 version string +#define ECAL_HDF5_DATE "03.12.2024" //!< eCAL HDF5 version date ;/* name as string */ #define ECAL_HDF5_NAME "eCALHDF5" //!< eCAL HDF5 library name diff --git a/contrib/ecalhdf5/include/ecalhdf5/eh5_meas.h b/contrib/ecalhdf5/include/ecalhdf5/eh5_meas.h index 4b3c64df96..13e0771166 100644 --- a/contrib/ecalhdf5/include/ecalhdf5/eh5_meas.h +++ b/contrib/ecalhdf5/include/ecalhdf5/eh5_meas.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ #pragma once +#include #include #include #include @@ -31,315 +32,11 @@ #include "eh5_types.h" -namespace eCAL -{ - namespace eh5 - { - class HDF5MeasImpl; +#if defined(ECAL_EH5_NO_DEPRECATION_WARNINGS) +#define ECAL_EH5_DEPRECATE(__message__) //!< Don't print deprecation warnigns +#else +#define ECAL_EH5_DEPRECATE(__message__) [[deprecated(__message__)]] //!< Deprecate the following function +#endif - /** - * @brief eCAL HDF5 measurement API - **/ - class HDF5Meas - { - public: - /** - * @brief Constructor - **/ - HDF5Meas(); - - /** - * @brief Constructor - * - * @param path Input file path / measurement directory path (see meas directory structure description bellow, in Open method). - * @param access Access type - * - **/ - explicit HDF5Meas(const std::string& path, eAccessType access = RDONLY); - - /** - * @brief Destructor - **/ - ~HDF5Meas(); - - /** - * @brief Copy constructor deleted - **/ - HDF5Meas(const HDF5Meas& other) = delete; - /** - * @brief Move assignemnt deleted - **/ - HDF5Meas& operator=(const HDF5Meas& other) = delete; - - /** - * @brief Move constructor - **/ - HDF5Meas(HDF5Meas&&) = default; - /** - * @brief Move assignment - **/ - HDF5Meas& operator=(HDF5Meas&&) = default; - - /** - * @brief Open file - * - * @param path Input file path / measurement directory path. - * - * Default measurement directory structure: - * - root directory e.g.: M:\measurement_directory\measurement01 - * - documents directory: |_doc - * - hosts directories: |_Host1 (e.g.: CARPC01) - * |_Host2 (e.g.: CARPC02) - * - * File path as input (eAccessType::RDONLY): - * - root directory (e.g.: M:\measurement_directory\measurement01) in this case all hosts subdirectories will be iterated, - * - host directory (e.g.: M:\measurement_directory\measurement01\CARPC01), - * - file path, path to file from measurement (e.g.: M:\measurement_directory\measurement01\CARPC01\meas01_05.hdf5). - * - * File path as output (eAccessType::CREATE): - * - full path to measurement directory (recommended with host name) (e.g.: M:\measurement_directory\measurement01\CARPC01), - * - to set the name of the actual hdf5 file use SetFileBaseName method. - * - * @param access Access type - * - * @return true if output (eAccessType::CREATE) measurement directory structure can be accessed/created, false otherwise. - * true if input (eAccessType::RDONLY) measurement/file path was opened, false otherwise. - **/ - bool Open(const std::string& path, eAccessType access = RDONLY); - - /** - * @brief Close file - * - * @return true if succeeds, false if it fails - **/ - bool Close(); - - /** - * @brief Checks if file/measurement is ok - * - * @return true if meas can be opened(read) or location is accessible(write), false otherwise - **/ - bool IsOk() const; - - /** - * @brief Get the File Type Version of the current opened file - * - * @return file version - **/ - std::string GetFileVersion() const; - - /** - * @brief Gets maximum allowed size for an individual file - * - * @return maximum size in MB - **/ - size_t GetMaxSizePerFile() const; - - /** - * @brief Sets maximum allowed size for an individual file - * - * @param size maximum size in MB - **/ - void SetMaxSizePerFile(size_t size); - - /** - * @brief Whether each Channel shall be writte in its own file - * - * When enabled, data is clustered by channel and each channel is written - * to its own file. The filenames will consist of the basename and the - * channel name. - * - * @return true, if one file per channel is enabled - */ - bool IsOneFilePerChannelEnabled() const; - - /** - * @brief Enable / disable the creation of one individual file per channel - * - * When enabled, data is clustered by channel and each channel is written - * to its own file. The filenames will consist of the basename and the - * channel name. - * - * @param enabled Whether one file shall be created per channel - */ - void SetOneFilePerChannelEnabled(bool enabled); - - /** - * @brief Get the available channel names of the current opened file / measurement - * - * @return channel names - **/ - std::set GetChannelNames() const; - - /** - * @brief Check if channel exists in measurement - * - * @param channel_name name of the channel - * - * @return true if exists, false otherwise - **/ - bool HasChannel(const std::string& channel_name) const; - - /** - * @brief Get the channel description for the given channel - * - * @param channel_name channel name - * - * @return channel description - **/ - [[deprecated("Please use GetChannelDataTypeInformation instead")]] - std::string GetChannelDescription(const std::string& channel_name) const; - - /** - * @brief Set description of the given channel - * - * @param channel_name channel name - * @param description description of the channel - **/ - [[deprecated("Please use SetChannelDataTypeInformation instead")]] - void SetChannelDescription(const std::string& channel_name, const std::string& description); - - /** - * @brief Gets the channel type of the given channel - * - * @param channel_name channel name - * - * @return channel type - **/ - [[deprecated("Please use GetChannelDataTypeInformation instead")]] - std::string GetChannelType(const std::string& channel_name) const; - - /** - * @brief Set type of the given channel - * - * @param channel_name channel name - * @param type type of the channel - **/ - [[deprecated("Please use SetChannelDataTypeInformation instead")]] - void SetChannelType(const std::string& channel_name, const std::string& type); - - /** - * @brief Get data type information of the given channel - * - * @param channel_name channel name - * - * @return channel type - **/ - DataTypeInformation GetChannelDataTypeInformation(const std::string& channel_name) const; - - /** - * @brief Set data type information of the given channel - * - * @param channel_name channel name - * @param info datatype info of the channel - * - * @return channel type - **/ - void SetChannelDataTypeInformation(const std::string& channel_name, const DataTypeInformation& info); - - /** - * @brief Gets minimum timestamp for specified channel - * - * @param channel_name channel name - * - * @return minimum timestamp value - **/ - long long GetMinTimestamp(const std::string& channel_name) const; - - /** - * @brief Gets maximum timestamp for specified channel - * - * @param channel_name channel name - * - * @return maximum timestamp value - **/ - long long GetMaxTimestamp(const std::string& channel_name) const; - - /** - * @brief Gets the header info for all data entries for the given channel - * Header = timestamp + entry id - * - * @param [in] channel_name channel name - * @param [out] entries header info for all data entries - * - * @return true if succeeds, false if it fails - **/ - bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const; - - /** - * @brief Gets the header info for data entries for the given channel included in given time range (begin->end) - * Header = timestamp + entry id - * - * @param [in] channel_name channel name - * @param [in] begin time range begin timestamp - * @param [in] end time range end timestamp - * @param [out] entries header info for data entries in given range - * - * @return true if succeeds, false if it fails - **/ - bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const; - - /** - * @brief Gets data size of a specific entry - * - * @param [in] entry_id Entry ID - * @param [out] size Entry data size - * - * @return true if succeeds, false if it fails - **/ - bool GetEntryDataSize(long long entry_id, size_t& size) const; - - /** - * @brief Gets data from a specific entry - * - * @param [in] entry_id Entry ID - * @param [out] data Entry data - * - * @return true if succeeds, false if it fails - **/ - bool GetEntryData(long long entry_id, void* data) const; - - /** - * @brief Set measurement file base name (desired name for the actual hdf5 files that will be created) - * - * @param base_name Name of the hdf5 files that will be created. - **/ - void SetFileBaseName(const std::string& base_name); - - /** - * @brief Add entry to file - * - * @param data data to be added - * @param size size of the data - * @param snd_timestamp send time stamp - * @param rcv_timestamp receive time stamp - * @param channel_name channel name - * @param id message id - * @param clock message clock - * - * @return true if succeeds, false if it fails - **/ - bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock); - - /** - * @brief Callback function type for pre file split notification - **/ - typedef std::function CallbackFunction; - - /** - * @brief Connect callback for pre file split notification - * - * @param cb callback function - **/ - void ConnectPreSplitCallback(CallbackFunction cb); - - /** - * @brief Disconnect pre file split callback - **/ - void DisconnectPreSplitCallback(); - - private: - std::unique_ptr hdf_meas_impl_; - }; - } // namespace eh5 -} // namespace eCAL +#include "eh5_meas_api_v2.h" +#include "eh5_meas_api_v3.h" diff --git a/contrib/ecalhdf5/include/ecalhdf5/eh5_meas_api_v2.h b/contrib/ecalhdf5/include/ecalhdf5/eh5_meas_api_v2.h new file mode 100644 index 0000000000..ccba86ad64 --- /dev/null +++ b/contrib/ecalhdf5/include/ecalhdf5/eh5_meas_api_v2.h @@ -0,0 +1,351 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +/** + * @file eh5_meas.h + * @brief eCALHDF5 measurement class +**/ + +#pragma once + +#include +#include +#include +#include +#include + +#include "eh5_types.h" + +namespace eCAL +{ + namespace eh5 + { + inline namespace v3 + { + class HDF5Meas; + } + + namespace v2 + { + /** + * @brief eCAL HDF5 measurement API + **/ + class HDF5Meas + { + public: + /** + * @brief Constructor + **/ + HDF5Meas(); + + /** + * @brief Constructor + * + * @param path Input file path / measurement directory path (see meas directory structure description bellow, in Open method). + * @param access Access type + * + **/ + explicit HDF5Meas(const std::string& path, eAccessType access = RDONLY); + + /** + * @brief Destructor + **/ + ~HDF5Meas(); + + /** + * @brief Copy constructor deleted + **/ + HDF5Meas(const HDF5Meas& other) = delete; + /** + * @brief Move assignemnt deleted + **/ + HDF5Meas& operator=(const HDF5Meas& other) = delete; + + /** + * @brief Move constructor + **/ + HDF5Meas(HDF5Meas&&) = default; + /** + * @brief Move assignment + **/ + HDF5Meas& operator=(HDF5Meas&&) = default; + + /** + * @brief Open file + * + * @param path Input file path / measurement directory path. + * + * Default measurement directory structure: + * - root directory e.g.: M:\measurement_directory\measurement01 + * - documents directory: |_doc + * - hosts directories: |_Host1 (e.g.: CARPC01) + * |_Host2 (e.g.: CARPC02) + * + * File path as input (eAccessType::RDONLY): + * - root directory (e.g.: M:\measurement_directory\measurement01) in this case all hosts subdirectories will be iterated, + * - host directory (e.g.: M:\measurement_directory\measurement01\CARPC01), + * - file path, path to file from measurement (e.g.: M:\measurement_directory\measurement01\CARPC01\meas01_05.hdf5). + * + * File path as output (eAccessType::CREATE): + * - full path to measurement directory (recommended with host name) (e.g.: M:\measurement_directory\measurement01\CARPC01), + * - to set the name of the actual hdf5 file use SetFileBaseName method. + * + * @param access Access type + * + * @return true if output (eAccessType::CREATE) measurement directory structure can be accessed/created, false otherwise. + * true if input (eAccessType::RDONLY) measurement/file path was opened, false otherwise. + **/ + bool Open(const std::string& path, eAccessType access = RDONLY); + + /** + * @brief Close file + * + * @return true if succeeds, false if it fails + **/ + bool Close(); + + /** + * @brief Checks if file/measurement is ok + * + * @return true if meas can be opened(read) or location is accessible(write), false otherwise + **/ + bool IsOk() const; + + /** + * @brief Get the File Type Version of the current opened file + * + * @return file version + **/ + std::string GetFileVersion() const; + + /** + * @brief Gets maximum allowed size for an individual file + * + * @return maximum size in MB + **/ + size_t GetMaxSizePerFile() const; + + /** + * @brief Sets maximum allowed size for an individual file + * + * @param size maximum size in MB + **/ + void SetMaxSizePerFile(size_t size); + + /** + * @brief Whether each Channel shall be writte in its own file + * + * When enabled, data is clustered by channel and each channel is written + * to its own file. The filenames will consist of the basename and the + * channel name. + * + * @return true, if one file per channel is enabled + */ + bool IsOneFilePerChannelEnabled() const; + + /** + * @brief Enable / disable the creation of one individual file per channel + * + * When enabled, data is clustered by channel and each channel is written + * to its own file. The filenames will consist of the basename and the + * channel name. + * + * @param enabled Whether one file shall be created per channel + */ + void SetOneFilePerChannelEnabled(bool enabled); + + /** + * @brief Get the available channel names of the current opened file / measurement + * + * @return channel names + **/ + std::set GetChannelNames() const; + + /** + * @brief Check if channel exists in measurement + * + * @param channel_name name of the channel + * + * @return true if exists, false otherwise + **/ + bool HasChannel(const std::string& channel_name) const; + + /** + * @brief Get the channel description for the given channel + * + * @param channel_name channel name + * + * @return channel description + **/ + std::string GetChannelDescription(const std::string& channel_name) const; + + /** + * @brief Set description of the given channel + * + * @param channel_name channel name + * @param description description of the channel + **/ + void SetChannelDescription(const std::string& channel_name, const std::string& description); + + /** + * @brief Gets the channel type of the given channel + * + * @param channel_name channel name + * + * @return channel type + **/ + std::string GetChannelType(const std::string& channel_name) const; + + /** + * @brief Set type of the given channel + * + * @param channel_name channel name + * @param type type of the channel + **/ + void SetChannelType(const std::string& channel_name, const std::string& type); + + /** + * @brief Get data type information of the given channel + * + * @param channel_name channel name + * + * @return channel type + **/ + DataTypeInformation GetChannelDataTypeInformation(const std::string& channel_name) const; + + /** + * @brief Set data type information of the given channel + * + * @param channel_name channel name + * @param info datatype info of the channel + * + * @return channel type + **/ + void SetChannelDataTypeInformation(const std::string& channel_name, const DataTypeInformation& info); + + /** + * @brief Gets minimum timestamp for specified channel + * + * @param channel_name channel name + * + * @return minimum timestamp value + **/ + long long GetMinTimestamp(const std::string& channel_name) const; + + /** + * @brief Gets maximum timestamp for specified channel + * + * @param channel_name channel name + * + * @return maximum timestamp value + **/ + long long GetMaxTimestamp(const std::string& channel_name) const; + + /** + * @brief Gets the header info for all data entries for the given channel + * Header = timestamp + entry id + * + * @param [in] channel_name channel name + * @param [out] entries header info for all data entries + * + * @return true if succeeds, false if it fails + **/ + bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const; + + /** + * @brief Gets the header info for data entries for the given channel included in given time range (begin->end) + * Header = timestamp + entry id + * + * @param [in] channel_name channel name + * @param [in] begin time range begin timestamp + * @param [in] end time range end timestamp + * @param [out] entries header info for data entries in given range + * + * @return true if succeeds, false if it fails + **/ + bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const; + + /** + * @brief Gets data size of a specific entry + * + * @param [in] entry_id Entry ID + * @param [out] size Entry data size + * + * @return true if succeeds, false if it fails + **/ + bool GetEntryDataSize(long long entry_id, size_t& size) const; + + /** + * @brief Gets data from a specific entry + * + * @param [in] entry_id Entry ID + * @param [out] data Entry data + * + * @return true if succeeds, false if it fails + **/ + bool GetEntryData(long long entry_id, void* data) const; + + /** + * @brief Set measurement file base name (desired name for the actual hdf5 files that will be created) + * + * @param base_name Name of the hdf5 files that will be created. + **/ + void SetFileBaseName(const std::string& base_name); + + /** + * @brief Add entry to file + * + * @param data data to be added + * @param size size of the data + * @param snd_timestamp send time stamp + * @param rcv_timestamp receive time stamp + * @param channel_name channel name + * @param id message id + * @param clock message clock + * + * @return true if succeeds, false if it fails + **/ + bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock); + + /** + * @brief Callback function type for pre file split notification + **/ + typedef std::function CallbackFunction; + + /** + * @brief Connect callback for pre file split notification + * + * @param cb callback function + **/ + void ConnectPreSplitCallback(CallbackFunction cb); + + /** + * @brief Disconnect pre file split callback + **/ + void DisconnectPreSplitCallback(); + + private: + std::unique_ptr hdf_meas_impl_; + // this map saves all datatype infos that have been set, so that the api can still + // support setting type and descriptor separately + std::map data_type_info_map; + }; + } // namespace v1 + } // namespace eh5 +} // namespace eCAL diff --git a/contrib/ecalhdf5/include/ecalhdf5/eh5_meas_api_v3.h b/contrib/ecalhdf5/include/ecalhdf5/eh5_meas_api_v3.h new file mode 100644 index 0000000000..80ec6a6ee0 --- /dev/null +++ b/contrib/ecalhdf5/include/ecalhdf5/eh5_meas_api_v3.h @@ -0,0 +1,312 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +/** + * @file eh5_meas.h + * @brief eCALHDF5 measurement class +**/ + +#pragma once + +#include +#include +#include +#include +#include + +#include "eh5_types.h" + + +namespace eCAL +{ + namespace eh5 + { + class HDF5MeasImpl; + + inline namespace v3{ + + /** + * @brief eCAL HDF5 measurement API + **/ + class HDF5Meas + { + public: + /** + * @brief Constructor + **/ + HDF5Meas(); + + /** + * @brief Constructor + * + * @param path Input file path / measurement directory path (see meas directory structure description bellow, in Open method). + * @param access Access type + * + **/ + explicit HDF5Meas(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY); + + /** + * @brief Destructor + **/ + ~HDF5Meas(); + + /** + * @brief Copy constructor deleted + **/ + HDF5Meas(const HDF5Meas& other) = delete; + /** + * @brief Move assignemnt deleted + **/ + HDF5Meas& operator=(const HDF5Meas& other) = delete; + + /** + * @brief Move constructor + **/ + HDF5Meas(HDF5Meas&&) = default; + /** + * @brief Move assignment + **/ + HDF5Meas& operator=(HDF5Meas&&) = default; + + /** + * @brief Open file + * + * @param path Input file path / measurement directory path. + * + * Default measurement directory structure: + * - root directory e.g.: M:\measurement_directory\measurement01 + * - documents directory: |_doc + * - hosts directories: |_Host1 (e.g.: CARPC01) + * |_Host2 (e.g.: CARPC02) + * + * File path as input (eAccessType::RDONLY): + * - root directory (e.g.: M:\measurement_directory\measurement01) in this case all hosts subdirectories will be iterated, + * - host directory (e.g.: M:\measurement_directory\measurement01\CARPC01), + * - file path, path to file from measurement (e.g.: M:\measurement_directory\measurement01\CARPC01\meas01_05.hdf5). + * + * File path as output (eAccessType::CREATE): + * - full path to measurement directory (recommended with host name) (e.g.: M:\measurement_directory\measurement01\CARPC01), + * - to set the name of the actual hdf5 file use SetFileBaseName method. + * + * @param access Access type + * + * @return true if output (eAccessType::CREATE) measurement directory structure can be accessed/created, false otherwise. + * true if input (eAccessType::RDONLY) measurement/file path was opened, false otherwise. + **/ + bool Open(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY); + + /** + * @brief Close file + * + * @return true if succeeds, false if it fails + **/ + bool Close(); + + /** + * @brief Checks if file/measurement is ok + * + * @return true if meas can be opened(read) or location is accessible(write), false otherwise + **/ + bool IsOk() const; + + /** + * @brief Get the File Type Version of the current opened file + * + * @return file version + **/ + std::string GetFileVersion() const; + + /** + * @brief Gets maximum allowed size for an individual file + * + * @return maximum size in MB + **/ + size_t GetMaxSizePerFile() const; + + /** + * @brief Sets maximum allowed size for an individual file + * + * @param size maximum size in MB + **/ + void SetMaxSizePerFile(size_t size); + + /** + * @brief Whether each Channel shall be writte in its own file + * + * When enabled, data is clustered by channel and each channel is written + * to its own file. The filenames will consist of the basename and the + * channel name. + * + * @return true, if one file per channel is enabled + */ + bool IsOneFilePerChannelEnabled() const; + + /** + * @brief Enable / disable the creation of one individual file per channel + * + * When enabled, data is clustered by channel and each channel is written + * to its own file. The filenames will consist of the basename and the + * channel name. + * + * @param enabled Whether one file shall be created per channel + */ + void SetOneFilePerChannelEnabled(bool enabled); + + /** + * @brief Get the available channel names of the current opened file / measurement + * + * @return Channels (channel name & id) + **/ + std::set GetChannels() const; + + /** + * @brief Check if channel exists in measurement + * + * @param channel channel name & id + * + * @return true if exists, false otherwise + **/ + bool HasChannel(const eCAL::eh5::SChannel& channel) const; + + /** + * @brief Get data type information of the given channel + * + * @param channel_name channel name + * + * @return channel type + **/ + DataTypeInformation GetChannelDataTypeInformation(const SChannel& channel) const; + + /** + * @brief Set data type information of the given channel + * + * @param channel_name channel name + * @param info datatype info of the channel + * + * @return channel type + **/ + void SetChannelDataTypeInformation(const SChannel& channel, const DataTypeInformation& info); + + /** + * @brief Gets minimum timestamp for specified channel + * + * @param channel channel (name & id) + * + * @return minimum timestamp value + **/ + long long GetMinTimestamp(const SChannel& channel) const; + + /** + * @brief Gets maximum timestamp for specified channel + * + * @param channel channel (name & id) + * + * @return maximum timestamp value + **/ + long long GetMaxTimestamp(const SChannel& channel) const; + + /** + * @brief Gets the header info for all data entries for the given channel + * Header = timestamp + entry id + * + * @param [in] channel channel (name & id) + * @param [out] entries header info for all data entries + * + * @return true if succeeds, false if it fails + **/ + bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const; + + /** + * @brief Gets the header info for data entries for the given channel included in given time range (begin->end) + * Header = timestamp + entry id + * + * @param [in] channel channel (name & id) + * @param [in] begin time range begin timestamp + * @param [in] end time range end timestamp + * @param [out] entries header info for data entries in given range + * + * @return true if succeeds, false if it fails + **/ + bool GetEntriesInfoRange(const SChannel& channel, long long begin, long long end, EntryInfoSet& entries) const; + + /** + * @brief Gets data size of a specific entry + * + * @param [in] entry_id Entry ID + * @param [out] size Entry data size + * + * @return true if succeeds, false if it fails + **/ + bool GetEntryDataSize(long long entry_id, size_t& size) const; + + /** + * @brief Gets data from a specific entry + * + * @param [in] entry_id Entry ID + * @param [out] data Entry data + * + * @return true if succeeds, false if it fails + **/ + bool GetEntryData(long long entry_id, void* data) const; + + /** + * @brief Set measurement file base name (desired name for the actual hdf5 files that will be created) + * + * @param base_name Name of the hdf5 files that will be created. + **/ + void SetFileBaseName(const std::string& base_name); + + /** + * @brief Add entry to file + * + * @param data data to be added + * @param size size of the data + * @param snd_timestamp send time stamp + * @param rcv_timestamp receive time stamp + * @param channel channel channel (name & id) + * @param id message id + * @param clock message clock + * + * @return true if succeeds, false if it fails + **/ + bool AddEntryToFile(const SWriteEntry& entry); + + /** + * @brief Callback function type for pre file split notification + **/ + typedef std::function CallbackFunction; + + /** + * @brief Connect callback for pre file split notification + * + * @param cb callback function + **/ + void ConnectPreSplitCallback(CallbackFunction cb); + + /** + * @brief Disconnect pre file split callback + **/ + void DisconnectPreSplitCallback(); + + private: + std::unique_ptr hdf_meas_impl_; + }; + } + } // namespace eh5 +} // namespace eCAL diff --git a/contrib/ecalhdf5/include/ecalhdf5/eh5_types.h b/contrib/ecalhdf5/include/ecalhdf5/eh5_types.h index 91351e56b5..1ec43591fa 100644 --- a/contrib/ecalhdf5/include/ecalhdf5/eh5_types.h +++ b/contrib/ecalhdf5/include/ecalhdf5/eh5_types.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,18 +38,40 @@ namespace eCAL const std::string kChnNameAttribTitle ("Channel Name"); const std::string kChnDescAttrTitle ("Channel Description"); const std::string kChnTypeAttrTitle ("Channel Type"); + const std::string kChnIdTypename ("TypeName"); + const std::string kChnIdEncoding ("TypeEncoding"); + const std::string kChnIdDescriptor ("TypeDescriptor"); + const std::string kChnIdData ("DataTable"); const std::string kFileVerAttrTitle ("Version"); const std::string kTimestampAttrTitle ("Timestamps"); const std::string kChnAttrTitle ("Channels"); // Remove @eCAL6 -> backwards compatibility with old interface! + using SChannel = eCAL::experimental::measurement::base::Channel; using SEntryInfo = eCAL::experimental::measurement::base::EntryInfo; using EntryInfoSet = eCAL::experimental::measurement::base::EntryInfoSet; using EntryInfoVect = eCAL::experimental::measurement::base::EntryInfoVect; - using eAccessType = eCAL::experimental::measurement::base::AccessType; - using eCAL::experimental::measurement::base::RDONLY; - using eCAL::experimental::measurement::base::CREATE; - + using SWriteEntry = eCAL::experimental::measurement::base::WriteEntry; + + namespace v2 + { + enum eAccessType + { + RDONLY, //!< ReadOnly - the measurement can only be read + CREATE, //!< Create - a new measurement will be created + }; + } + + inline namespace v3 + { + enum class eAccessType + { + RDONLY, //!< ReadOnly - the measurement can only be read + CREATE, //!< Create - a new measurement will be created + CREATE_V5 //!< Create a legacy V5 hdf5 measurement (For testing purpose only!) + }; + } + using eCAL::experimental::measurement::base::DataTypeInformation; //!< @endcond } // namespace eh5 diff --git a/contrib/ecalhdf5/src/datatype_helper.cpp b/contrib/ecalhdf5/src/datatype_helper.cpp new file mode 100644 index 0000000000..63d5a8fb0a --- /dev/null +++ b/contrib/ecalhdf5/src/datatype_helper.cpp @@ -0,0 +1,60 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +#include "datatype_helper.h" + +namespace eCAL +{ + namespace eh5 + { + DataTypeInformation CreateInfo(const std::string& combined_topic_type_, const std::string& descriptor_) + { + eCAL::eh5::DataTypeInformation info; + auto pos = combined_topic_type_.find(':'); + if (pos == std::string::npos) + { + info.name = combined_topic_type_; + info.encoding = ""; + } + else + { + info.name = combined_topic_type_.substr(pos + 1); + info.encoding = combined_topic_type_.substr(0, pos); + } + info.descriptor = descriptor_; + return info; + } + + std::pair FromInfo(const eCAL::eh5::DataTypeInformation& datatype_info_) + { + std::string combined_topic_type; + if (datatype_info_.encoding.empty()) + { + combined_topic_type = datatype_info_.name; + } + else + { + combined_topic_type = datatype_info_.encoding + ":" + datatype_info_.name; + } + + return std::make_pair(combined_topic_type, datatype_info_.descriptor); + } + + } +} \ No newline at end of file diff --git a/contrib/ecalhdf5/src/datatype_helper.h b/contrib/ecalhdf5/src/datatype_helper.h new file mode 100644 index 0000000000..cb1a1e3d03 --- /dev/null +++ b/contrib/ecalhdf5/src/datatype_helper.h @@ -0,0 +1,34 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +#pragma once + +#include +#include +#include + + +namespace eCAL +{ + namespace eh5 + { + DataTypeInformation CreateInfo(const std::string& combined_topic_type_, const std::string& descriptor_); + std::pair FromInfo(const DataTypeInformation& datatype_info_); + } +} \ No newline at end of file diff --git a/contrib/ecalhdf5/src/eh5_meas_api_v2.cpp b/contrib/ecalhdf5/src/eh5_meas_api_v2.cpp new file mode 100644 index 0000000000..6f699a716b --- /dev/null +++ b/contrib/ecalhdf5/src/eh5_meas_api_v2.cpp @@ -0,0 +1,283 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +/** + * @brief eCALHDF5 measurement class +**/ + +#include + +#include + +#include +#include "datatype_helper.h" + + +namespace { + using namespace eCAL::eh5; + + v3::eAccessType convert(v2::eAccessType v2_access) + { + switch (v2_access) + { + case v2::RDONLY: + return v3::eAccessType::RDONLY; + case v2::CREATE: + return v3::eAccessType::CREATE_V5; + default: + return v3::eAccessType::RDONLY; + } + } + + SChannel createChannel(const std::string& channel_name) + { + return SChannel(channel_name, 0); + } + + + std::set GetChannelsWithName(const std::unique_ptr& hdf_meas_impl_, const std::string& channel_name) + { + const auto all_channels = hdf_meas_impl_->GetChannels(); + std::set named_channels; + for (const auto& channel : all_channels) + { + if (channel.name == channel_name) + { + named_channels.insert(channel); + } + } + return named_channels; + } +} + +using namespace eCAL::eh5::v2; + +eCAL::eh5::v2::HDF5Meas::HDF5Meas() +: hdf_meas_impl_(std::make_unique()) +{} + +// TODO restrict to V5 due to API +eCAL::eh5::v2::HDF5Meas::HDF5Meas(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) +: hdf_meas_impl_(std::make_unique(path, convert(access))) +{} + +eCAL::eh5::v2::HDF5Meas::~HDF5Meas() += default; + +bool eCAL::eh5::v2::HDF5Meas::Open(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) +{ + return hdf_meas_impl_->Open(path, convert(access)); +} + +bool eCAL::eh5::v2::HDF5Meas::Close() +{ + return hdf_meas_impl_->Close(); +} + +bool eCAL::eh5::v2::HDF5Meas::IsOk() const +{ + return hdf_meas_impl_->IsOk(); +} + +std::string eCAL::eh5::v2::HDF5Meas::GetFileVersion() const +{ + return hdf_meas_impl_->GetFileVersion(); +} + +size_t eCAL::eh5::v2::HDF5Meas::GetMaxSizePerFile() const +{ + return hdf_meas_impl_->GetMaxSizePerFile(); +} + +void eCAL::eh5::v2::HDF5Meas::SetMaxSizePerFile(size_t size) +{ + return hdf_meas_impl_->SetMaxSizePerFile(size); +} + +bool eCAL::eh5::v2::HDF5Meas::IsOneFilePerChannelEnabled() const +{ + return hdf_meas_impl_->IsOneFilePerChannelEnabled(); +} + +void eCAL::eh5::v2::HDF5Meas::SetOneFilePerChannelEnabled(bool enabled) +{ + return hdf_meas_impl_->SetOneFilePerChannelEnabled(enabled); +} + +std::set eCAL::eh5::v2::HDF5Meas::GetChannelNames() const +{ + auto channels = hdf_meas_impl_->GetChannels(); + std::set channel_names; + for (const auto& channel : channels) { + channel_names.insert(channel.name); + } + return channel_names; +} + +bool eCAL::eh5::v2::HDF5Meas::HasChannel(const std::string& channel_name) const +{ + auto named_channels = GetChannelsWithName(hdf_meas_impl_, channel_name); + bool has_channel = false; + for (const auto& channel : named_channels) + { + has_channel |= hdf_meas_impl_->HasChannel(channel); + } + return has_channel; +} + +std::string eCAL::eh5::v2::HDF5Meas::GetChannelDescription(const std::string& channel_name) const +{ + auto datatype_info = GetChannelDataTypeInformation(channel_name); + return datatype_info.descriptor; +} + +void eCAL::eh5::v2::HDF5Meas::SetChannelDescription(const std::string& channel_name, const std::string& description) +{ + const auto& channel = createChannel(channel_name); + auto& current_info = data_type_info_map[channel_name]; + current_info.descriptor = description; + hdf_meas_impl_->SetChannelDataTypeInformation(channel, current_info); +} + +std::string eCAL::eh5::v2::HDF5Meas::GetChannelType(const std::string& channel_name) const +{ + std::string ret_val; + auto datatype_info = GetChannelDataTypeInformation(channel_name); + std::tie(ret_val, std::ignore) = FromInfo(datatype_info); + return ret_val; +} + +void eCAL::eh5::v2::HDF5Meas::SetChannelType(const std::string& channel_name, const std::string& type) +{ + const auto& channel = createChannel(channel_name); + auto& current_info = data_type_info_map[channel_name]; + current_info = CreateInfo(type, current_info.descriptor); + hdf_meas_impl_->SetChannelDataTypeInformation(channel, current_info); +} + +// This function "has" to loose information if there are multople channels in the measurement with the same name +eCAL::eh5::DataTypeInformation eCAL::eh5::v2::HDF5Meas::GetChannelDataTypeInformation(const std::string& channel_name) const +{ + auto named_channels = GetChannelsWithName(hdf_meas_impl_, channel_name); + if (named_channels.size() > 0) + { + return hdf_meas_impl_->GetChannelDataTypeInformation(*named_channels.begin()); + } + return DataTypeInformation{}; +} + +void eCAL::eh5::v2::HDF5Meas::SetChannelDataTypeInformation(const std::string& channel_name, const eCAL::eh5::DataTypeInformation& info) +{ + data_type_info_map[channel_name] = info; + return hdf_meas_impl_->SetChannelDataTypeInformation(createChannel(channel_name), info); +} + +long long eCAL::eh5::v2::HDF5Meas::GetMinTimestamp(const std::string& channel_name) const +{ + auto named_channels = GetChannelsWithName(hdf_meas_impl_, channel_name); + long long min_timestamp = std::numeric_limits::max(); + for (const auto& channel : named_channels) + { + min_timestamp = std::min(min_timestamp, hdf_meas_impl_->GetMinTimestamp(channel)); + } + if (min_timestamp == std::numeric_limits::max()) + return 0; // the old API would return 0 in this case + return min_timestamp; +} + +long long eCAL::eh5::v2::HDF5Meas::GetMaxTimestamp(const std::string& channel_name) const +{ + auto named_channels = GetChannelsWithName(hdf_meas_impl_, channel_name); + long long max_timestamp = std::numeric_limits::min(); + for (const auto& channel : named_channels) + { + max_timestamp = std::max(max_timestamp, hdf_meas_impl_->GetMaxTimestamp(channel)); + } + if (max_timestamp == std::numeric_limits::min()) + return 0; // the old API would return 0 in this case + return max_timestamp; +} + +bool eCAL::eh5::v2::HDF5Meas::GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const +{ + // we need to aggregate info from all channels within the measurement with a given name. + auto named_channels = GetChannelsWithName(hdf_meas_impl_, channel_name); + entries.clear(); + bool ret_value{ true }; + for (const auto& channel : named_channels) + { + EntryInfoSet channel_entries; + ret_value &= hdf_meas_impl_->GetEntriesInfo(channel, channel_entries); + entries.insert(channel_entries.begin(), channel_entries.end()); + } + return ret_value; +} + +bool eCAL::eh5::v2::HDF5Meas::GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const +{ + // we need to aggregate info from all channels within the measurement with a given name. + auto named_channels = GetChannelsWithName(hdf_meas_impl_, channel_name); + entries.clear(); + bool ret_value{ true }; + for (const auto& channel : named_channels) + { + EntryInfoSet channel_entries; + ret_value &= hdf_meas_impl_->GetEntriesInfoRange(channel, begin, end, channel_entries); + entries.insert(channel_entries.begin(), channel_entries.end()); + } + return ret_value; +} + +bool eCAL::eh5::v2::HDF5Meas::GetEntryDataSize(long long entry_id, size_t& size) const +{ + return hdf_meas_impl_->GetEntryDataSize(entry_id, size); +} + +bool eCAL::eh5::v2::HDF5Meas::GetEntryData(long long entry_id, void* data) const +{ + return hdf_meas_impl_->GetEntryData(entry_id, data); +} + +void eCAL::eh5::v2::HDF5Meas::SetFileBaseName(const std::string& base_name) +{ + return hdf_meas_impl_->SetFileBaseName(base_name); +} + +bool eCAL::eh5::v2::HDF5Meas::AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) +{ + SWriteEntry entry; + entry.channel = createChannel(channel_name); + entry.data = data; + entry.size = size; + entry.snd_timestamp = snd_timestamp; + entry.rcv_timestamp = rcv_timestamp; + entry.sender_id = id; + entry.clock = clock; + return hdf_meas_impl_->AddEntryToFile(entry); +} + +void eCAL::eh5::v2::HDF5Meas::ConnectPreSplitCallback(CallbackFunction cb) +{ + return hdf_meas_impl_->ConnectPreSplitCallback(std::move(cb)); +} + +void eCAL::eh5::v2::HDF5Meas::DisconnectPreSplitCallback() +{ + return hdf_meas_impl_->DisconnectPreSplitCallback(); +} diff --git a/contrib/ecalhdf5/src/eh5_meas.cpp b/contrib/ecalhdf5/src/eh5_meas_api_v3.cpp similarity index 58% rename from contrib/ecalhdf5/src/eh5_meas.cpp rename to contrib/ecalhdf5/src/eh5_meas_api_v3.cpp index 28419814ce..8feff22ff5 100644 --- a/contrib/ecalhdf5/src/eh5_meas.cpp +++ b/contrib/ecalhdf5/src/eh5_meas_api_v3.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +21,12 @@ * @brief eCALHDF5 measurement class **/ -#include +#include #include +#include +#include #include #include "eh5_meas_dir.h" @@ -33,33 +35,36 @@ #include "eh5_meas_file_v3.h" #include "eh5_meas_file_v4.h" #include "eh5_meas_file_v5.h" +#include "eh5_meas_file_v6.h" #include "escape.h" namespace { - const double file_version_max(5.0); + const double file_version_max(6.0); } -eCAL::eh5::HDF5Meas::HDF5Meas() +using namespace eCAL::eh5::v3; + +eCAL::eh5::v3::HDF5Meas::HDF5Meas() = default; -eCAL::eh5::HDF5Meas::HDF5Meas(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) +eCAL::eh5::v3::HDF5Meas::HDF5Meas(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) { Open(path, access); } -eCAL::eh5::HDF5Meas::~HDF5Meas() +eCAL::eh5::v3::HDF5Meas::~HDF5Meas() = default; -bool eCAL::eh5::HDF5Meas::Open(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) +bool eCAL::eh5::v3::HDF5Meas::Open(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) { if (hdf_meas_impl_) { Close(); } - if (access == eAccessType::CREATE) + if (access == eAccessType::CREATE || access == eAccessType::CREATE_V5) { EcalUtils::Filesystem::MkPath(path, EcalUtils::Filesystem::OsStyle::Current); } @@ -75,7 +80,7 @@ bool eCAL::eh5::HDF5Meas::Open(const std::string& path, eAccessType access /*= e } case EcalUtils::Filesystem::RegularFile: { - hdf_meas_impl_ = std::make_unique(path, access); + hdf_meas_impl_ = std::make_unique(path, access); if (!hdf_meas_impl_->IsOk()) { @@ -120,6 +125,10 @@ bool eCAL::eh5::HDF5Meas::Open(const std::string& path, eAccessType access /*= e { hdf_meas_impl_ = std::make_unique(path, access); } + else if (file_version_numeric >= 5.0 && file_version_numeric < 6.0) + { + hdf_meas_impl_ = std::make_unique(path, access); + } } break; case EcalUtils::Filesystem::Unknown: @@ -128,7 +137,7 @@ bool eCAL::eh5::HDF5Meas::Open(const std::string& path, eAccessType access /*= e break; } - if (access == eAccessType::CREATE) + if (access == eAccessType::CREATE || access == eAccessType::CREATE_V5) { return hdf_meas_impl_ ? EcalUtils::Filesystem::IsDir(path, EcalUtils::Filesystem::OsStyle::Current) : false; } @@ -138,7 +147,7 @@ bool eCAL::eh5::HDF5Meas::Open(const std::string& path, eAccessType access /*= e } } -bool eCAL::eh5::HDF5Meas::Close() +bool eCAL::eh5::v3::HDF5Meas::Close() { bool ret_val = false; if (hdf_meas_impl_) @@ -149,7 +158,7 @@ bool eCAL::eh5::HDF5Meas::Close() return ret_val; } -bool eCAL::eh5::HDF5Meas::IsOk() const +bool eCAL::eh5::v3::HDF5Meas::IsOk() const { bool ret_val = false; if (hdf_meas_impl_) @@ -160,7 +169,7 @@ bool eCAL::eh5::HDF5Meas::IsOk() const return ret_val; } -std::string eCAL::eh5::HDF5Meas::GetFileVersion() const +std::string eCAL::eh5::v3::HDF5Meas::GetFileVersion() const { std::string ret_val; if (hdf_meas_impl_) @@ -171,7 +180,7 @@ std::string eCAL::eh5::HDF5Meas::GetFileVersion() const return ret_val; } -size_t eCAL::eh5::HDF5Meas::GetMaxSizePerFile() const +size_t eCAL::eh5::v3::HDF5Meas::GetMaxSizePerFile() const { size_t ret_val = 0; if (hdf_meas_impl_) @@ -182,7 +191,7 @@ size_t eCAL::eh5::HDF5Meas::GetMaxSizePerFile() const return ret_val; } -void eCAL::eh5::HDF5Meas::SetMaxSizePerFile(size_t size) +void eCAL::eh5::v3::HDF5Meas::SetMaxSizePerFile(size_t size) { if (hdf_meas_impl_) { @@ -190,7 +199,7 @@ void eCAL::eh5::HDF5Meas::SetMaxSizePerFile(size_t size) } } -bool eCAL::eh5::HDF5Meas::IsOneFilePerChannelEnabled() const +bool eCAL::eh5::v3::HDF5Meas::IsOneFilePerChannelEnabled() const { if (hdf_meas_impl_ != nullptr) { @@ -199,7 +208,7 @@ bool eCAL::eh5::HDF5Meas::IsOneFilePerChannelEnabled() const return false; } -void eCAL::eh5::HDF5Meas::SetOneFilePerChannelEnabled(bool enabled) +void eCAL::eh5::v3::HDF5Meas::SetOneFilePerChannelEnabled(bool enabled) { if (hdf_meas_impl_ != nullptr) { @@ -207,128 +216,96 @@ void eCAL::eh5::HDF5Meas::SetOneFilePerChannelEnabled(bool enabled) } } -std::set eCAL::eh5::HDF5Meas::GetChannelNames() const +std::set eCAL::eh5::v3::HDF5Meas::GetChannels() const { - std::set ret_val; + std::set ret_val; if (hdf_meas_impl_) { - std::set escaped_channel_names = hdf_meas_impl_->GetChannelNames(); - for (const std::string& escaped_name : escaped_channel_names) + auto escaped_channels = hdf_meas_impl_->GetChannels(); + for (const auto& escaped_channel : escaped_channels) { - ret_val.emplace(GetUnescapedString(escaped_name)); + ret_val.emplace(GetUnescapedString(escaped_channel.name), escaped_channel.id); } } return ret_val; } -bool eCAL::eh5::HDF5Meas::HasChannel(const std::string& channel_name) const +bool eCAL::eh5::v3::HDF5Meas::HasChannel(const eCAL::eh5::SChannel& channel) const { bool ret_val = false; if (hdf_meas_impl_) { - ret_val = hdf_meas_impl_->HasChannel(GetEscapedTopicname(channel_name)); + ret_val = hdf_meas_impl_->HasChannel(GetEscapedTopicname(channel)); } return ret_val; } -// deprecated -std::string eCAL::eh5::HDF5Meas::GetChannelDescription(const std::string& channel_name) const -{ - auto datatype_info = GetChannelDataTypeInformation(channel_name); - return datatype_info.descriptor; -} - -// deprecated -void eCAL::eh5::HDF5Meas::SetChannelDescription(const std::string& channel_name, const std::string& description) -{ - auto current_info = GetChannelDataTypeInformation(channel_name); - current_info.descriptor = description; - SetChannelDataTypeInformation(channel_name, current_info); -} - -// deprecated -std::string eCAL::eh5::HDF5Meas::GetChannelType(const std::string& channel_name) const -{ - std::string ret_val; - auto datatype_info = GetChannelDataTypeInformation(channel_name); - std::tie(ret_val, std::ignore) = FromInfo(datatype_info); - return ret_val; -} - -// deprecated -void eCAL::eh5::HDF5Meas::SetChannelType(const std::string& channel_name, const std::string& type) -{ - auto current_info = GetChannelDataTypeInformation(channel_name); - auto new_info = CreateInfo(type, current_info.descriptor); - SetChannelDataTypeInformation(channel_name, new_info); -} - -eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5Meas::GetChannelDataTypeInformation(const std::string& channel_name) const +eCAL::eh5::DataTypeInformation eCAL::eh5::v3::HDF5Meas::GetChannelDataTypeInformation(const SChannel& channel) const { eCAL::eh5::DataTypeInformation ret_val; if (hdf_meas_impl_) { - ret_val = hdf_meas_impl_->GetChannelDataTypeInformation(GetEscapedTopicname(channel_name)); + ret_val = hdf_meas_impl_->GetChannelDataTypeInformation(GetEscapedTopicname(channel)); } return ret_val; } -void eCAL::eh5::HDF5Meas::SetChannelDataTypeInformation(const std::string& channel_name, const eCAL::eh5::DataTypeInformation& info) +void eCAL::eh5::v3::HDF5Meas::SetChannelDataTypeInformation(const SChannel& channel, const eCAL::eh5::DataTypeInformation& info) { if (hdf_meas_impl_) { - hdf_meas_impl_->SetChannelDataTypeInformation(GetEscapedTopicname(channel_name), info); + hdf_meas_impl_->SetChannelDataTypeInformation(GetEscapedTopicname(channel), info); } } -long long eCAL::eh5::HDF5Meas::GetMinTimestamp(const std::string& channel_name) const +long long eCAL::eh5::v3::HDF5Meas::GetMinTimestamp(const SChannel& channel) const { long long ret_val = 0; if (hdf_meas_impl_) { - ret_val = hdf_meas_impl_->GetMinTimestamp(GetEscapedTopicname(channel_name)); + ret_val = hdf_meas_impl_->GetMinTimestamp(GetEscapedTopicname(channel)); } return ret_val; } -long long eCAL::eh5::HDF5Meas::GetMaxTimestamp(const std::string& channel_name) const +long long eCAL::eh5::v3::HDF5Meas::GetMaxTimestamp(const SChannel& channel) const { long long ret_val = 0; if (hdf_meas_impl_) { - ret_val = hdf_meas_impl_->GetMaxTimestamp(GetEscapedTopicname(channel_name)); + ret_val = hdf_meas_impl_->GetMaxTimestamp(GetEscapedTopicname(channel)); } return ret_val; } -bool eCAL::eh5::HDF5Meas::GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const +bool eCAL::eh5::v3::HDF5Meas::GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const { bool ret_val = false; if (hdf_meas_impl_) { - ret_val = hdf_meas_impl_->GetEntriesInfo(GetEscapedTopicname(channel_name), entries); + ret_val = hdf_meas_impl_->GetEntriesInfo(GetEscapedTopicname(channel), entries); } return ret_val; } -bool eCAL::eh5::HDF5Meas::GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const +bool eCAL::eh5::v3::HDF5Meas::GetEntriesInfoRange(const SChannel& channel, long long begin, long long end, EntryInfoSet& entries) const { bool ret_val = false; if (hdf_meas_impl_ && begin < end) { - ret_val = hdf_meas_impl_->GetEntriesInfoRange(GetEscapedTopicname(channel_name), begin, end, entries); + ret_val = hdf_meas_impl_->GetEntriesInfoRange(GetEscapedTopicname(channel), begin, end, entries); } return ret_val; } -bool eCAL::eh5::HDF5Meas::GetEntryDataSize(long long entry_id, size_t& size) const +bool eCAL::eh5::v3::HDF5Meas::GetEntryDataSize(long long entry_id, size_t& size) const { bool ret_val = false; if (hdf_meas_impl_) @@ -339,7 +316,7 @@ bool eCAL::eh5::HDF5Meas::GetEntryDataSize(long long entry_id, size_t& size) con return ret_val; } -bool eCAL::eh5::HDF5Meas::GetEntryData(long long entry_id, void* data) const +bool eCAL::eh5::v3::HDF5Meas::GetEntryData(long long entry_id, void* data) const { bool ret_val = false; if (hdf_meas_impl_) @@ -350,7 +327,7 @@ bool eCAL::eh5::HDF5Meas::GetEntryData(long long entry_id, void* data) const return ret_val; } -void eCAL::eh5::HDF5Meas::SetFileBaseName(const std::string& base_name) +void eCAL::eh5::v3::HDF5Meas::SetFileBaseName(const std::string& base_name) { if (hdf_meas_impl_) { @@ -358,18 +335,18 @@ void eCAL::eh5::HDF5Meas::SetFileBaseName(const std::string& base_name) } } -bool eCAL::eh5::HDF5Meas::AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) +bool eCAL::eh5::v3::HDF5Meas::AddEntryToFile(const SWriteEntry& entry) { bool ret_val = false; if (hdf_meas_impl_) { - return hdf_meas_impl_->AddEntryToFile(data, size, snd_timestamp, rcv_timestamp, GetEscapedTopicname(channel_name), id, clock); + return hdf_meas_impl_->AddEntryToFile(GetEscapedEntry(entry)); } return ret_val; } -void eCAL::eh5::HDF5Meas::ConnectPreSplitCallback(CallbackFunction cb) +void eCAL::eh5::v3::HDF5Meas::ConnectPreSplitCallback(CallbackFunction cb) { if (hdf_meas_impl_) { @@ -377,7 +354,7 @@ void eCAL::eh5::HDF5Meas::ConnectPreSplitCallback(CallbackFunction cb) } } -void eCAL::eh5::HDF5Meas::DisconnectPreSplitCallback() +void eCAL::eh5::v3::HDF5Meas::DisconnectPreSplitCallback() { if (hdf_meas_impl_) { diff --git a/contrib/ecalhdf5/src/eh5_meas_dir.cpp b/contrib/ecalhdf5/src/eh5_meas_dir.cpp index 0e8263d5ff..d53ed26460 100644 --- a/contrib/ecalhdf5/src/eh5_meas_dir.cpp +++ b/contrib/ecalhdf5/src/eh5_meas_dir.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,31 +24,34 @@ #include "eh5_meas_dir.h" #include "escape.h" +#define NOMINMAX #ifdef WIN32 #include #else #include #endif //WIN32 -#include -#include #include +#include +#include +#include #include #include #include "eh5_meas_file_writer_v5.h" +#include "eh5_meas_file_writer_v6.h" // TODO: Test the one-file-per-channel setting with gtest constexpr unsigned int kDefaultMaxFileSizeMB = 1000; eCAL::eh5::HDF5MeasDir::HDF5MeasDir() - : access_ (RDONLY) // Temporarily set it to RDONLY, so the leading "Close()" from the Open() function will not operate on the uninitialized variable. + : access_ (v3::eAccessType::RDONLY) // Temporarily set it to RDONLY, so the leading "Close()" from the Open() function will not operate on the uninitialized variable. , one_file_per_channel_(false) , max_size_per_file_ (kDefaultMaxFileSizeMB * 1024 * 1024) , cb_pre_split_ (nullptr) {} -eCAL::eh5::HDF5MeasDir::HDF5MeasDir(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) +eCAL::eh5::HDF5MeasDir::HDF5MeasDir(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/) : access_ (access) , one_file_per_channel_(false) , max_size_per_file_ (kDefaultMaxFileSizeMB * 1024 * 1024) @@ -66,7 +69,7 @@ eCAL::eh5::HDF5MeasDir::~HDF5MeasDir() HDF5MeasDir::Close(); } -bool eCAL::eh5::HDF5MeasDir::Open(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) +bool eCAL::eh5::HDF5MeasDir::Open(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/) { // call the function via its class becase it's a virtual function that is called directly/indirectly in constructor/destructor,- // where the vtable is not created yet or it's destructed. @@ -80,10 +83,11 @@ bool eCAL::eh5::HDF5MeasDir::Open(const std::string& path, eAccessType access /* switch (access) { - case eCAL::eh5::RDONLY: + case eCAL::eh5::v3::eAccessType::RDONLY: //case eCAL::eh5::RDWR: return OpenRX(path, access); - case eCAL::eh5::CREATE: + case eCAL::eh5::v3::eAccessType::CREATE: + case eCAL::eh5::v3::eAccessType::CREATE_V5: output_dir_ = path; return true; default: @@ -97,7 +101,7 @@ bool eCAL::eh5::HDF5MeasDir::Close() { bool successfully_closed{ true }; - if (access_ == eAccessType::CREATE) + if (access_ == v3::eAccessType::CREATE || access_ == v3::eAccessType::CREATE_V5) { // Close all existing file writers for (auto& file_writer : file_writers_) @@ -135,10 +139,11 @@ bool eCAL::eh5::HDF5MeasDir::IsOk() const { switch (access_) { - case eCAL::eh5::RDONLY: + case eCAL::eh5::v3::eAccessType::RDONLY: //case eCAL::eh5::RDWR: return !file_readers_.empty() && !entries_by_id_.empty(); - case eCAL::eh5::CREATE: + case eCAL::eh5::v3::eAccessType::CREATE: + case eCAL::eh5::v3::eAccessType::CREATE_V5: return true; default: return false; @@ -182,26 +187,26 @@ void eCAL::eh5::HDF5MeasDir::SetOneFilePerChannelEnabled(bool enabled) one_file_per_channel_ = enabled; } -std::set eCAL::eh5::HDF5MeasDir::GetChannelNames() const +std::set eCAL::eh5::HDF5MeasDir::GetChannels() const { - std::set channels; + std::set channels; + for (const auto& chn : channels_info_) channels.insert(chn.first); return channels; } -bool eCAL::eh5::HDF5MeasDir::HasChannel(const std::string& channel_name) const +bool eCAL::eh5::HDF5MeasDir::HasChannel(const eCAL::eh5::SChannel& channel) const { - return channels_info_.count(channel_name) != 0; + return channels_info_.find(channel) != channels_info_.end(); } -eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasDir::GetChannelDataTypeInformation(const std::string& channel_name) const +eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasDir::GetChannelDataTypeInformation(const SChannel& channel) const { eCAL::eh5::DataTypeInformation ret_val; - const auto& found = channels_info_.find(channel_name); - + const auto& found = channels_info_.find(channel); if (found != channels_info_.end()) { ret_val = found->second.info; @@ -209,85 +214,82 @@ eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasDir::GetChannelDataTypeInforma return ret_val; } -void eCAL::eh5::HDF5MeasDir::SetChannelDataTypeInformation(const std::string& channel_name, const eCAL::eh5::DataTypeInformation& info) +// TODO: this seems fishy. Do we need to escape? +void eCAL::eh5::HDF5MeasDir::SetChannelDataTypeInformation(const SChannel& channel, const eCAL::eh5::DataTypeInformation& info) { // Get an existing writer or create a new one - auto file_writer_it = GetWriter(channel_name); - file_writer_it->second->SetChannelDataTypeInformation(channel_name, info); + auto file_writer_it = GetWriter(channel); + file_writer_it->second->SetChannelDataTypeInformation(channel, info); // Let's save them in case we need to query them - channels_info_[channel_name] = ChannelInfo(info); + channels_info_[channel] = ChannelInfo(info); } -long long eCAL::eh5::HDF5MeasDir::GetMinTimestamp(const std::string& channel_name) const +long long eCAL::eh5::HDF5MeasDir::GetMinTimestamp(const SChannel& channel) const { - long long ret_val = 0; - - const auto& found = entries_by_chn_.find(channel_name); + long long min_timestamp = std::numeric_limits::max(); + const auto& channel_entries = entries_by_chn_.find(channel); - if (found != entries_by_chn_.end()) + if (channel_entries != entries_by_chn_.end()) { - if (!found->second.empty()) + if (!channel_entries->second.empty()) { - ret_val = found->second.begin()->RcvTimestamp; + min_timestamp = channel_entries->second.begin()->RcvTimestamp; } } - return ret_val; + return min_timestamp; } -long long eCAL::eh5::HDF5MeasDir::GetMaxTimestamp(const std::string& channel_name) const +long long eCAL::eh5::HDF5MeasDir::GetMaxTimestamp(const SChannel& channel) const { - long long ret_val = 0; - - const auto& found = entries_by_chn_.find(channel_name); + long long max_timestamp = std::numeric_limits::min(); + const auto& channel_entries = entries_by_chn_.find(channel); - if (found != entries_by_chn_.end()) + if (channel_entries != entries_by_chn_.end()) { - if (!found->second.empty()) + if (!channel_entries->second.empty()) { - ret_val = found->second.rbegin()->RcvTimestamp; + max_timestamp = channel_entries->second.rbegin()->RcvTimestamp; } } - return ret_val; + return max_timestamp; } -bool eCAL::eh5::HDF5MeasDir::GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const +bool eCAL::eh5::HDF5MeasDir::GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const { entries.clear(); - const auto& found = entries_by_chn_.find(channel_name); - - if (found != entries_by_chn_.end()) + const auto& channel_it = entries_by_chn_.find(channel); + if (channel_it == entries_by_chn_.end()) { - entries = found->second; + return false; } + entries = channel_it->second; + return !entries.empty(); } -bool eCAL::eh5::HDF5MeasDir::GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const +bool eCAL::eh5::HDF5MeasDir::GetEntriesInfoRange(const SChannel& channel, long long begin, long long end, EntryInfoSet& entries) const { - bool ret_val = false; - entries.clear(); - const auto& found = entries_by_chn_.find(channel_name); - - if (found != entries_by_chn_.end()) + const auto& channel_it = entries_by_chn_.find(channel); + if (channel_it == entries_by_chn_.end()) { - if (begin == 0) begin = entries.begin()->RcvTimestamp; - if (end == 0) end = entries.rbegin()->RcvTimestamp; + return false; + } - const auto& lower = found->second.lower_bound(SEntryInfo(begin, 0, 0)); - const auto& upper = found->second.upper_bound(SEntryInfo(end, 0, 0)); + if (begin == 0) begin = entries.begin()->RcvTimestamp; + if (end == 0) end = entries.rbegin()->RcvTimestamp; - entries.insert(lower, upper); - ret_val = true; - } + const auto& lower = channel_it->second.lower_bound(SEntryInfo(begin, 0, 0)); + const auto& upper = channel_it->second.upper_bound(SEntryInfo(end, 0, 0)); - return ret_val; + entries.insert(lower, upper); + return true; } bool eCAL::eh5::HDF5MeasDir::GetEntryDataSize(long long entry_id, size_t& size) const @@ -317,9 +319,9 @@ void eCAL::eh5::HDF5MeasDir::SetFileBaseName(const std::string& base_name) base_name_ = base_name; } -bool eCAL::eh5::HDF5MeasDir::AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) +bool eCAL::eh5::HDF5MeasDir::AddEntryToFile(const SWriteEntry& entry) { - if ((access_ != CREATE) + if ((access_ == v3::eAccessType::RDONLY) || (output_dir_.empty()) || (base_name_.empty())) { @@ -327,10 +329,10 @@ bool eCAL::eh5::HDF5MeasDir::AddEntryToFile(const void* data, const unsigned lon } // Get an existing writer or create a new one - auto file_writer_it = GetWriter(channel_name); - + auto file_writer_it = GetWriter(entry.channel); + // Use the writer that was either found or created to actually write the data - return file_writer_it->second->AddEntryToFile(data, size, snd_timestamp, rcv_timestamp, channel_name, id, clock); + return file_writer_it->second->AddEntryToFile(entry); } void eCAL::eh5::HDF5MeasDir::ConnectPreSplitCallback(CallbackFunction cb) @@ -422,9 +424,9 @@ std::list eCAL::eh5::HDF5MeasDir::GetHdfFiles(const std::string& pa return paths; } -bool eCAL::eh5::HDF5MeasDir::OpenRX(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) +bool eCAL::eh5::HDF5MeasDir::OpenRX(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/) { - if (access != eAccessType::RDONLY /*&& access != eAccessType::RDWR*/) return false; + if (access != v3::eAccessType::RDONLY /*&& access != eAccessType::RDWR*/) return false; auto files = GetHdfFiles(path); @@ -432,30 +434,19 @@ bool eCAL::eh5::HDF5MeasDir::OpenRX(const std::string& path, eAccessType access for (const auto& file_path : files) { - auto reader = new eCAL::eh5::HDF5Meas(file_path); + auto reader = new eCAL::eh5::v3::HDF5Meas(file_path); if (reader->IsOk()) { - auto channels = reader->GetChannelNames(); + auto channels = reader->GetChannels(); for (const auto& channel : channels) { - auto escaped_name = GetEscapedTopicname(channel); - auto info = reader->GetChannelDataTypeInformation(channel); - - // What exactly does that do? what are we overwriting? - if (channels_info_.find(escaped_name) == channels_info_.end()) - { - channels_info_[escaped_name] = ChannelInfo(info); - } - else - { - if (!info.descriptor.empty()) - { - channels_info_[escaped_name].info.descriptor = info.descriptor; - } - } + auto escaped_channel = GetEscapedTopicname(channel); + auto info = reader->GetChannelDataTypeInformation(escaped_channel); - channels_info_[escaped_name].files.push_back(reader); + auto& channel_info = channels_info_[escaped_channel]; + channel_info.info = info; + channel_info.files.push_back(reader); EntryInfoSet entries; if (reader->GetEntriesInfo(channel, entries)) @@ -464,7 +455,7 @@ bool eCAL::eh5::HDF5MeasDir::OpenRX(const std::string& path, eAccessType access { entries_by_id_[id] = EntryInfo(entry.ID, reader); entry.ID = id; - entries_by_chn_[escaped_name].insert(entry); + entries_by_chn_[escaped_channel].insert(entry); id++; } } @@ -481,16 +472,24 @@ bool eCAL::eh5::HDF5MeasDir::OpenRX(const std::string& path, eAccessType access return !file_readers_.empty(); } -::eCAL::eh5::HDF5MeasDir::FileWriterMap::iterator eCAL::eh5::HDF5MeasDir::GetWriter(const std::string& channel_name) +::eCAL::eh5::HDF5MeasDir::FileWriterMap::iterator eCAL::eh5::HDF5MeasDir::GetWriter(const SChannel& channel) { + const auto& channel_name{ channel.name }; // Look for an existing writer. When creating 1 file per channel, the channel // name is used as key. Otherwise, emptystring is used as "generic" key and // the same writer is used for all channels. FileWriterMap::iterator file_writer_it = file_writers_.find(one_file_per_channel_ ? channel_name : ""); if (file_writer_it == file_writers_.end()) { - // No appropriate file writer was found. Let's create a new one! - file_writer_it = file_writers_.emplace(one_file_per_channel_ ? channel_name : "", std::make_unique<::eCAL::eh5::HDF5MeasFileWriterV5>()).first; + if (access_ == v3::eAccessType::CREATE) + { + // No appropriate file writer was found. Let's create a new one! + file_writer_it = file_writers_.emplace(one_file_per_channel_ ? channel_name : "", std::make_unique<::eCAL::eh5::HDF5MeasFileWriterV6>()).first; + } + else + { + file_writer_it = file_writers_.emplace(one_file_per_channel_ ? channel_name : "", std::make_unique<::eCAL::eh5::HDF5MeasFileWriterV5>()).first; + } // Set the current parameters to the new file writer file_writer_it->second->SetMaxSizePerFile(GetMaxSizePerFile()); diff --git a/contrib/ecalhdf5/src/eh5_meas_dir.h b/contrib/ecalhdf5/src/eh5_meas_dir.h index f6287b3e9c..f7392e3b6c 100644 --- a/contrib/ecalhdf5/src/eh5_meas_dir.h +++ b/contrib/ecalhdf5/src/eh5_meas_dir.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ namespace eCAL * * @param path input file path **/ - explicit HDF5MeasDir(const std::string& path, eAccessType access = eAccessType::RDONLY); + explicit HDF5MeasDir(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY); /** * @brief Destructor @@ -67,7 +67,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool Open(const std::string& path, eAccessType access = eAccessType::RDONLY) override; + bool Open(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY) override; /** * @brief Close file @@ -127,20 +127,20 @@ namespace eCAL void SetOneFilePerChannelEnabled(bool enabled) override; /** - * @brief Get the available channel names of the current opened file / measurement - * - * @return channel names - **/ - std::set GetChannelNames() const override; + * @brief Get the available channel names of the current opened file / measurement + * + * @return channel names & ids + **/ + std::set GetChannels() const override; /** - * @brief Check if channel exists in measurement - * - * @param channel_name name of the channel - * - * @return true if exists, false otherwise + * @brief Check if channel exists in measurement + * + * @param channel channel name & id + * + * @return true if exists, false otherwise **/ - bool HasChannel(const std::string& channel_name) const override; + bool HasChannel(const eCAL::eh5::SChannel& channel) const override; /** * @brief Get data type information of the given channel @@ -149,7 +149,7 @@ namespace eCAL * * @return channel type **/ - DataTypeInformation GetChannelDataTypeInformation(const std::string& channel_name) const override; + DataTypeInformation GetChannelDataTypeInformation(const SChannel& channel) const override; /** * @brief Set data type information of the given channel @@ -159,7 +159,7 @@ namespace eCAL * * @return channel type **/ - void SetChannelDataTypeInformation(const std::string& channel_name, const DataTypeInformation& info) override; + void SetChannelDataTypeInformation(const SChannel& channel, const DataTypeInformation& info) override; /** * @brief Gets minimum timestamp for specified channel @@ -168,7 +168,7 @@ namespace eCAL * * @return minimum timestamp value **/ - long long GetMinTimestamp(const std::string& channel_name) const override; + long long GetMinTimestamp(const SChannel& channel) const override; /** * @brief Gets maximum timestamp for specified channel @@ -177,7 +177,7 @@ namespace eCAL * * @return maximum timestamp value **/ - long long GetMaxTimestamp(const std::string& channel_name) const override; + long long GetMaxTimestamp(const SChannel& channel) const override; /** * @brief Gets the header info for all data entries for the given channel @@ -188,7 +188,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const override; + bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const override; /** * @brief Gets the header info for data entries for the given channel included in given time range (begin->end) @@ -201,7 +201,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const override; + bool GetEntriesInfoRange(const SChannel& channel, long long begin, long long end, EntryInfoSet& entries) const override; /** * @brief Gets data size of a specific entry @@ -237,13 +237,13 @@ namespace eCAL * @param size size of the data * @param snd_timestamp send timestamp * @param rcv_timestamp receive timestamp - * @param channel_name channel name + * @param channel channel * @param id message id * @param clock message clock * * @return true if succeeds, false if it fails **/ - bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) override; + bool AddEntryToFile(const SWriteEntry& entry) override; typedef std::function CallbackFunction; /** @@ -266,7 +266,7 @@ namespace eCAL struct ChannelInfo { DataTypeInformation info; - std::list files; + std::list files; ChannelInfo() = default; ChannelInfo(const DataTypeInformation& info_) @@ -276,21 +276,21 @@ namespace eCAL struct EntryInfo { - long long file_id; - const eCAL::eh5::HDF5Meas* reader; + long long file_id; + const eCAL::eh5::v3::HDF5Meas* reader; EntryInfo() : file_id(0), reader(nullptr) {} - EntryInfo(long long file_id_, const eCAL::eh5::HDF5Meas* reader_) + EntryInfo(long long file_id_, const eCAL::eh5::v3::HDF5Meas* reader_) : file_id(file_id_) , reader(reader_) {} }; - typedef std::list HDF5Files; - typedef std::unordered_map ChannelInfoUMap; - typedef std::unordered_map EntriesByIdUMap; - typedef std::unordered_map EntriesByChannelUMap; + typedef std::list HDF5Files; + typedef std::unordered_map ChannelInfoUMap; + typedef std::unordered_map EntriesByIdUMap; + typedef std::unordered_map EntriesByChannelUMap; HDF5Files file_readers_; ChannelInfoUMap channels_info_; @@ -307,7 +307,7 @@ namespace eCAL typedef std::map Channels; Channels channels_; - eAccessType access_; + v3::eAccessType access_; std::list GetHdfFiles(const std::string& path) const; @@ -318,7 +318,7 @@ namespace eCAL return std::equal(end.rbegin(), end.rend(), str.rbegin()); } - bool OpenRX(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/); + bool OpenRX(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/); // ===================================================================== @@ -350,7 +350,7 @@ namespace eCAL * * @return an iterator to the writer */ - FileWriterMap::iterator GetWriter(const std::string& channel_name); + FileWriterMap::iterator GetWriter(const SChannel& channel); }; } // namespace eh5 } // namespace eCAL diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v1.cpp b/contrib/ecalhdf5/src/eh5_meas_file_v1.cpp index 20d1381f1d..a6a227d7e7 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_v1.cpp +++ b/contrib/ecalhdf5/src/eh5_meas_file_v1.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ #include "hdf5.h" #include +#include "datatype_helper.h" #include @@ -37,7 +38,7 @@ eCAL::eh5::HDF5MeasFileV1::HDF5MeasFileV1() } -eCAL::eh5::HDF5MeasFileV1::HDF5MeasFileV1(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) +eCAL::eh5::HDF5MeasFileV1::HDF5MeasFileV1(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/) : file_id_(-1) { #ifndef _DEBUG @@ -58,7 +59,7 @@ eCAL::eh5::HDF5MeasFileV1::~HDF5MeasFileV1() } -bool eCAL::eh5::HDF5MeasFileV1::Open(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) +bool eCAL::eh5::HDF5MeasFileV1::Open(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/) { entries_.clear(); @@ -68,7 +69,7 @@ bool eCAL::eh5::HDF5MeasFileV1::Open(const std::string& path, eAccessType access if (file_id_ > 0) HDF5MeasFileV1::Close(); - if (access != eAccessType::RDONLY) + if (access != v3::eAccessType::RDONLY) { ReportUnsupportedAction(); return false; @@ -78,11 +79,11 @@ bool eCAL::eh5::HDF5MeasFileV1::Open(const std::string& path, eAccessType access if (HDF5MeasFileV1::IsOk()) { - auto channels = HDF5MeasFileV1::GetChannelNames(); + auto channels = HDF5MeasFileV1::GetChannels(); if (channels.size() == 1) { - channel_name_ = *channels.begin(); - HDF5MeasFileV1::GetEntriesInfo(channel_name_, entries_); + auto channel = *channels.begin(); + HDF5MeasFileV1::GetEntriesInfo(channel, entries_); } } @@ -143,48 +144,47 @@ void eCAL::eh5::HDF5MeasFileV1::SetOneFilePerChannelEnabled(bool /*enabled*/) ReportUnsupportedAction(); } -std::set eCAL::eh5::HDF5MeasFileV1::GetChannelNames() const +std::set eCAL::eh5::HDF5MeasFileV1::GetChannels() const { - std::set channels; + std::set channels; std::string channel_name; GetAttributeValue(file_id_, kChnNameAttribTitle, channel_name); if (!channel_name.empty()) - channels.insert(channel_name); + channels.insert(eCAL::experimental::measurement::base::CreateChannel(channel_name)); return channels; } - -bool eCAL::eh5::HDF5MeasFileV1::HasChannel(const std::string& channel_name) const +bool eCAL::eh5::HDF5MeasFileV1::HasChannel(const eCAL::eh5::SChannel& channel) const { - auto channels = GetChannelNames(); + auto channels = GetChannels(); - return std::find(channels.cbegin(), channels.cend(), channel_name) != channels.end(); + return std::find(channels.cbegin(), channels.cend(), channel) != channels.end(); } -eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasFileV1::GetChannelDataTypeInformation(const std::string& channel_name) const +eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasFileV1::GetChannelDataTypeInformation(const SChannel& channel) const { std::string type; - if (EcalUtils::String::Icompare(channel_name, channel_name_)) + if (EcalUtils::String::Icompare(channel.name, channel_name_)) GetAttributeValue(file_id_, kChnTypeAttrTitle, type); std::string description; - if (EcalUtils::String::Icompare(channel_name, channel_name_)) + if (EcalUtils::String::Icompare(channel.name, channel_name_)) GetAttributeValue(file_id_, kChnDescAttrTitle, description); return CreateInfo(type, description); } -void eCAL::eh5::HDF5MeasFileV1::SetChannelDataTypeInformation(const std::string& /*channel_name*/, const eCAL::eh5::DataTypeInformation& /*info*/) +void eCAL::eh5::HDF5MeasFileV1::SetChannelDataTypeInformation(const SChannel& /*channel*/, const eCAL::eh5::DataTypeInformation& /*info*/) { ReportUnsupportedAction(); } -long long eCAL::eh5::HDF5MeasFileV1::GetMinTimestamp(const std::string& /*channel_name*/) const +long long eCAL::eh5::HDF5MeasFileV1::GetMinTimestamp(const SChannel& /*channel_name*/) const { long long ret_val = 0; @@ -196,7 +196,7 @@ long long eCAL::eh5::HDF5MeasFileV1::GetMinTimestamp(const std::string& /*channe return ret_val; } -long long eCAL::eh5::HDF5MeasFileV1::GetMaxTimestamp(const std::string& /*channel_name*/) const +long long eCAL::eh5::HDF5MeasFileV1::GetMaxTimestamp(const SChannel& /*channel_name*/) const { long long ret_val = 0; @@ -208,11 +208,11 @@ long long eCAL::eh5::HDF5MeasFileV1::GetMaxTimestamp(const std::string& /*channe return ret_val; } -bool eCAL::eh5::HDF5MeasFileV1::GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const +bool eCAL::eh5::HDF5MeasFileV1::GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const { entries.clear(); - if (!EcalUtils::String::Icompare(channel_name, channel_name_)) return false; + if (!EcalUtils::String::Icompare(channel.name, channel_name_)) return false; if (!HDF5MeasFileV1::IsOk()) return false; @@ -244,7 +244,7 @@ bool eCAL::eh5::HDF5MeasFileV1::GetEntriesInfo(const std::string& channel_name, return (status >= 0); } -bool eCAL::eh5::HDF5MeasFileV1::GetEntriesInfoRange(const std::string& /*channel_name*/, long long begin, long long end, EntryInfoSet& entries) const +bool eCAL::eh5::HDF5MeasFileV1::GetEntriesInfoRange(const SChannel& /*channel_name*/, long long begin, long long end, EntryInfoSet& entries) const { bool ret_val = false; @@ -305,7 +305,7 @@ void eCAL::eh5::HDF5MeasFileV1::SetFileBaseName(const std::string& /*base_name*/ ReportUnsupportedAction(); } -bool eCAL::eh5::HDF5MeasFileV1::AddEntryToFile(const void* /*data*/, const unsigned long long& /*size*/, const long long& /*snd_timestamp*/, const long long& /*rcv_timestamp*/, const std::string& /*channel_name*/, long long /*id*/, long long /*clock*/) +bool eCAL::eh5::HDF5MeasFileV1::AddEntryToFile(const SWriteEntry& /*entry*/) { ReportUnsupportedAction(); return false; @@ -377,5 +377,5 @@ bool eCAL::eh5::HDF5MeasFileV1::GetAttributeValue(hid_t obj_id, const std::strin void eCAL::eh5::HDF5MeasFileV1::ReportUnsupportedAction() { - std::cout << "eCALHDF5 file version bellow 2.0 support only readonly access type. Desired action not supported.\n"; + std::cout << "eCALHDF5 file version below 2.0 support only readonly access type. Desired action not supported.\n"; } diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v1.h b/contrib/ecalhdf5/src/eh5_meas_file_v1.h index 317733c80d..7b8e0565cc 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_v1.h +++ b/contrib/ecalhdf5/src/eh5_meas_file_v1.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ namespace eCAL * * @param path input file path **/ - explicit HDF5MeasFileV1(const std::string& path, eAccessType access = eAccessType::RDONLY); + explicit HDF5MeasFileV1(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY); /** * @brief Destructor @@ -58,7 +58,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool Open(const std::string& path, eAccessType access = eAccessType::RDONLY) override; + bool Open(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY) override; /** * @brief Close file @@ -117,22 +117,21 @@ namespace eCAL */ void SetOneFilePerChannelEnabled(bool enabled) override; - /** - * @brief Get the available channel names of the current opened file / measurement - * - * @return channel names + * @brief Get the available channel names of the current opened file / measurement + * + * @return channel names & ids **/ - std::set GetChannelNames() const override; + std::set GetChannels() const override; /** - * @brief Check if channel exists in measurement - * - * @param channel_name name of the channel - * - * @return true if exists, false otherwise + * @brief Check if channel exists in measurement + * + * @param channel channel name & id + * + * @return true if exists, false otherwise **/ - bool HasChannel(const std::string& channel_name) const override; + bool HasChannel(const eCAL::eh5::SChannel& channel) const override; /** * @brief Get data type information of the given channel @@ -141,7 +140,7 @@ namespace eCAL * * @return channel type **/ - DataTypeInformation GetChannelDataTypeInformation(const std::string& channel_name) const override; + DataTypeInformation GetChannelDataTypeInformation(const SChannel& channel) const override; /** * @brief Set data type information of the given channel @@ -151,7 +150,7 @@ namespace eCAL * * @return channel type **/ - void SetChannelDataTypeInformation(const std::string& channel_name, const DataTypeInformation& info) override; + void SetChannelDataTypeInformation(const SChannel& channel, const DataTypeInformation& info) override; /** * @brief Gets minimum timestamp for specified channel @@ -160,7 +159,7 @@ namespace eCAL * * @return minimum timestamp value **/ - long long GetMinTimestamp(const std::string& channel_name) const override; + long long GetMinTimestamp(const SChannel& channel) const override; /** * @brief Gets maximum timestamp for specified channel @@ -169,7 +168,7 @@ namespace eCAL * * @return maximum timestamp value **/ - long long GetMaxTimestamp(const std::string& channel_name) const override; + long long GetMaxTimestamp(const SChannel& channel) const override; /** * @brief Gets the header info for all data entries for the given channel @@ -180,7 +179,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const override; + bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const override; /** * @brief Gets the header info for data entries for the given channel included in given time range (begin->end) @@ -193,7 +192,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const override; + bool GetEntriesInfoRange(const SChannel& channel, long long begin, long long end, EntryInfoSet& entries) const override; /** * @brief Gets data size of a specific entry @@ -235,7 +234,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) override; + bool AddEntryToFile(const SWriteEntry& entry) override; typedef std::function CallbackFunction; /** diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v2.cpp b/contrib/ecalhdf5/src/eh5_meas_file_v2.cpp index a84b15c4ba..c621311f09 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_v2.cpp +++ b/contrib/ecalhdf5/src/eh5_meas_file_v2.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,8 @@ **/ #include "eh5_meas_file_v2.h" +#include "hdf5_helper.h" +#include "datatype_helper.h" #include "hdf5.h" #include @@ -38,7 +40,7 @@ eCAL::eh5::HDF5MeasFileV2::HDF5MeasFileV2() #endif // _DEBUG } -eCAL::eh5::HDF5MeasFileV2::HDF5MeasFileV2(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) +eCAL::eh5::HDF5MeasFileV2::HDF5MeasFileV2(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/) : file_id_(-1) { #ifndef _DEBUG @@ -58,11 +60,11 @@ eCAL::eh5::HDF5MeasFileV2::~HDF5MeasFileV2() } -bool eCAL::eh5::HDF5MeasFileV2::Open(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) +bool eCAL::eh5::HDF5MeasFileV2::Open(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/) { if (file_id_ > 0) Close(); if (path.empty()) return false; - if (access != eAccessType::RDONLY) return false; + if (access != v3::eAccessType::RDONLY) return false; file_id_ = H5Fopen(path.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); @@ -95,7 +97,7 @@ bool eCAL::eh5::HDF5MeasFileV2::IsOk() const std::string eCAL::eh5::HDF5MeasFileV2::GetFileVersion() const { std::string file_version; - GetAttributeValue(file_id_, kFileVerAttrTitle, file_version); + GetAttribute(file_id_, kFileVerAttrTitle, file_version); return file_version; } @@ -120,42 +122,41 @@ void eCAL::eh5::HDF5MeasFileV2::SetOneFilePerChannelEnabled(bool /*enabled*/) { } -std::set eCAL::eh5::HDF5MeasFileV2::GetChannelNames() const +std::set eCAL::eh5::HDF5MeasFileV2::GetChannels() const { - std::set channels_set; + std::set channels_set; - std::string channel_names; - GetAttributeValue(file_id_, kChnAttrTitle, channel_names); + std::string combined_channel_names; + GetAttribute(file_id_, kChnAttrTitle, combined_channel_names); - std::list channels; - EcalUtils::String::Split(channel_names, ",", channels); + std::list channel_name_list; + EcalUtils::String::Split(combined_channel_names, ",", channel_name_list); - for (const auto& channel : channels) - channels_set.insert(channel); + for (const auto& channel_name : channel_name_list) + channels_set.insert(eCAL::experimental::measurement::base::CreateChannel(channel_name)); return channels_set; } - -bool eCAL::eh5::HDF5MeasFileV2::HasChannel(const std::string& channel_name) const +bool eCAL::eh5::HDF5MeasFileV2::HasChannel(const eCAL::eh5::SChannel& channel) const { - auto channels = GetChannelNames(); + auto channels = GetChannels(); - return std::find(channels.cbegin(), channels.cend(), channel_name) != channels.end(); + return std::find(channels.cbegin(), channels.cend(), channel) != channels.end(); } -eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasFileV2::GetChannelDataTypeInformation(const std::string& channel_name) const +eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasFileV2::GetChannelDataTypeInformation(const SChannel& channel) const { std::string type; std::string description; if (this->IsOk()) { - auto dataset_id = H5Dopen(file_id_, channel_name.c_str(), H5P_DEFAULT); + auto dataset_id = H5Dopen(file_id_, channel.name.c_str(), H5P_DEFAULT); if (dataset_id >= 0) { - GetAttributeValue(dataset_id, kChnTypeAttrTitle, type); - GetAttributeValue(dataset_id, kChnDescAttrTitle, description); + GetAttribute(dataset_id, kChnTypeAttrTitle, type); + GetAttribute(dataset_id, kChnDescAttrTitle, description); H5Dclose(dataset_id); } } @@ -163,17 +164,17 @@ eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasFileV2::GetChannelDataTypeInfo return CreateInfo(type, description); } -void eCAL::eh5::HDF5MeasFileV2::SetChannelDataTypeInformation(const std::string& /*channel_name*/, const eCAL::eh5::DataTypeInformation& /*info*/) +void eCAL::eh5::HDF5MeasFileV2::SetChannelDataTypeInformation(const SChannel& /*channel*/ , const eCAL::eh5::DataTypeInformation& /*info*/) { } -long long eCAL::eh5::HDF5MeasFileV2::GetMinTimestamp(const std::string& channel_name) const +long long eCAL::eh5::HDF5MeasFileV2::GetMinTimestamp(const SChannel& channel) const { long long ret_val = 0; EntryInfoSet entries; - if (GetEntriesInfo(channel_name, entries) && !entries.empty()) + if (GetEntriesInfo(channel, entries) && !entries.empty()) { ret_val = entries.begin()->RcvTimestamp; } @@ -181,12 +182,12 @@ long long eCAL::eh5::HDF5MeasFileV2::GetMinTimestamp(const std::string& channel_ return ret_val; } -long long eCAL::eh5::HDF5MeasFileV2::GetMaxTimestamp(const std::string& channel_name) const +long long eCAL::eh5::HDF5MeasFileV2::GetMaxTimestamp(const SChannel& channel) const { long long ret_val = 0; EntryInfoSet entries; - if (GetEntriesInfo(channel_name, entries) && !entries.empty()) + if (GetEntriesInfo(channel, entries) && !entries.empty()) { ret_val = entries.rbegin()->RcvTimestamp; } @@ -194,13 +195,13 @@ long long eCAL::eh5::HDF5MeasFileV2::GetMaxTimestamp(const std::string& channel_ return ret_val; } -bool eCAL::eh5::HDF5MeasFileV2::GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const +bool eCAL::eh5::HDF5MeasFileV2::GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const { entries.clear(); if (!this->IsOk()) return false; - auto dataset_id = H5Dopen(file_id_, channel_name.c_str(), H5P_DEFAULT); + auto dataset_id = H5Dopen(file_id_, channel.name.c_str(), H5P_DEFAULT); if (dataset_id < 0) return false; @@ -228,13 +229,13 @@ bool eCAL::eh5::HDF5MeasFileV2::GetEntriesInfo(const std::string& channel_name, return (status >= 0); } -bool eCAL::eh5::HDF5MeasFileV2::GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const +bool eCAL::eh5::HDF5MeasFileV2::GetEntriesInfoRange(const SChannel& channel, long long begin, long long end, EntryInfoSet& entries) const { bool ret_val = false; EntryInfoSet all_entries; entries.clear(); - if (GetEntriesInfo(channel_name, all_entries) && !all_entries.empty()) + if (GetEntriesInfo(channel, all_entries) && !all_entries.empty()) { if (begin == 0) begin = entries.begin()->RcvTimestamp; if (end == 0) end = entries.rbegin()->RcvTimestamp; @@ -293,9 +294,9 @@ void eCAL::eh5::HDF5MeasFileV2::SetFileBaseName(const std::string& /*base_name*/ } -bool eCAL::eh5::HDF5MeasFileV2::AddEntryToFile(const void* /*data*/, const unsigned long long& /*size*/, const long long& /*snd_timestamp*/, const long long& /*rcv_timestamp*/, const std::string& /*channel_name*/, long long /*id*/, long long /*clock*/) +bool eCAL::eh5::HDF5MeasFileV2::AddEntryToFile(const SWriteEntry& /*entry*/) { - return false; + return false; } void eCAL::eh5::HDF5MeasFileV2::ConnectPreSplitCallback(CallbackFunction /*cb*/) @@ -304,58 +305,4 @@ void eCAL::eh5::HDF5MeasFileV2::ConnectPreSplitCallback(CallbackFunction /*cb*/) void eCAL::eh5::HDF5MeasFileV2::DisconnectPreSplitCallback() { -} - -bool eCAL::eh5::HDF5MeasFileV2::GetAttributeValue(hid_t obj_id, const std::string& name, std::string& value) -{ - bool ret_val = false; - // empty attribute value - value.clear(); - if (obj_id < 0) return false; - - // check if attribute exists - if (H5Aexists(obj_id, name.c_str()) != 0) - { - // open attribute by name, getting the attribute index - hid_t attr_id = H5Aopen_name(obj_id, name.c_str()); - // fail - attribute can not be opened - if (attr_id <= 0) return false; - - // get attribute type - hid_t attr_type = H5Aget_type(attr_id); - // get type class based on attribute type - H5T_class_t type_class = H5Tget_class(attr_type); - // get attribute content dataSize - const size_t attr_size = H5Tget_size(attr_type); - - // if attribute class is string - if (type_class == H5T_STRING) - { - hid_t attr_type_mem = H5Tget_native_type(attr_type, H5T_DIR_ASCEND); - // create buffer to store the value of the attribute - char* content_buffer = new char[attr_size]; - // get attribute value - ret_val = (H5Aread(attr_id, attr_type_mem, content_buffer) >= 0); - - // convert value to std string - value = std::string(content_buffer, attr_size); - - // free buffer - delete[]content_buffer; - } - else - { - // fail - attribute is not string type - ret_val = false; - } - // close attribute - H5Aclose(attr_id); - } - else - { - // fail - attribute name does not exist - ret_val = false; - } - // return read status - return ret_val; -} +} \ No newline at end of file diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v2.h b/contrib/ecalhdf5/src/eh5_meas_file_v2.h index 63934f88cb..17101d59eb 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_v2.h +++ b/contrib/ecalhdf5/src/eh5_meas_file_v2.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ namespace eCAL * * @param path input file path **/ - explicit HDF5MeasFileV2(const std::string& path, eAccessType access = eAccessType::RDONLY); + explicit HDF5MeasFileV2(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY); /** * @brief Destructor @@ -58,7 +58,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool Open(const std::string& path, eAccessType access = eAccessType::RDONLY) override; + bool Open(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY) override; /** * @brief Close file @@ -117,22 +117,21 @@ namespace eCAL */ void SetOneFilePerChannelEnabled(bool enabled) override; - /** - * @brief Get the available channel names of the current opened file / measurement - * - * @return channel names + * @brief Get the available channel names of the current opened file / measurement + * + * @return channel names & ids **/ - std::set GetChannelNames() const override; + std::set GetChannels() const override; /** - * @brief Check if channel exists in measurement - * - * @param channel_name name of the channel - * - * @return true if exists, false otherwise + * @brief Check if channel exists in measurement + * + * @param channel channel name & id + * + * @return true if exists, false otherwise **/ - bool HasChannel(const std::string& channel_name) const override; + bool HasChannel(const eCAL::eh5::SChannel& channel) const override; /** * @brief Get data type information of the given channel @@ -141,7 +140,7 @@ namespace eCAL * * @return channel type **/ - DataTypeInformation GetChannelDataTypeInformation(const std::string& channel_name) const override; + DataTypeInformation GetChannelDataTypeInformation(const SChannel& channel) const override; /** * @brief Set data type information of the given channel @@ -151,7 +150,7 @@ namespace eCAL * * @return channel type **/ - void SetChannelDataTypeInformation(const std::string& channel_name, const DataTypeInformation& info) override; + void SetChannelDataTypeInformation(const SChannel& channel, const DataTypeInformation& info) override; /** * @brief Gets minimum timestamp for specified channel @@ -160,7 +159,7 @@ namespace eCAL * * @return minimum timestamp value **/ - long long GetMinTimestamp(const std::string& channel_name) const override; + long long GetMinTimestamp(const SChannel& channel) const override; /** * @brief Gets maximum timestamp for specified channel @@ -169,7 +168,7 @@ namespace eCAL * * @return maximum timestamp value **/ - long long GetMaxTimestamp(const std::string& channel_name) const override; + long long GetMaxTimestamp(const SChannel& channel) const override; /** * @brief Gets the header info for all data entries for the given channel @@ -180,7 +179,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const override; + bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const override; /** * @brief Gets the header info for data entries for the given channel included in given time range (begin->end) @@ -193,7 +192,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const override; + bool GetEntriesInfoRange(const SChannel& channel, long long begin, long long end, EntryInfoSet& entries) const override; /** * @brief Gets data size of a specific entry @@ -235,7 +234,8 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) override; + bool AddEntryToFile(const SWriteEntry& entry) override; + typedef std::function CallbackFunction; /** @@ -252,17 +252,6 @@ namespace eCAL protected: hid_t file_id_; - - /** - * @brief Gets the value of a string attribute - * - * @param [in] obj_id ID of the attribute's parent - * @param [in] name Name of the attribute - * @param [out] value Value of the attribute - * - * @return true if succeeds, false if it fails - **/ - static bool GetAttributeValue(hid_t obj_id, const std::string& name, std::string& value) ; }; } // namespace eh5 diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v3.cpp b/contrib/ecalhdf5/src/eh5_meas_file_v3.cpp index 0469d80619..36e5eec07f 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_v3.cpp +++ b/contrib/ecalhdf5/src/eh5_meas_file_v3.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ namespace eCAL namespace eh5 { - HDF5MeasFileV3::HDF5MeasFileV3(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) + HDF5MeasFileV3::HDF5MeasFileV3(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/) : HDF5MeasFileV2(path, access) { } @@ -41,13 +41,13 @@ namespace eCAL HDF5MeasFileV3::~HDF5MeasFileV3() = default; - bool HDF5MeasFileV3::GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const + bool HDF5MeasFileV3::GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const { entries.clear(); if (!this->IsOk()) return false; - hid_t dataset_id = H5Dopen(file_id_, channel_name.c_str(), H5P_DEFAULT); + hid_t dataset_id = H5Dopen(file_id_, channel.name.c_str(), H5P_DEFAULT); if (dataset_id < 0) return false; diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v3.h b/contrib/ecalhdf5/src/eh5_meas_file_v3.h index 716bf00a7c..3c16b5ff32 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_v3.h +++ b/contrib/ecalhdf5/src/eh5_meas_file_v3.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ namespace eCAL * * @param path Input file path **/ - explicit HDF5MeasFileV3(const std::string& path, eAccessType access = eAccessType::RDONLY); + explicit HDF5MeasFileV3(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY); /** * @brief Destructor @@ -60,7 +60,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const override; + bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const override; }; } // namespace eh5 } // namespace eCAL diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v4.cpp b/contrib/ecalhdf5/src/eh5_meas_file_v4.cpp index ae5d125d76..dd33c70497 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_v4.cpp +++ b/contrib/ecalhdf5/src/eh5_meas_file_v4.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ namespace eCAL namespace eh5 { - HDF5MeasFileV4::HDF5MeasFileV4(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) + HDF5MeasFileV4::HDF5MeasFileV4(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/) : HDF5MeasFileV2(path, access) { } @@ -41,13 +41,13 @@ namespace eCAL HDF5MeasFileV4::~HDF5MeasFileV4() = default; - bool HDF5MeasFileV4::GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const + bool HDF5MeasFileV4::GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const { entries.clear(); if (!this->IsOk()) return false; - auto dataset_id = H5Dopen(file_id_, channel_name.c_str(), H5P_DEFAULT); + auto dataset_id = H5Dopen(file_id_, channel.name.c_str(), H5P_DEFAULT); if (dataset_id < 0) return false; diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v4.h b/contrib/ecalhdf5/src/eh5_meas_file_v4.h index f9d1139752..d2b0de9737 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_v4.h +++ b/contrib/ecalhdf5/src/eh5_meas_file_v4.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ namespace eCAL * * @param path Input file path **/ - explicit HDF5MeasFileV4(const std::string& path, eAccessType access = eAccessType::RDONLY); + explicit HDF5MeasFileV4(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY); /** * @brief Destructor @@ -60,7 +60,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const override; + bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const override; }; } // namespace eh5 } // namespace eCAL diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v5.cpp b/contrib/ecalhdf5/src/eh5_meas_file_v5.cpp index 39960e6015..5ba1eebb8a 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_v5.cpp +++ b/contrib/ecalhdf5/src/eh5_meas_file_v5.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ namespace eCAL namespace eh5 { - HDF5MeasFileV5::HDF5MeasFileV5(const std::string& path, eAccessType access /*= eAccessType::RDONLY*/) + HDF5MeasFileV5::HDF5MeasFileV5(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/) : HDF5MeasFileV2(path, access) { } @@ -41,13 +41,13 @@ namespace eCAL HDF5MeasFileV5::~HDF5MeasFileV5() = default; - bool HDF5MeasFileV5::GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const + bool HDF5MeasFileV5::GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const { entries.clear(); if (!this->IsOk()) return false; - auto dataset_id = H5Dopen(file_id_, channel_name.c_str(), H5P_DEFAULT); + auto dataset_id = H5Dopen(file_id_, channel.name.c_str(), H5P_DEFAULT); if (dataset_id < 0) return false; diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v5.h b/contrib/ecalhdf5/src/eh5_meas_file_v5.h index 9188616b15..ec2d7acc28 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_v5.h +++ b/contrib/ecalhdf5/src/eh5_meas_file_v5.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ namespace eCAL * * @param path Input file path **/ - explicit HDF5MeasFileV5(const std::string& path, eAccessType access = eAccessType::RDONLY); + explicit HDF5MeasFileV5(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY); /** * @brief Destructor @@ -60,7 +60,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const override; + bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const override; }; } // namespace eh5 } // namespace eCAL diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v6.cpp b/contrib/ecalhdf5/src/eh5_meas_file_v6.cpp new file mode 100644 index 0000000000..3aa8e5058a --- /dev/null +++ b/contrib/ecalhdf5/src/eh5_meas_file_v6.cpp @@ -0,0 +1,128 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +/** + * @brief eCALHDF5 reader multiple channels implement +**/ + +#include "eh5_meas_file_v6.h" + +#include "hdf5.h" +#include "hdf5_helper.h" + +namespace eCAL +{ + namespace eh5 + { + + HDF5MeasFileV6::HDF5MeasFileV6(const std::string& path, v3::eAccessType access /*= eAccessType::RDONLY*/) + : HDF5MeasFileV2(path, access) + { + } + + HDF5MeasFileV6::HDF5MeasFileV6() + = default; + + HDF5MeasFileV6::~HDF5MeasFileV6() + = default; + + // Channels have to be obtained differently, the names themselves are written in the header + // for channel, id, we need to traverse the file format and get them. + std::set HDF5MeasFileV6::GetChannels() const + { + std::set channels; + // V2 Channel function will return (channel_name, 0) + // so we will take those channel_names + const auto channels_v2 = HDF5MeasFileV2::GetChannels(); + + for (const auto& channel_v2 : channels_v2) + { + const auto& channel_name = channel_v2.name; + auto group_id = H5Gopen(file_id_, channel_name.c_str(), H5P_DEFAULT); + auto groups = ListSubgroups(group_id); + H5Gclose(group_id); + + for (const auto& group : groups) + { + const auto id = parseHexID(group); + channels.insert({ channel_name, id }); + } + + } + + return channels; + } + + bool HDF5MeasFileV6::HasChannel(const eCAL::eh5::SChannel& channel) const + { + bool has_channel_name = HasGroup(file_id_, channel.name); + if (!has_channel_name) + { + return false; + } + auto group_id = H5Gopen(file_id_, channel.name.c_str(), H5P_DEFAULT); + bool has_channel_id = HasGroup(group_id, printHex(channel.id).c_str()); + H5Gclose(group_id); + + return has_channel_id; + } + + eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasFileV6::GetChannelDataTypeInformation(const SChannel& channel) const + { + std::string type_name; + std::string type_encoding; + std::string type_descriptor; + + auto group_id = H5Gopen(file_id_, channel.name.c_str(), H5P_DEFAULT); + auto groups = ListSubgroups(group_id); + H5Gclose(group_id); + + if (this->IsOk()) + { + std::string channel_id_key = printHex(channel.id); + + // Read Typename + auto type_name_url = v6::GetUrl(channel.name, channel_id_key, eCAL::eh5::kChnIdTypename); + ReadStringEntryAsString(file_id_, type_name_url, type_name); + + // Read Encoding + auto type_encoding_url = v6::GetUrl(channel.name, channel_id_key, eCAL::eh5::kChnIdEncoding); + ReadStringEntryAsString(file_id_, type_encoding_url, type_encoding); + + // Read Descriptor + auto type_descriptor_url = v6::GetUrl(channel.name, channel_id_key, eCAL::eh5::kChnIdDescriptor); + ReadStringEntryAsString(file_id_, type_descriptor_url, type_descriptor); + } + + return eCAL::eh5::DataTypeInformation{ type_name, type_encoding, type_descriptor }; + } + + bool eCAL::eh5::HDF5MeasFileV6::GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const + { + if (!this->IsOk()) return false; + + auto hex_id = printHex(channel.id); + EntryInfoSet channel_id_entries; + auto url = v6::GetUrl(channel.name, hex_id, kChnIdData); + GetEntryInfoVector(file_id_, url, entries); + + return true; + } + } // namespace eh5 +} // namespace eCAL diff --git a/contrib/ecalhdf5/src/eh5_meas_file_v6.h b/contrib/ecalhdf5/src/eh5_meas_file_v6.h new file mode 100644 index 0000000000..536e7cd0aa --- /dev/null +++ b/contrib/ecalhdf5/src/eh5_meas_file_v6.h @@ -0,0 +1,75 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +/** + * eCALHDF5 file reader multiple channels +**/ + +#pragma once + +#include + +#include "eh5_meas_file_v5.h" + +namespace eCAL +{ + namespace eh5 + { + class HDF5MeasFileV6 : virtual public HDF5MeasFileV5 + { + public: + /** + * @brief Constructor + **/ + HDF5MeasFileV6(); + + /** + * @brief Constructor + * + * @param path Input file path + **/ + explicit HDF5MeasFileV6(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY); + + /** + * @brief Destructor + **/ + ~HDF5MeasFileV6() override; + + /** + * @brief Get the available channel names of the current opened file / measurement + * + * @return channel names & ids + **/ + std::set GetChannels() const override; + + /** + * @brief Check if channel exists in measurement + * + * @param channel channel name & id + * + * @return true if exists, false otherwise + **/ + bool HasChannel(const eCAL::eh5::SChannel& channel) const override; + + DataTypeInformation GetChannelDataTypeInformation(const SChannel& channel) const override; + + bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const override; + }; + } // namespace eh5 +} // namespace eCAL diff --git a/contrib/ecalhdf5/src/eh5_meas_file_writer_v5.cpp b/contrib/ecalhdf5/src/eh5_meas_file_writer_v5.cpp index 31d9f3916a..7d0562d275 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_writer_v5.cpp +++ b/contrib/ecalhdf5/src/eh5_meas_file_writer_v5.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ #include "eh5_meas_file_writer_v5.h" #include "escape.h" +#include "datatype_helper.h" #ifdef WIN32 #include @@ -54,7 +55,7 @@ eCAL::eh5::HDF5MeasFileWriterV5::~HDF5MeasFileWriterV5() HDF5MeasFileWriterV5::Close(); } -bool eCAL::eh5::HDF5MeasFileWriterV5::Open(const std::string& output_dir, eAccessType /*access = eAccessType::RDONLY*/) +bool eCAL::eh5::HDF5MeasFileWriterV5::Open(const std::string& output_dir, v3::eAccessType /*access = eAccessType::RDONLY*/) { Close(); @@ -126,51 +127,50 @@ void eCAL::eh5::HDF5MeasFileWriterV5::SetOneFilePerChannelEnabled(bool /*enabled { } -std::set eCAL::eh5::HDF5MeasFileWriterV5::GetChannelNames() const +std::set eCAL::eh5::HDF5MeasFileWriterV5::GetChannels() const { - // UNSUPPORTED FUNCTION - return {}; + // UNSUPPORTED FUNCTIONs + return std::set(); } -bool eCAL::eh5::HDF5MeasFileWriterV5::HasChannel(const std::string& /*channel_name*/) const +bool eCAL::eh5::HDF5MeasFileWriterV5::HasChannel(const eCAL::eh5::SChannel& /*channel*/ ) const { // UNSUPPORTED FUNCTION return false; } - -eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasFileWriterV5::GetChannelDataTypeInformation(const std::string& /*channel_name*/) const +eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasFileWriterV5::GetChannelDataTypeInformation(const SChannel& /*channel*/) const { // UNSUPPORTED FUNCTION return eCAL::eh5::DataTypeInformation{}; } -void eCAL::eh5::HDF5MeasFileWriterV5::SetChannelDataTypeInformation(const std::string& channel_name, const eCAL::eh5::DataTypeInformation& info) +void eCAL::eh5::HDF5MeasFileWriterV5::SetChannelDataTypeInformation(const SChannel& channel, const eCAL::eh5::DataTypeInformation& info) { auto type_descriptor = FromInfo(info); - channels_[channel_name].Type = type_descriptor.first; - channels_[channel_name].Description = type_descriptor.second; + channels_[channel.name].Type = type_descriptor.first; + channels_[channel.name].Description = type_descriptor.second; } -long long eCAL::eh5::HDF5MeasFileWriterV5::GetMinTimestamp(const std::string& /*channel_name*/) const +long long eCAL::eh5::HDF5MeasFileWriterV5::GetMinTimestamp(const SChannel& /*channel*/) const { // UNSUPPORTED FUNCTION return -1; } -long long eCAL::eh5::HDF5MeasFileWriterV5::GetMaxTimestamp(const std::string& /*channel_name*/) const +long long eCAL::eh5::HDF5MeasFileWriterV5::GetMaxTimestamp(const SChannel& /*channel*/) const { // UNSUPPORTED FUNCTION return -1; } -bool eCAL::eh5::HDF5MeasFileWriterV5::GetEntriesInfo(const std::string& /*channel_name*/, EntryInfoSet& /*entries*/) const +bool eCAL::eh5::HDF5MeasFileWriterV5::GetEntriesInfo(const SChannel& /*channel*/, EntryInfoSet& /*entries*/) const { // UNSUPPORTED FUNCTION return false; } -bool eCAL::eh5::HDF5MeasFileWriterV5::GetEntriesInfoRange(const std::string& /*channel_name*/, long long /*begin*/, long long /*end*/, EntryInfoSet& /*entries*/) const +bool eCAL::eh5::HDF5MeasFileWriterV5::GetEntriesInfoRange(const SChannel& /*channel*/, long long /*begin*/, long long /*end*/, EntryInfoSet& /*entries*/) const { // UNSUPPORTED FUNCTION return false; @@ -193,13 +193,13 @@ void eCAL::eh5::HDF5MeasFileWriterV5::SetFileBaseName(const std::string& base_na base_name_ = base_name; } -bool eCAL::eh5::HDF5MeasFileWriterV5::AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) +bool eCAL::eh5::HDF5MeasFileWriterV5::AddEntryToFile(const SWriteEntry& entry) { if (!IsOk()) file_id_ = Create(); if (!IsOk()) return false; - hsize_t hsSize = static_cast(size); + hsize_t hsSize = static_cast(entry.size); if (!EntryFitsTheFile(hsSize)) { @@ -223,14 +223,14 @@ bool eCAL::eh5::HDF5MeasFileWriterV5::AddEntryToFile(const void* data, const uns auto dataSet = H5Dcreate(file_id_, std::to_string(entries_counter_).c_str(), H5T_NATIVE_UCHAR, dataSpace, H5P_DEFAULT, dsProperty, H5P_DEFAULT); // Write buffer to dataset - herr_t writeStatus = H5Dwrite(dataSet, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + herr_t writeStatus = H5Dwrite(dataSet, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, entry.data); // Close dataset, data space, and data set property H5Dclose(dataSet); H5Pclose(dsProperty); H5Sclose(dataSpace); - channels_[channel_name].Entries.emplace_back(SEntryInfo(rcv_timestamp, static_cast(entries_counter_), clock, snd_timestamp, id)); + channels_[entry.channel.name].Entries.emplace_back(SEntryInfo(entry.rcv_timestamp, static_cast(entries_counter_), entry.clock, entry.snd_timestamp, entry.sender_id)); entries_counter_++; diff --git a/contrib/ecalhdf5/src/eh5_meas_file_writer_v5.h b/contrib/ecalhdf5/src/eh5_meas_file_writer_v5.h index 579951cf70..975d1f34b4 100644 --- a/contrib/ecalhdf5/src/eh5_meas_file_writer_v5.h +++ b/contrib/ecalhdf5/src/eh5_meas_file_writer_v5.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool Open(const std::string& output_dir, eAccessType access) override; + bool Open(const std::string& output_dir, v3::eAccessType access) override; /** * @brief Close file @@ -125,20 +125,20 @@ namespace eCAL void SetOneFilePerChannelEnabled(bool enabled) override; /** - * @brief Get the available channel names of the current opened file / measurement - * - * @return channel names + * @brief Get the available channel names of the current opened file / measurement + * + * @return channel names & ids **/ - std::set GetChannelNames() const override; + std::set GetChannels() const override; /** - * @brief Check if channel exists in measurement - * - * @param channel_name name of the channel - * - * @return true if exists, false otherwise + * @brief Check if channel exists in measurement + * + * @param channel channel name & id + * + * @return true if exists, false otherwise **/ - bool HasChannel(const std::string& channel_name) const override; + bool HasChannel(const eCAL::eh5::SChannel & channel) const override; /** * @brief Get data type information of the given channel @@ -147,7 +147,7 @@ namespace eCAL * * @return channel type **/ - DataTypeInformation GetChannelDataTypeInformation(const std::string & channel_name) const override; + DataTypeInformation GetChannelDataTypeInformation(const SChannel& channel) const override; /** * @brief Set data type information of the given channel @@ -157,7 +157,7 @@ namespace eCAL * * @return channel type **/ - void SetChannelDataTypeInformation(const std::string & channel_name, const DataTypeInformation & info) override; + void SetChannelDataTypeInformation(const SChannel& channel, const DataTypeInformation & info) override; /** * @brief Gets minimum timestamp for specified channel @@ -166,7 +166,7 @@ namespace eCAL * * @return minimum timestamp value **/ - long long GetMinTimestamp(const std::string& channel_name) const override; + long long GetMinTimestamp(const SChannel& channel) const override; /** * @brief Gets maximum timestamp for specified channel @@ -175,7 +175,7 @@ namespace eCAL * * @return maximum timestamp value **/ - long long GetMaxTimestamp(const std::string& channel_name) const override; + long long GetMaxTimestamp(const SChannel& channel) const override; /** * @brief Gets the header info for all data entries for the given channel @@ -186,7 +186,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const override; + bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const override; /** * @brief Gets the header info for data entries for the given channel included in given time range (begin->end) @@ -199,7 +199,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const override; + bool GetEntriesInfoRange(const SChannel& channel, long long begin, long long end, EntryInfoSet& entries) const override; /** * @brief Gets data size of a specific entry @@ -241,7 +241,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) override; + bool AddEntryToFile(const SWriteEntry& entry) override; using CallbackFunction = std::function; /** diff --git a/contrib/ecalhdf5/src/eh5_meas_file_writer_v6.cpp b/contrib/ecalhdf5/src/eh5_meas_file_writer_v6.cpp new file mode 100644 index 0000000000..4689073a97 --- /dev/null +++ b/contrib/ecalhdf5/src/eh5_meas_file_writer_v6.cpp @@ -0,0 +1,339 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +/** + * @brief eCALHDF5 directory reader +**/ + +#include "eh5_meas_file_writer_v6.h" +#include "escape.h" + +#ifdef WIN32 +#include +#else +#include +#endif //WIN32 + +#include +#include +#include + +#include +#include + +#include "hdf5_helper.h" + +constexpr unsigned int kDefaultMaxFileSizeMB = 1000; + +eCAL::eh5::HDF5MeasFileWriterV6::HDF5MeasFileWriterV6() + : cb_pre_split_ (nullptr) + , file_id_ (-1) + , file_split_counter_(-1) + , entries_counter_ (0) + , max_size_per_file_ (kDefaultMaxFileSizeMB * 1024 * 1024) +{} + +eCAL::eh5::HDF5MeasFileWriterV6::~HDF5MeasFileWriterV6() +{ + // call the function via its class becase it's a virtual function that is called in constructor/destructor,- + // where the vtable is not created yet or it's destructed. + HDF5MeasFileWriterV6::Close(); +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::Open(const std::string& output_dir, v3::eAccessType /*access = eAccessType::RDONLY*/) +{ + Close(); + + // Check if the given path points to a directory + if (!EcalUtils::Filesystem::IsDir(output_dir, EcalUtils::Filesystem::Current)) + return false; + + output_dir_ = output_dir; + + return true; +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::Close() +{ + if (!this->IsOk()) return false; + + std::string channels_with_entries; + + for (const auto& channel_per_name : channels_) + { + for (const auto& channel_per_id : channel_per_name.second) + { + std::ignore = CreateEntriesTableOfContentsFor(channel_per_name.first, channel_per_id.first, channel_per_id.second.Info, channel_per_id.second.Entries); + } + channels_with_entries += channel_per_name.first + ","; + } + + if ((!channels_with_entries.empty()) && (channels_with_entries.back() == ',')) + channels_with_entries.pop_back(); + + SetAttribute(file_id_, kChnAttrTitle, channels_with_entries); + + for (auto& channel_per_name : channels_) + for (auto& channel_per_id : channel_per_name.second) + channel_per_id.second.Entries.clear(); + + if (H5Fclose(file_id_) >= 0) + { + file_id_ = -1; + return true ; + } + else + { + return false; + } +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::IsOk() const +{ + return (file_id_ >= 0); +} + +std::string eCAL::eh5::HDF5MeasFileWriterV6::GetFileVersion() const +{ + // UNSUPPORTED FUNCTION + return ""; +} + +size_t eCAL::eh5::HDF5MeasFileWriterV6::GetMaxSizePerFile() const +{ + return max_size_per_file_ / 1024 / 1024; +} + +void eCAL::eh5::HDF5MeasFileWriterV6::SetMaxSizePerFile(size_t max_file_size_mib) +{ + max_size_per_file_ = max_file_size_mib * 1024 * 1024; +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::IsOneFilePerChannelEnabled() const +{ + return false; +} + +void eCAL::eh5::HDF5MeasFileWriterV6::SetOneFilePerChannelEnabled(bool /*enabled*/) +{ +} + +std::set eCAL::eh5::HDF5MeasFileWriterV6::GetChannels() const +{ + // UNSUPPORTED FUNCTION + return std::set(); +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::HasChannel(const eCAL::eh5::SChannel& /*channel*/) const +{ + // UNSUPPORTED FUNCTION + return false; +} + +eCAL::eh5::DataTypeInformation eCAL::eh5::HDF5MeasFileWriterV6::GetChannelDataTypeInformation(const SChannel& /*channel*/) const +{ + // UNSUPPORTED FUNCTION + return eCAL::eh5::DataTypeInformation{}; +} + +void eCAL::eh5::HDF5MeasFileWriterV6::SetChannelDataTypeInformation(const SChannel& channel , const eCAL::eh5::DataTypeInformation& info) +{ + channels_[channel.name][channel.id].Info = info; +} + + +long long eCAL::eh5::HDF5MeasFileWriterV6::GetMinTimestamp(const SChannel& /*channel_name*/) const +{ + // UNSUPPORTED FUNCTION + return -1; +} + +long long eCAL::eh5::HDF5MeasFileWriterV6::GetMaxTimestamp(const SChannel& /*channel_name*/) const +{ + // UNSUPPORTED FUNCTION + return -1; +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::GetEntriesInfo(const SChannel& /*channel_name*/, EntryInfoSet& /*entries*/) const +{ + // UNSUPPORTED FUNCTION + return false; +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::GetEntriesInfoRange(const SChannel& /*channel_name*/, long long /*begin*/, long long /*end*/, EntryInfoSet& /*entries*/) const +{ + // UNSUPPORTED FUNCTION + return false; +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::GetEntryDataSize(long long /*entry_id*/, size_t& /*size*/) const +{ + // UNSUPPORTED FUNCTION + return false; +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::GetEntryData(long long /*entry_id*/, void* /*data*/) const +{ + // UNSUPPORTED FUNCTION + return false; +} + +void eCAL::eh5::HDF5MeasFileWriterV6::SetFileBaseName(const std::string& base_name) +{ + base_name_ = base_name; +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::AddEntryToFile(const SWriteEntry& entry) +{ + if (!IsOk()) file_id_ = Create(); + if (!IsOk()) + return false; + + hsize_t hsSize = static_cast(entry.size); + + if (!EntryFitsTheFile(hsSize)) + { + if (cb_pre_split_ != nullptr) + { + cb_pre_split_(); + } + + if (Create() < 0) + return false; + } + + // Create DataSpace with rank 1 and size dimension + auto dataSpace = H5Screate_simple(1, &hsSize, nullptr); + + // Create creation property for dataSpace + auto dsProperty = H5Pcreate(H5P_DATASET_CREATE); + H5Pset_obj_track_times(dsProperty, false); + + // Create dataset in dataSpace + auto dataSet = H5Dcreate(file_id_, std::to_string(entries_counter_).c_str(), H5T_NATIVE_UCHAR, dataSpace, H5P_DEFAULT, dsProperty, H5P_DEFAULT); + + // Write buffer to dataset + herr_t writeStatus = H5Dwrite(dataSet, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, entry.data); + + // Close dataset, data space, and data set property + H5Dclose(dataSet); + H5Pclose(dsProperty); + H5Sclose(dataSpace); + + // TODO: check here about id vs channel.id + channels_[entry.channel.name][entry.channel.id].Entries.emplace_back(SEntryInfo(entry.rcv_timestamp, static_cast(entries_counter_), entry.clock, entry.snd_timestamp, entry.sender_id)); + + entries_counter_++; + + return (writeStatus >= 0); +} + +void eCAL::eh5::HDF5MeasFileWriterV6::ConnectPreSplitCallback(CallbackFunction cb) +{ + cb_pre_split_ = cb; +} + +void eCAL::eh5::HDF5MeasFileWriterV6::DisconnectPreSplitCallback() +{ + cb_pre_split_ = nullptr; +} + +hid_t eCAL::eh5::HDF5MeasFileWriterV6::Create() +{ + if (output_dir_.empty()) return -1; + + if (!EcalUtils::Filesystem::IsDir(output_dir_, EcalUtils::Filesystem::OsStyle::Current) + && !EcalUtils::Filesystem::MkPath(output_dir_, EcalUtils::Filesystem::OsStyle::Current)) + return -1; + + if (base_name_.empty()) return -1; + + if (IsOk() && !Close()) return -1; + + file_split_counter_++; + + std::string filePath = output_dir_ + "/" + base_name_; + + if (file_split_counter_ > 0) + filePath += "_" + std::to_string(file_split_counter_); + + filePath += ".hdf5"; + + // create file access property + hid_t fileAccessPropery = H5Pcreate(H5P_FILE_ACCESS); + // create file create property + hid_t fileCreateProperty = H5Pcreate(H5P_FILE_CREATE); + + // Create hdf file and get file id + file_id_ = H5Fcreate(filePath.c_str(), H5F_ACC_TRUNC, fileCreateProperty, fileAccessPropery); + + if (file_id_ >= 0) + SetAttribute(file_id_, kFileVerAttrTitle, "6.0"); + else + file_split_counter_--; + + return file_id_; +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::EntryFitsTheFile(const hsize_t& size) const +{ + hsize_t fileSize = 0; + bool status = GetFileSize(fileSize); + + // check if buffer fits the current file + return (status && ((fileSize + size) <= max_size_per_file_)); +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::GetFileSize(hsize_t& size) const +{ + if (!IsOk()) + { + size = 0; + return false; + } + else + { + return H5Fget_filesize(file_id_, &size) >= 0; + } +} + +bool eCAL::eh5::HDF5MeasFileWriterV6::CreateEntriesTableOfContentsFor(const std::string& channelName, std::uint64_t channelId, const DataTypeInformation& channelInfo, const EntryInfoVect& entries) const +{ + if (!IsOk()) return false; + +// const size_t dataSetsSize = entries.size(); +// if (dataSetsSize == 0) return false; + + std::string hex_id = printHex(channelId); + + // Create a group with the cannel name + auto group_name_id = OpenOrCreateGroup(file_id_, channelName); + auto group_id_id = OpenOrCreateGroup(group_name_id, hex_id); + + CreateStringEntryInRoot(file_id_, v6::GetUrl(channelName, hex_id, kChnIdTypename), channelInfo.name); + CreateStringEntryInRoot(file_id_, v6::GetUrl(channelName, hex_id, kChnIdEncoding), channelInfo.encoding); + CreateStringEntryInRoot(file_id_, v6::GetUrl(channelName, hex_id, kChnIdDescriptor), channelInfo.descriptor); + CreateInformationEntryInRoot(file_id_, v6::GetUrl(channelName, hex_id, kChnIdData), entries); + + H5Gclose(group_name_id); + H5Gclose(group_id_id); + + return true; +} + diff --git a/contrib/ecalhdf5/src/eh5_meas_file_writer_v6.h b/contrib/ecalhdf5/src/eh5_meas_file_writer_v6.h new file mode 100644 index 0000000000..8ff05339c0 --- /dev/null +++ b/contrib/ecalhdf5/src/eh5_meas_file_writer_v6.h @@ -0,0 +1,318 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +/** + * eCALHDF5 file reader single channel +**/ + +#pragma once + +#include +#include +#include +#include + +#include "eh5_meas_impl.h" + +#include "hdf5.h" + +namespace eCAL +{ + namespace eh5 + { + class HDF5MeasFileWriterV6 : virtual public HDF5MeasImpl + { + public: + /** + * @brief Constructor + **/ + HDF5MeasFileWriterV6(); + + // Copy + HDF5MeasFileWriterV6(const HDF5MeasFileWriterV6&) = delete; + HDF5MeasFileWriterV6& operator=(const HDF5MeasFileWriterV6&) = delete; + + // Move + HDF5MeasFileWriterV6& operator=(HDF5MeasFileWriterV6&&) = default; + HDF5MeasFileWriterV6(HDF5MeasFileWriterV6&&) = default; + + /** + * @brief Destructor + **/ + ~HDF5MeasFileWriterV6() override; + + /** + * @brief Open file + * + * @param output_dir Input file path / measurement directory path + * @param access Access type (IGNORED, WILL ALWAYS OPEN READ-WRITE!) + * + * @return true if succeeds, false if it fails + **/ + bool Open(const std::string& output_dir, v3::eAccessType access) override; + + /** + * @brief Close file + * + * @return true if succeeds, false if it fails + **/ + bool Close() override; + + /** + * @brief Checks if file/measurement is ok + * + * @return true if meas can be opened(read) or location is accessible(write), false otherwise + **/ + bool IsOk() const override; + + /** + * @brief Get the File Type Version of the current opened file + * + * @return file version + **/ + std::string GetFileVersion() const override; + + /** + * @brief Gets maximum allowed size for an individual file + * + * @return maximum size in MB + **/ + size_t GetMaxSizePerFile() const override; + + /** + * @brief Sets maximum allowed size for an individual file + * + * @param max_file_size_mib maximum size in MB + **/ + void SetMaxSizePerFile(size_t max_file_size_mib) override; + + /** + * @brief Whether each Channel shall be writte in its own file + * + * When enabled, data is clustered by channel and each channel is written + * to its own file. The filenames will consist of the basename and the + * channel name. + * + * @return true, if one file per channel is enabled + */ + bool IsOneFilePerChannelEnabled() const override; + + /** + * @brief Enable / disable the creation of one individual file per channel + * + * When enabled, data is clustered by channel and each channel is written + * to its own file. The filenames will consist of the basename and the + * channel name. + * + * @param enabled Whether one file shall be created per channel + */ + void SetOneFilePerChannelEnabled(bool enabled) override; + + /** + * @brief Get the available channel names of the current opened file / measurement + * + * @return channel names & ids + **/ + std::set GetChannels() const override; + + /** + * @brief Check if channel exists in measurement + * + * @param channel channel name & id + * + * @return true if exists, false otherwise + **/ + bool HasChannel(const eCAL::eh5::SChannel & channel) const override; + + /** + * @brief Get data type information of the given channel + * + * @param channel_name channel name + * + * @return channel type + **/ + DataTypeInformation GetChannelDataTypeInformation(const SChannel & channel) const override; + + /** + * @brief Set data type information of the given channel + * + * @param channel_name channel name + * @param info datatype info of the channel + * + * @return channel type + **/ + void SetChannelDataTypeInformation(const SChannel& channel, const eCAL::eh5::DataTypeInformation& info) override; + + /** + * @brief Gets minimum timestamp for specified channel + * + * @param channel_name channel name + * + * @return minimum timestamp value + **/ + long long GetMinTimestamp(const SChannel& channel) const override; + + /** + * @brief Gets maximum timestamp for specified channel + * + * @param channel_name channel name + * + * @return maximum timestamp value + **/ + long long GetMaxTimestamp(const SChannel& channele) const override; + + /** + * @brief Gets the header info for all data entries for the given channel + * Header = timestamp + entry id + * + * @param [in] channel_name channel name + * @param [out] entries header info for all data entries + * + * @return true if succeeds, false if it fails + **/ + bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const override; + + /** + * @brief Gets the header info for data entries for the given channel included in given time range (begin->end) + * Header = timestamp + entry id + * + * @param [in] channel_name channel name + * @param [in] begin time range begin timestamp + * @param [in] end time range end timestamp + * @param [out] entries header info for data entries in given range + * + * @return true if succeeds, false if it fails + **/ + bool GetEntriesInfoRange(const SChannel& channel, long long begin, long long end, EntryInfoSet& entries) const override; + + /** + * @brief Gets data size of a specific entry + * + * @param [in] entry_id Entry ID + * @param [out] size Entry data size + * + * @return true if succeeds, false if it fails + **/ + bool GetEntryDataSize(long long entry_id, size_t& size) const override; + + /** + * @brief Gets data from a specific entry + * + * @param [in] entry_id Entry ID + * @param [out] data Entry data + * + * @return true if succeeds, false if it fails + **/ + bool GetEntryData(long long entry_id, void* data) const override; + + /** + * @brief Set measurement file base name + * + * @param base_name File base name. + **/ + void SetFileBaseName(const std::string& base_name) override; + + /** + * @brief Add entry to file + * + * @param data data to be added + * @param size size of the data + * @param snd_timestamp send timestamp + * @param rcv_timestamp receive timestamp + * @param channel channel name + * @param id message id + * @param clock message clock + * + * @return true if succeeds, false if it fails + **/ + bool AddEntryToFile(const SWriteEntry& entry) override; + + using CallbackFunction = std::function; + /** + * @brief Connect callback for pre file split notification + * + * @param cb callback function + **/ + void ConnectPreSplitCallback(CallbackFunction cb) override; + + /** + * @brief Disconnect pre file split callback + **/ + void DisconnectPreSplitCallback() override; + + protected: + struct Channel + { + DataTypeInformation Info; + EntryInfoVect Entries; + }; + + using Channels = std::map>; + + std::string output_dir_; + std::string base_name_; + Channels channels_; + CallbackFunction cb_pre_split_; + hid_t file_id_; + int file_split_counter_; + unsigned long long entries_counter_; + size_t max_size_per_file_; + + /** + * @brief Creates the actual file + * + * @return file ID, file was not created if id is negative + **/ + hid_t Create(); + + /** + * @brief Checks if current file size + entry size does not exceed the maximum allowed size of the file + * + * @param size Size of the entry in bytes + * + * @return true if entry can be saved in current file, false if it can not be added to the current file + **/ + bool EntryFitsTheFile(const hsize_t& size) const; + + /** + * @brief Gets the size of the file + * + * @param size Size of the file in bytes + * + * @return true if succeeds, false if it fails + **/ + bool GetFileSize(hsize_t& size) const; + + /** + * @brief Creates the entries "table of contents" (timestamp + entry id) + * (Call it just before closing the file) + * + * @param channelName name for the dataset + * @param channelId id for the dataset (unique publisher ID) + * @param channelType type for the dataset + * @param channelDescription description for the dataset + * @param entries entries for given channel + * + * @return true if succeeds, false if it fails + **/ + bool CreateEntriesTableOfContentsFor(const std::string& channelName, std::uint64_t channelId, const DataTypeInformation& channelInfo, const EntryInfoVect& entries) const; + + }; + } // namespace eh5 +} // namespace eCAL diff --git a/contrib/ecalhdf5/src/eh5_meas_impl.h b/contrib/ecalhdf5/src/eh5_meas_impl.h index cee99fac60..97cc4fa563 100644 --- a/contrib/ecalhdf5/src/eh5_meas_impl.h +++ b/contrib/ecalhdf5/src/eh5_meas_impl.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,39 +29,6 @@ #include "ecalhdf5/eh5_types.h" -inline eCAL::eh5::DataTypeInformation CreateInfo(const std::string& combined_topic_type_, const std::string& descriptor_) -{ - eCAL::eh5::DataTypeInformation info; - auto pos = combined_topic_type_.find(':'); - if (pos == std::string::npos) - { - info.name = combined_topic_type_; - info.encoding = ""; - } - else - { - info.name = combined_topic_type_.substr(pos + 1); - info.encoding = combined_topic_type_.substr(0, pos); - } - info.descriptor = descriptor_; - return info; -} - -inline std::pair FromInfo(const eCAL::eh5::DataTypeInformation& datatype_info_) -{ - std::string combined_topic_type; - if (datatype_info_.encoding.empty()) - { - combined_topic_type = datatype_info_.name; - } - else - { - combined_topic_type = datatype_info_.encoding + ":" + datatype_info_.name; - } - - return std::make_pair(combined_topic_type, datatype_info_.descriptor); -} - namespace eCAL { namespace eh5 @@ -82,7 +49,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - virtual bool Open(const std::string& path, eAccessType access = eAccessType::RDONLY) = 0; + virtual bool Open(const std::string& path, v3::eAccessType access = v3::eAccessType::RDONLY) = 0; /** * @brief Close file @@ -141,22 +108,21 @@ namespace eCAL */ virtual void SetOneFilePerChannelEnabled(bool enabled) = 0; - /** - * @brief Get the available channel names of the current opened file / measurement - * - * @return channel names + * @brief Get the available channel names of the current opened file / measurement + * + * @return channel names & ids **/ - virtual std::set GetChannelNames() const = 0; + virtual std::set GetChannels() const = 0; /** * @brief Check if channel exists in measurement * - * @param channel_name name of the channel + * @param channel channel name & id * * @return true if exists, false otherwise **/ - virtual bool HasChannel(const std::string& channel_name) const = 0; + virtual bool HasChannel(const eCAL::eh5::SChannel& channel) const = 0; /** * @brief Get data type information of the given channel @@ -165,7 +131,7 @@ namespace eCAL * * @return channel type **/ - virtual DataTypeInformation GetChannelDataTypeInformation(const std::string& channel_name) const = 0; + virtual DataTypeInformation GetChannelDataTypeInformation(const SChannel& channel) const = 0; /** * @brief Set data type information of the given channel @@ -175,7 +141,7 @@ namespace eCAL * * @return channel type **/ - virtual void SetChannelDataTypeInformation(const std::string& channel_name, const DataTypeInformation& info) = 0; + virtual void SetChannelDataTypeInformation(const SChannel& channel, const eCAL::eh5::DataTypeInformation& info) = 0; /** * @brief Gets minimum timestamp for specified channel @@ -184,7 +150,7 @@ namespace eCAL * * @return minimum timestamp value **/ - virtual long long GetMinTimestamp(const std::string& channel_name) const = 0; + virtual long long GetMinTimestamp(const SChannel& channel) const = 0; /** * @brief Gets maximum timestamp for specified channel @@ -193,7 +159,7 @@ namespace eCAL * * @return maximum timestamp value **/ - virtual long long GetMaxTimestamp(const std::string& channel_name) const = 0; + virtual long long GetMaxTimestamp(const SChannel& channel) const = 0; /** * @brief Gets the header info for all data entries for the given channel @@ -204,7 +170,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - virtual bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const = 0; + virtual bool GetEntriesInfo(const SChannel& channel, EntryInfoSet& entries) const = 0; /** * @brief Gets the header info for data entries for the given channel included in given time range (begin->end) @@ -217,7 +183,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - virtual bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const = 0; + virtual bool GetEntriesInfoRange(const SChannel& channel, long long begin, long long end, EntryInfoSet& entries) const = 0; /** * @brief Gets data size of a specific entry @@ -259,7 +225,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - virtual bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) = 0; + virtual bool AddEntryToFile(const SWriteEntry& entry) = 0; typedef std::function CallbackFunction; /** diff --git a/contrib/ecalhdf5/src/escape.cpp b/contrib/ecalhdf5/src/escape.cpp index dfc37c75ec..cce41dfb8f 100644 --- a/contrib/ecalhdf5/src/escape.cpp +++ b/contrib/ecalhdf5/src/escape.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -576,6 +576,18 @@ namespace eCAL return GetEscapedString(non_escaped_topicname, is_reserved_topicname_); } + SChannel GetEscapedTopicname(const SChannel& input) + { + return SChannel(GetEscapedTopicname(input.name), input.id); + } + + SWriteEntry GetEscapedEntry(const SWriteEntry& input) + { + SWriteEntry escaped_entry{ input }; + escaped_entry.channel = GetEscapedTopicname(input.channel); + return escaped_entry; + } + std::string GetEscapedFilename(const std::string& non_escaped_filename) { return GetEscapedString(non_escaped_filename, is_reserved_filename_); diff --git a/contrib/ecalhdf5/src/escape.h b/contrib/ecalhdf5/src/escape.h index 4e979c7b92..cd26027964 100644 --- a/contrib/ecalhdf5/src/escape.h +++ b/contrib/ecalhdf5/src/escape.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,15 @@ #pragma once #include +#include namespace eCAL { namespace eh5 { std::string GetEscapedTopicname(const std::string& input); + SChannel GetEscapedTopicname(const SChannel& input); + SWriteEntry GetEscapedEntry(const SWriteEntry& input); std::string GetEscapedFilename(const std::string& input); std::string GetUnescapedString(const std::string& input); } diff --git a/contrib/ecalhdf5/src/hdf5_helper.cpp b/contrib/ecalhdf5/src/hdf5_helper.cpp new file mode 100644 index 0000000000..e752aefc74 --- /dev/null +++ b/contrib/ecalhdf5/src/hdf5_helper.cpp @@ -0,0 +1,274 @@ +#include "hdf5_helper.h" + +bool CreateStringEntryInRoot(hid_t root, const std::string& url, const std::string& dataset_content) +{ + // create scalar dataset + hid_t scalar_dataspace = H5Screate(H5S_SCALAR); + // create new string data type + hid_t string_data_type = H5Tcopy(H5T_C_S1); + + // if attribute's value length exists, allocate space for it + if (dataset_content.length() > 0) + H5Tset_size(string_data_type, dataset_content.length()); + // Create creation property for data_space + auto ds_property = H5Pcreate(H5P_DATASET_CREATE); + H5Pset_obj_track_times(ds_property, false); + //H5Pset_create_intermediate_group(ds_property, 1); + + // create attribute + hid_t data_set = H5Dcreate(root, url.c_str(), string_data_type, scalar_dataspace, H5P_DEFAULT, ds_property, H5P_DEFAULT); + if (data_set < 0) return false; + + auto write_status = H5Dwrite(data_set, string_data_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, dataset_content.c_str()); + if (write_status < 0) return false; + + // close all created stuff + H5Dclose(data_set); + H5Pclose(ds_property); + H5Tclose(string_data_type); + H5Sclose(scalar_dataspace); + + return true; +} + + +bool ReadStringEntryAsString(hid_t root, const std::string& url, std::string& data) +{ + // empty attribute value + data.clear(); + if (root < 0) return false; + + auto dataset_id = H5Dopen(root, url.c_str(), H5P_DEFAULT); + if (dataset_id < 0) return false; + + auto size = H5Dget_storage_size(dataset_id); + data.resize(size); + + herr_t read_status = -1; + if (size >= 0) + { + hid_t string_data_type = H5Tcopy(H5T_C_S1); + H5Tset_size(string_data_type, size); + read_status = H5Dread(dataset_id, string_data_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, static_cast(const_cast(data.data()))); + } + + H5Dclose(dataset_id); + return (read_status >= 0); +} + +// status = H5Dread(dset, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); +bool CreateBinaryEntryInRoot(hid_t root, const std::string& url, const std::string& dataset_content) +{ + + hsize_t hs_size = static_cast(dataset_content.size()); + // Create DataSpace with rank 1 and size dimension + auto data_space = H5Screate_simple(1, &hs_size, nullptr); + // Create creation property for data_space + auto ds_property = H5Pcreate(H5P_DATASET_CREATE); + H5Pset_obj_track_times(ds_property, false); + //H5Pset_create_intermediate_group(ds_property, 1); + // Create dataset in data_space + auto data_set = H5Dcreate(root, url.c_str(), H5T_NATIVE_UCHAR, data_space, H5P_DEFAULT, ds_property, H5P_DEFAULT); + + // Write buffer to dataset + herr_t write_status = H5Dwrite(data_set, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, dataset_content.c_str()); + + // Close dataset, data space, and data set property + H5Dclose(data_set); + H5Pclose(ds_property); + H5Sclose(data_space); + + return (write_status >= 0); +} + +bool ReadBinaryEntryAsString(hid_t root, const std::string& url, std::string& data) +{ + data.clear(); + + auto dataset_id = H5Dopen(root, url.c_str(), H5P_DEFAULT); + if (dataset_id < 0) return false; + + auto size = H5Dget_storage_size(dataset_id); + data.resize(size); + + herr_t read_status = -1; + if (size >= 0) + { + read_status = H5Dread(dataset_id, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, static_cast(const_cast(data.data()))); + } + + H5Dclose(dataset_id); + return (read_status >= 0); +} + + +bool CreateInformationEntryInRoot(hid_t root, const std::string& url, const eCAL::eh5::EntryInfoVect& entries) +{ + const size_t dataSetsSize = entries.size(); + hsize_t dims[2] = { dataSetsSize, 5 }; + // Create DataSpace with rank 2 and size dimension + auto dataSpace = H5Screate_simple(2, dims, nullptr); + // Create creation property for data_space + auto dsProperty = H5Pcreate(H5P_DATASET_CREATE); + H5Pset_obj_track_times(dsProperty, false); + auto dataSet = H5Dcreate(root, url.c_str(), H5T_NATIVE_LLONG, dataSpace, H5P_DEFAULT, dsProperty, H5P_DEFAULT); + if (dataSet < 0) return false; + + // Write buffer to dataset + herr_t writeStatus = H5Dwrite(dataSet, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, entries.data()); + if (writeStatus < 0) return false; + + // Close dataset, data space, and data set property + H5Dclose(dataSet); + H5Pclose(dsProperty); + H5Sclose(dataSpace); + + return true; +} + +bool GetEntryInfoVector(hid_t root, const std::string& url, eCAL::eh5::EntryInfoSet& entries) +{ + entries.clear(); + + auto dataset_id = H5Dopen(root, url.c_str(), H5P_DEFAULT); + + if (dataset_id < 0) return false; + + const size_t sizeof_ll = sizeof(long long); + hsize_t data_size = H5Dget_storage_size(dataset_id) / sizeof_ll; + + if (data_size <= 0) return false; + + std::vector data(data_size); + herr_t status = H5Dread(dataset_id, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data[0]); + H5Dclose(dataset_id); + + for (unsigned int index = 0; index < data_size; index += 5) + { + // rec timestamp, channel id, send clock, send time stamp, send ID + entries.emplace(eCAL::eh5::SEntryInfo(data[index], data[index + 1], data[index + 2], data[index + 3], data[index + 4])); + } + + return (status >= 0); +} + +bool SetAttribute(hid_t id, const std::string& name, const std::string& value) +{ + if (id < 0) return false; + + if (H5Aexists(id, name.c_str()) > 0) + H5Adelete(id, name.c_str()); + // create scalar dataset + hid_t scalarDataset = H5Screate(H5S_SCALAR); + + // create new string data type + hid_t stringDataType = H5Tcopy(H5T_C_S1); + + // if attribute's value length exists, allocate space for it + if (value.length() > 0) + H5Tset_size(stringDataType, value.length()); + + // create attribute + hid_t attribute = H5Acreate(id, name.c_str(), stringDataType, scalarDataset, H5P_DEFAULT, H5P_DEFAULT); + + if (attribute < 0) return false; + + // write attribute value to attribute + herr_t writeStatus = H5Awrite(attribute, stringDataType, value.c_str()); + if (writeStatus < 0) return false; + + // close attribute + H5Aclose(attribute); + // close scalar dataset + H5Sclose(scalarDataset); + // close string data type + H5Tclose(stringDataType); + + return true; +} + +bool GetAttribute(hid_t id, const std::string& name, std::string& value) +{ + bool ret_val = false; + // empty attribute value + value.clear(); + if (id < 0) return false; + + // check if attribute exists + if (H5Aexists(id, name.c_str()) != 0) + { + // open attribute by name, getting the attribute index + hid_t attr_id = H5Aopen_name(id, name.c_str()); + // fail - attribute can not be opened + if (attr_id <= 0) return false; + + // get attribute type + hid_t attr_type = H5Aget_type(attr_id); + // get type class based on attribute type + H5T_class_t type_class = H5Tget_class(attr_type); + // get attribute content dataSize + const size_t attr_size = H5Tget_size(attr_type); + + // if attribute class is string + if (type_class == H5T_STRING) + { + hid_t attr_type_mem = H5Tget_native_type(attr_type, H5T_DIR_ASCEND); + // create buffer to store the value of the attribute + std::vector content_buffer(attr_size); + // get attribute value + ret_val = (H5Aread(attr_id, attr_type_mem, &content_buffer[0]) >= 0); + + // convert value to std string + value = std::string(&content_buffer[0], attr_size); + } + else + { + // fail - attribute is not string type + ret_val = false; + } + // close attribute + H5Aclose(attr_id); + } + else + { + // fail - attribute name does not exist + ret_val = false; + } + // return read status + return ret_val; +} + +bool HasGroup(hid_t root, const std::string& path) +{ + hid_t exists = H5Lexists(root, path.c_str(), H5P_DEFAULT); + return (exists > 0); +} + +hid_t OpenOrCreateGroup(hid_t root, const std::string& name) +{ + hid_t group; + if (HasGroup(root, name)) + { + group = H5Gopen(root, name.c_str(), H5P_DEFAULT); + } + else + { + group = H5Gcreate(root, name.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } + + return group; +} + +std::vector ListSubgroups(hid_t id) +{ + std::vector group_vector; + auto iterate_lambda = [](hid_t /*group*/, const char* name, const H5L_info_t* /*info*/, void* op_data)->herr_t + { + auto vec = static_cast*>(op_data); + vec->push_back(name); + return 0; + }; + + H5Literate(id, H5_INDEX_NAME, H5_ITER_INC, nullptr, iterate_lambda, (void*)&group_vector); + return group_vector; +} \ No newline at end of file diff --git a/contrib/ecalhdf5/src/hdf5_helper.h b/contrib/ecalhdf5/src/hdf5_helper.h new file mode 100644 index 0000000000..6df5544800 --- /dev/null +++ b/contrib/ecalhdf5/src/hdf5_helper.h @@ -0,0 +1,68 @@ +#pragma once + +#include +#include +#include + +#include + +#include + +bool CreateStringEntryInRoot(hid_t root, const std::string& url, const std::string& dataset_content); +bool ReadStringEntryAsString(hid_t root, const std::string& url, std::string& data); + +bool CreateBinaryEntryInRoot(hid_t root, const std::string& url, const std::string& dataset_content); +bool ReadBinaryEntryAsString(hid_t root, const std::string& url, std::string& data); + +bool CreateInformationEntryInRoot(hid_t root, const std::string& url, const eCAL::eh5::EntryInfoVect& entries); +bool GetEntryInfoVector(hid_t root, const std::string& url, eCAL::eh5::EntryInfoSet& entries); + +/** +* @brief Set attribute to object(file, entry...) +* +* @param id ID of the attributes parent +* @param name Name of the attribute +* @param value Value of the attribute +* +* @return true if succeeds, false if it fails +**/ +bool SetAttribute(hid_t id, const std::string& name, const std::string& value); +/** +* @brief Gets the value of a string attribute +* +* @param [in] obj_id ID of the attribute's parent +* @param [in] name Name of the attribute +* @param [out] value Value of the attribute +* +* @return true if succeeds, false if it fails +**/ +bool GetAttribute(hid_t id, const std::string& name, std::string& value); + +bool HasGroup(hid_t root, const std::string& path); + +hid_t OpenOrCreateGroup(hid_t root, const std::string& name); + +std::vector ListSubgroups(hid_t id); + + +inline std::string printHex(eCAL::experimental::measurement::base::Channel::id_t id) +{ + std::stringstream ss; + ss << std::hex << std::setw(16) << std::setfill('0') << std::uppercase << id; + return ss.str(); +} + +inline eCAL::experimental::measurement::base::Channel::id_t parseHexID(std::string string_id) +{ + auto unsigned_value = std::stoull(string_id, 0, 16); + return static_cast(unsigned_value); +} + +namespace v6 +{ + inline std::string GetUrl(const std::string& channel_name_, const std::string& channel_id, const std::string& attribute) + { + return "/" + channel_name_ + "/" + channel_id + "/" + attribute; + //return "/" + channel_name_ + "/" + attribute; + } +} \ No newline at end of file diff --git a/contrib/ecaltime/simtime/src/ecal_time_simtime.cpp b/contrib/ecaltime/simtime/src/ecal_time_simtime.cpp index 98e748cbd9..c847816fb8 100644 --- a/contrib/ecaltime/simtime/src/ecal_time_simtime.cpp +++ b/contrib/ecaltime/simtime/src/ecal_time_simtime.cpp @@ -39,7 +39,7 @@ bool eCAL::CSimTime::initialize() { std::unique_lock lk(initialize_mutex); if (!is_initialized) { - //eCAL::Initialize(0, NULL, "ecal_sim_time_listener", eCAL::Init::Subscriber); + //eCAL::Initialize("ecal_sim_time_listener", eCAL::Init::Subscriber); // this has to be done by the parent process // needs to be fixed with an improved reference counting // in eCAL::Initialize .. diff --git a/contrib/measurement/base/include/ecal/measurement/base/reader.h b/contrib/measurement/base/include/ecal/measurement/base/reader.h index 557b94d887..fcc9999075 100644 --- a/contrib/measurement/base/include/ecal/measurement/base/reader.h +++ b/contrib/measurement/base/include/ecal/measurement/base/reader.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,68 +114,81 @@ namespace eCAL * * @return channel names **/ - virtual std::set GetChannelNames() const = 0; + /*virtual std::set GetChannelNames() const = 0;*/ + + /** + * @brief Get the available channel names of the current opened file / measurement + * + * @return Channels (channel name & id) + **/ + virtual std::set GetChannels() const = 0; + + /** + * @brief Get the available channel names of the current opened file / measurement + * + * @return Channels (channel name & id) + **/ + /*virtual std::set GetChannels(const std::string& channel_name) const = 0;*/ /** * @brief Check if channel exists in measurement * - * @param channel_name name of the channel + * @param channel The channel (channel name & id) * * @return true if exists, false otherwise **/ - virtual bool HasChannel(const std::string& channel_name) const = 0; + virtual bool HasChannel(const eCAL::experimental::measurement::base::Channel& channel) const = 0; /** * @brief Get data type information of the given channel * - * @param channel_name channel name + * @param channel (channel name & id) * * @return channel type **/ - virtual DataTypeInformation GetChannelDataTypeInformation(const std::string & channel_name) const = 0; - + virtual DataTypeInformation GetChannelDataTypeInformation(const eCAL::experimental::measurement::base::Channel& channel) const = 0; /** * @brief Gets minimum timestamp for specified channel * - * @param channel_name channel name + * @param channel (channel name & id) * * @return minimum timestamp value **/ - virtual long long GetMinTimestamp(const std::string& channel_name) const = 0; + virtual long long GetMinTimestamp(const eCAL::experimental::measurement::base::Channel& channel) const = 0; /** * @brief Gets maximum timestamp for specified channel * - * @param channel_name channel name + * @param channel (channel name & id) * * @return maximum timestamp value **/ - virtual long long GetMaxTimestamp(const std::string& channel_name) const = 0; + virtual long long GetMaxTimestamp(const eCAL::experimental::measurement::base::Channel & channel) const = 0; /** * @brief Gets the header info for all data entries for the given channel * Header = timestamp + entry id * - * @param [in] channel_name channel name + * @param [in] channel (channel name & id) * @param [out] entries header info for all data entries * * @return true if succeeds, false if it fails **/ - virtual bool GetEntriesInfo(const std::string& channel_name, EntryInfoSet& entries) const = 0; + virtual bool GetEntriesInfo(const eCAL::experimental::measurement::base::Channel & channel, EntryInfoSet& entries) const = 0; /** * @brief Gets the header info for data entries for the given channel included in given time range (begin->end) * Header = timestamp + entry id * - * @param [in] channel_name channel name + * @param [in] channel (channel name & id) * @param [in] begin time range begin timestamp * @param [in] end time range end timestamp * @param [out] entries header info for data entries in given range * * @return true if succeeds, false if it fails **/ - virtual bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, EntryInfoSet& entries) const = 0; + virtual bool GetEntriesInfoRange(const eCAL::experimental::measurement::base::Channel& channel, long long begin, long long end, EntryInfoSet& entries) const = 0; /** * @brief Gets data size of a specific entry diff --git a/contrib/measurement/base/include/ecal/measurement/base/types.h b/contrib/measurement/base/include/ecal/measurement/base/types.h index 0906824716..43a3b5dad7 100644 --- a/contrib/measurement/base/include/ecal/measurement/base/types.h +++ b/contrib/measurement/base/include/ecal/measurement/base/types.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,9 @@ #pragma once +#include #include +#include #include namespace eCAL @@ -42,33 +44,88 @@ namespace eCAL **/ struct DataTypeInformation { - std::string name; //!< name of the datatype - std::string encoding; //!< encoding of the datatype (e.g. protobuf, flatbuffers, capnproto) - std::string descriptor; //!< descriptor information of the datatype (necessary for reflection) + std::string name = ""; //!< name of the datatype + std::string encoding = ""; //!< encoding of the datatype (e.g. protobuf, flatbuffers, capnproto) + std::string descriptor = ""; //!< descriptor information of the datatype (necessary for reflection) //!< @cond bool operator==(const DataTypeInformation& other) const { - return name == other.name && encoding == other.encoding && descriptor == other.descriptor; + return std::tie(name, encoding, descriptor) == std::tie(other.name, other.encoding, other.descriptor); } bool operator!=(const DataTypeInformation& other) const { return !(*this == other); } + + bool operator<(const DataTypeInformation& other) const + { + return std::tie(name, encoding, descriptor) < std::tie(other.name, other.encoding, other.descriptor); + } //!< @endcond }; + struct Channel + { + using id_t = std::int64_t; + + std::string name = ""; + id_t id = 0; + + Channel() = default; + Channel(const std::string name_, id_t id_) : name(name_), id(id_) {}; + + //!< @cond + bool operator==(const Channel& other) const + { + return std::tie(id, name) == std::tie(other.id, other.name); + } + + bool operator!=(const Channel& other) const + { + return !(*this == other); + } + + bool operator<(const Channel& other) const + { + return std::tie(id, name) < std::tie(other.id, other.name); + } + //!< @endcond + }; + + inline Channel CreateChannel(const std::string& name) + { + return Channel{ name, 0 }; + } + + struct WriteEntry + { + // channel + Channel channel; + + // data + const void* data = nullptr; + unsigned long long size = 0; + + // metadata + long long snd_timestamp = 0; + long long rcv_timestamp = 0; + long long sender_id = 0; // Unique ID which may be set by sender + long long clock = 0; + }; + + /** * @brief Info struct for a single measurement entry **/ struct EntryInfo { long long RcvTimestamp; //!< Receive time stamp - long long ID; //!< Channel ID + long long ID; //!< Data ID - to extract corresponding data long long SndClock; //!< Send clock long long SndTimestamp; //!< Send time stamp - long long SndID; //!< Send ID + long long SndID; //!< Send ID (!= channel ID!!!!) //!< @cond EntryInfo() : RcvTimestamp(0), ID(0), SndClock(0), SndTimestamp(0), SndID(0) {} @@ -103,16 +160,21 @@ namespace eCAL **/ using EntryInfoVect = std::vector; - /** - * @brief eCAL Measurement Access types - **/ - enum AccessType - { - RDONLY, //!< ReadOnly - the measurement can only be read - CREATE //!< Create - a new measurement will be created - }; - } } } +} + +namespace std { + template <> + struct hash { + std::size_t operator()(const eCAL::experimental::measurement::base::Channel& data) const { + // Combine the hash of the string and the integer + std::size_t h1 = std::hash{}(data.name); + std::size_t h2 = std::hash{}(data.id); + + // Combine the two hashes (this is a common technique) + return h1 ^ (h2 << 1); // XOR and shift + } + }; } \ No newline at end of file diff --git a/contrib/measurement/base/include/ecal/measurement/base/writer.h b/contrib/measurement/base/include/ecal/measurement/base/writer.h index 9eb003290c..c092fcd3f5 100644 --- a/contrib/measurement/base/include/ecal/measurement/base/writer.h +++ b/contrib/measurement/base/include/ecal/measurement/base/writer.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -146,7 +146,7 @@ namespace eCAL * * @return channel type **/ - virtual void SetChannelDataTypeInformation(const std::string & channel_name, const DataTypeInformation& info) = 0; + virtual void SetChannelDataTypeInformation(const eCAL::experimental::measurement::base::Channel& channel_name, const DataTypeInformation& info) = 0; /** * @brief Set measurement file base name (desired name for the actual hdf5 files that will be created) @@ -168,8 +168,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - virtual bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) = 0; - + virtual bool AddEntryToFile(const base::WriteEntry& entry) = 0; }; } } diff --git a/contrib/measurement/base/include/ecal/measurement/imeasurement.h b/contrib/measurement/base/include/ecal/measurement/imeasurement.h index 95d89f8da1..11bc011a72 100644 --- a/contrib/measurement/base/include/ecal/measurement/imeasurement.h +++ b/contrib/measurement/base/include/ecal/measurement/imeasurement.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,11 +35,11 @@ namespace eCAL class IBinaryChannel { public: - IBinaryChannel(std::shared_ptr meas_, std::string name_) - : channel_name(name_) + IBinaryChannel(std::shared_ptr meas_, experimental::measurement::base::Channel channel_) + : channel(channel_) , meas(meas_) { - meas->GetEntriesInfo(channel_name, entry_infos); + meas->GetEntriesInfo(channel, entry_infos); } virtual BinaryFrame operator[](const experimental::measurement::base::EntryInfo& entry) @@ -53,7 +53,7 @@ namespace eCAL std::string name() { - return channel_name; + return channel.name; } class iterator /*: public std::iterator>*/ @@ -100,7 +100,7 @@ namespace eCAL mutable std::string m_msg; }; - bool operator==(const IBinaryChannel& rhs) const { return channel_name == rhs.channel_name && meas == rhs.meas; /*return it == rhs.it; */ }; + bool operator==(const IBinaryChannel& rhs) const { return channel == rhs.channel && meas == rhs.meas; /*return it == rhs.it; */ }; bool operator!=(const IBinaryChannel& rhs) const { return !(operator==(rhs)); /*return it == rhs.it; */ }; iterator begin() @@ -114,7 +114,7 @@ namespace eCAL } private: - const std::string channel_name; + const experimental::measurement::base::Channel channel; std::shared_ptr meas; mutable experimental::measurement::base::EntryInfoSet entry_infos; mutable std::string data; @@ -125,8 +125,8 @@ namespace eCAL class IChannel { public: - IChannel(std::shared_ptr meas_, std::string name_) - : binary_channel(meas_, name_) + IChannel(std::shared_ptr meas_, const experimental::measurement::base::Channel& channel_) + : binary_channel(meas_, channel_) { } @@ -219,10 +219,11 @@ namespace eCAL public: IMeasurement(const std::string& path); - ChannelSet ChannelNames() const; + ChannelSet Channels() const; + ChannelSet Channels(const std::string& channel_name) const; template - IChannel Get(const std::string& channel) const; + IChannel Get(const experimental::measurement::base::Channel& channel) const; private: std::shared_ptr meas; @@ -233,9 +234,23 @@ namespace eCAL { } - inline ChannelSet IMeasurement::ChannelNames() const + inline ChannelSet IMeasurement::Channels() const { - return meas->GetChannelNames(); + return meas->GetChannels(); + } + + // This is probably not very performant. We should check! + inline ChannelSet IMeasurement::Channels(const std::string& channel_name) const + { + ChannelSet channels_filtered_by_name; + auto all_channels = meas->GetChannels(); + for (const auto& channel : all_channels) { + if (channel.name == channel_name) + { + channels_filtered_by_name.insert(channel); + } + } + return channels_filtered_by_name; } // This will return a nullptr if channel name and @@ -243,14 +258,14 @@ namespace eCAL // a) channel does not exist in the IMeasurement // b) the registered type does not match with the descriptor in the chanenel template - inline IChannel IMeasurement::Get(const std::string& channel) const + inline IChannel IMeasurement::Get(const experimental::measurement::base::Channel& channel) const { // Assert that the channel is in the IMeasurement - auto channels = ChannelNames(); + auto channels = Channels(); if (channels.find(channel) == channels.end()) { // Throw an exception, if channel is not available? - throw std::out_of_range("The channel " + channel + " does not exist in this measurement"); + throw std::out_of_range("The channel {" + channel.name + ", " + std::to_string(channel.id) + "} does not exist in this measurement"); } // Assert that the channel type is compatible with the requested type diff --git a/contrib/measurement/base/include/ecal/measurement/measurement.h b/contrib/measurement/base/include/ecal/measurement/measurement.h index 720445d5d4..19ece11e8c 100644 --- a/contrib/measurement/base/include/ecal/measurement/measurement.h +++ b/contrib/measurement/base/include/ecal/measurement/measurement.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ namespace eCAL { namespace measurement { - using ChannelSet = std::set; + using ChannelSet = std::set; struct SenderID { diff --git a/contrib/measurement/base/include/ecal/measurement/omeasurement.h b/contrib/measurement/base/include/ecal/measurement/omeasurement.h index 09f92c3763..46fe1d0fc2 100644 --- a/contrib/measurement/base/include/ecal/measurement/omeasurement.h +++ b/contrib/measurement/base/include/ecal/measurement/omeasurement.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,36 +34,46 @@ namespace eCAL class OBinaryChannel { public: - OBinaryChannel(std::shared_ptr meas_, const std::string& name_) - : channel_name(name_) + OBinaryChannel(std::shared_ptr meas_, const std::string& name_, const eCAL::experimental::measurement::base::DataTypeInformation& datatype_info) + : channel(name_, 0) , meas(meas_) - , SenderID(0) + , id(0) , clock(0) { + meas->SetChannelDataTypeInformation(channel, datatype_info); } OBinaryChannel& operator<<(const BinaryFrame& entry_) { - meas->AddEntryToFile((void*)entry_.message.data(), entry_.message.size(), entry_.send_timestamp, entry_.receive_timestamp, channel_name, SenderID, clock); + eCAL::experimental::measurement::base::WriteEntry entry; + entry.channel = channel; + entry.data = entry_.message.data(); + entry.size = entry_.message.size(); + entry.snd_timestamp = entry_.send_timestamp; + entry.rcv_timestamp = entry_.receive_timestamp; + entry.sender_id = id; + entry.clock = clock; + + meas->AddEntryToFile(entry); ++clock; return *this; } OBinaryChannel& operator<<(const SenderID& id_) { - SenderID = id_.ID; + id = id_.ID; return *this; } - bool operator==(const OBinaryChannel& rhs) const { return channel_name == rhs.channel_name && meas == rhs.meas; /*return it == rhs.it; */ }; + bool operator==(const OBinaryChannel& rhs) const { return channel == rhs.channel && meas == rhs.meas; /*return it == rhs.it; */ }; bool operator!=(const OBinaryChannel& rhs) const { return !(operator==(rhs)); /*return it == rhs.it; */ }; private: - const std::string channel_name; + const experimental::measurement::base::Channel channel; std::shared_ptr meas; - long long SenderID; + long long id; long long clock; }; @@ -72,8 +82,8 @@ namespace eCAL class OChannel { public: - OChannel(std::shared_ptr meas_, std::string name_) - : binary_channel(meas_, name_) + OChannel(std::shared_ptr meas_, std::string name_, const eCAL::experimental::measurement::base::DataTypeInformation& datatype_info) + : binary_channel(meas_, name_, datatype_info) { } @@ -137,9 +147,8 @@ namespace eCAL eCAL::message::GetEncoding(msg), eCAL::message::GetDescription(msg) }; - meas->SetChannelDataTypeInformation(channel, datatype_info); - // Construct a channel based - return OChannel{meas, channel}; + // Construct a channel based + return OChannel{meas, channel, datatype_info}; } diff --git a/contrib/measurement/hdf5/include/ecal/measurement/hdf5/reader.h b/contrib/measurement/hdf5/include/ecal/measurement/hdf5/reader.h index c626b2efab..f5eeb21111 100644 --- a/contrib/measurement/hdf5/include/ecal/measurement/hdf5/reader.h +++ b/contrib/measurement/hdf5/include/ecal/measurement/hdf5/reader.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,20 +27,16 @@ #include #include - namespace eCAL { - namespace eh5 - { - class HDF5Meas; - } - namespace experimental { namespace measurement { namespace hdf5 { + struct ReaderImpl; + /** * @brief Hdf5 based Reader Implementation **/ @@ -124,7 +120,21 @@ namespace eCAL * * @return channel names **/ - std::set GetChannelNames() const override; + //std::set GetChannelNames() const override; + + /** + * @brief Get the available channel names of the current opened file / measurement + * + * @return Channels (channel name & id) + **/ + std::set GetChannels() const override; + + /** + * @brief Get the available channel names of the current opened file / measurement + * + * @return Channels (channel name & id) + **/ + //std::set GetChannels(const std::string& channel_name) const override; /** * @brief Check if channel exists in measurement @@ -133,7 +143,7 @@ namespace eCAL * * @return true if exists, false otherwise **/ - bool HasChannel(const std::string& channel_name) const override; + bool HasChannel(const eCAL::experimental::measurement::base::Channel& channel) const override; /** * @brief Get data type information of the given channel @@ -142,7 +152,7 @@ namespace eCAL * * @return channel type **/ - base::DataTypeInformation GetChannelDataTypeInformation(const std::string& channel_name) const override; + base::DataTypeInformation GetChannelDataTypeInformation(const eCAL::experimental::measurement::base::Channel& channel) const override; /** * @brief Gets minimum timestamp for specified channel @@ -151,7 +161,7 @@ namespace eCAL * * @return minimum timestamp value **/ - long long GetMinTimestamp(const std::string& channel_name) const override; + long long GetMinTimestamp(const eCAL::experimental::measurement::base::Channel& channel) const override; /** * @brief Gets maximum timestamp for specified channel @@ -160,7 +170,7 @@ namespace eCAL * * @return maximum timestamp value **/ - long long GetMaxTimestamp(const std::string& channel_name) const override; + long long GetMaxTimestamp(const eCAL::experimental::measurement::base::Channel& channel) const override; /** * @brief Gets the header info for all data entries for the given channel @@ -171,7 +181,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfo(const std::string& channel_name, measurement::base::EntryInfoSet& entries) const override; + bool GetEntriesInfo(const eCAL::experimental::measurement::base::Channel& channel, measurement::base::EntryInfoSet& entries) const override; /** * @brief Gets the header info for data entries for the given channel included in given time range (begin->end) @@ -184,7 +194,7 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, measurement::base::EntryInfoSet& entries) const override; + bool GetEntriesInfoRange(const eCAL::experimental::measurement::base::Channel& channel, long long begin, long long end, measurement::base::EntryInfoSet& entries) const override; /** * @brief Gets data size of a specific entry @@ -207,7 +217,7 @@ namespace eCAL bool GetEntryData(long long entry_id, void* data) const override; private: - std::unique_ptr measurement; + std::unique_ptr impl; }; diff --git a/contrib/measurement/hdf5/include/ecal/measurement/hdf5/writer.h b/contrib/measurement/hdf5/include/ecal/measurement/hdf5/writer.h index 355bccc2e4..3d11703a47 100644 --- a/contrib/measurement/hdf5/include/ecal/measurement/hdf5/writer.h +++ b/contrib/measurement/hdf5/include/ecal/measurement/hdf5/writer.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,17 +33,14 @@ namespace eCAL { - namespace eh5 - { - class HDF5Meas; - } - namespace experimental { namespace measurement { namespace hdf5 { + struct WriterImpl; + /** * @brief Hdf5 based Writer implementation **/ @@ -156,7 +153,7 @@ namespace eCAL * * @return channel type **/ - void SetChannelDataTypeInformation(const std::string& channel_name, const base::DataTypeInformation& info) override; + void SetChannelDataTypeInformation(const eCAL::experimental::measurement::base::Channel& channel, const base::DataTypeInformation& info) override; /** * @brief Set measurement file base name (desired name for the actual hdf5 files that will be created) @@ -178,10 +175,10 @@ namespace eCAL * * @return true if succeeds, false if it fails **/ - bool AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) override; + bool AddEntryToFile(const base::WriteEntry& entry) override; private: - std::unique_ptr measurement; + std::unique_ptr impl; }; } // namespace hdf5 } // namespace measurement diff --git a/contrib/measurement/hdf5/src/reader.cpp b/contrib/measurement/hdf5/src/reader.cpp index 2f9f3fd18b..064d7df48d 100644 --- a/contrib/measurement/hdf5/src/reader.cpp +++ b/contrib/measurement/hdf5/src/reader.cpp @@ -5,12 +5,34 @@ using namespace eCAL::experimental::measurement::hdf5; using namespace eCAL::experimental::measurement; +namespace eCAL +{ + namespace experimental + { + namespace measurement + { + namespace hdf5 + { + struct ReaderImpl + { + eCAL::eh5::HDF5Meas measurement; + + ReaderImpl() = default; + ReaderImpl(const std::string& path) + : measurement(path, eCAL::eh5::eAccessType::RDONLY) + {} + }; + } + } + } +} + Reader::Reader() - : measurement(std::make_unique()) + : impl(std::make_unique()) {} Reader::Reader(const std::string& path) - : measurement(std::make_unique(path, eh5::eAccessType::RDONLY)) + : impl(std::make_unique(path)) {} Reader::~Reader() = default; @@ -21,65 +43,77 @@ Reader& Reader::operator=(Reader&&) noexcept = default; bool Reader::Open(const std::string& path) { - return measurement->Open(path, eh5::eAccessType::RDONLY); + return impl->measurement.Open(path, eCAL::eh5::eAccessType::RDONLY); } bool Reader::Close() { - return measurement->Close(); + return impl->measurement.Close(); } bool Reader::IsOk() const { - return measurement->IsOk(); + return impl->measurement.IsOk(); } std::string Reader::GetFileVersion() const { - return measurement->GetFileVersion(); + return impl->measurement.GetFileVersion(); } +/* std::set Reader::GetChannelNames() const { - return measurement->GetChannelNames(); + return impl->measurement.GetChannelNames(); +}*/ + +std::set eCAL::experimental::measurement::hdf5::Reader::GetChannels() const +{ + return impl->measurement.GetChannels(); } -bool Reader::HasChannel(const std::string& channel_name) const +/* +std::set eCAL::experimental::measurement::hdf5::Reader::GetChannels(const std::string& channel_name) const +{ + return impl->measurement.GetChannels(channel_name); +}*/ + +bool Reader::HasChannel(const eCAL::experimental::measurement::base::Channel& channel) const { - return measurement->HasChannel(channel_name); + return impl->measurement.HasChannel(channel); } -base::DataTypeInformation Reader::GetChannelDataTypeInformation(const std::string& channel_name) const +base::DataTypeInformation Reader::GetChannelDataTypeInformation(const base::Channel& channel) const { - return measurement->GetChannelDataTypeInformation(channel_name); + return impl->measurement.GetChannelDataTypeInformation(channel); } -long long Reader::GetMinTimestamp(const std::string& channel_name) const +long long Reader::GetMinTimestamp(const base::Channel& channel) const { - return measurement->GetMinTimestamp(channel_name); + return impl->measurement.GetMinTimestamp(channel); } -long long Reader::GetMaxTimestamp(const std::string& channel_name) const +long long Reader::GetMaxTimestamp(const base::Channel& channel) const { - return measurement->GetMaxTimestamp(channel_name); + return impl->measurement.GetMaxTimestamp(channel); } -bool Reader::GetEntriesInfo(const std::string& channel_name, base::EntryInfoSet& entries) const +bool Reader::GetEntriesInfo(const base::Channel& channel, base::EntryInfoSet& entries) const { - return measurement->GetEntriesInfo(channel_name, entries); + return impl->measurement.GetEntriesInfo(channel, entries); } -bool Reader::GetEntriesInfoRange(const std::string& channel_name, long long begin, long long end, base::EntryInfoSet& entries) const +bool Reader::GetEntriesInfoRange(const base::Channel& channel, long long begin, long long end, base::EntryInfoSet& entries) const { - return measurement->GetEntriesInfoRange(channel_name, begin, end, entries); + return impl->measurement.GetEntriesInfoRange(channel, begin, end, entries); } bool Reader::GetEntryDataSize(long long entry_id, size_t& size) const { - return measurement->GetEntryDataSize(entry_id, size); + return impl->measurement.GetEntryDataSize(entry_id, size); } bool Reader::GetEntryData(long long entry_id, void* data) const { - return measurement->GetEntryData(entry_id, data); + return impl->measurement.GetEntryData(entry_id, data); } \ No newline at end of file diff --git a/contrib/measurement/hdf5/src/writer.cpp b/contrib/measurement/hdf5/src/writer.cpp index 34fd56717e..783a73838a 100644 --- a/contrib/measurement/hdf5/src/writer.cpp +++ b/contrib/measurement/hdf5/src/writer.cpp @@ -4,12 +4,34 @@ using namespace eCAL::experimental::measurement::hdf5; using namespace eCAL::experimental::measurement; +namespace eCAL +{ + namespace experimental + { + namespace measurement + { + namespace hdf5 + { + struct WriterImpl + { + eCAL::eh5::HDF5Meas measurement; + + WriterImpl() = default; + WriterImpl(const std::string& path) + : measurement(path, eCAL::eh5::eAccessType::CREATE) + {} + }; + } + } + } +} + Writer::Writer() - : measurement(std::make_unique()) + : impl(std::make_unique()) {} Writer::Writer(const std::string& path) - : measurement(std::make_unique(path, eh5::eAccessType::CREATE)) + : impl(std::make_unique(path)) {} Writer::~Writer() = default; @@ -20,50 +42,50 @@ Writer& Writer::operator=(Writer&&) noexcept = default; bool Writer::Open(const std::string& path) { - return measurement->Open(path, eh5::eAccessType::CREATE); + return impl->measurement.Open(path, eCAL::eh5::eAccessType::CREATE); } bool Writer::Close() { - return measurement->Close(); + return impl->measurement.Close(); } bool Writer::IsOk() const { - return measurement->IsOk(); + return impl->measurement.IsOk(); } size_t Writer::GetMaxSizePerFile() const { - return measurement->GetMaxSizePerFile(); + return impl->measurement.GetMaxSizePerFile(); } void Writer::SetMaxSizePerFile(size_t size) { - return measurement->SetMaxSizePerFile(size); + return impl->measurement.SetMaxSizePerFile(size); } bool Writer::IsOneFilePerChannelEnabled() const { - return measurement->IsOneFilePerChannelEnabled(); + return impl->measurement.IsOneFilePerChannelEnabled(); } void Writer::SetOneFilePerChannelEnabled(bool enabled) { - return measurement->SetOneFilePerChannelEnabled(enabled); + return impl->measurement.SetOneFilePerChannelEnabled(enabled); } -void Writer::SetChannelDataTypeInformation(const std::string& channel_name, const base::DataTypeInformation& info) +void Writer::SetChannelDataTypeInformation(const base::Channel& channel_name, const base::DataTypeInformation& info) { - measurement->SetChannelDataTypeInformation(channel_name, info); + impl->measurement.SetChannelDataTypeInformation(channel_name, info); } void Writer::SetFileBaseName(const std::string& base_name) { - return measurement->SetFileBaseName(base_name); + return impl->measurement.SetFileBaseName(base_name); } -bool Writer::AddEntryToFile(const void* data, const unsigned long long& size, const long long& snd_timestamp, const long long& rcv_timestamp, const std::string& channel_name, long long id, long long clock) +bool Writer::AddEntryToFile(const base::WriteEntry& entry) { - return measurement->AddEntryToFile(data, size, snd_timestamp, rcv_timestamp, channel_name, id, clock); + return impl->measurement.AddEntryToFile(entry); } diff --git a/contrib/mma/src/mma_application.cpp b/contrib/mma/src/mma_application.cpp index 0bd4ec8312..87cb5d923a 100644 --- a/contrib/mma/src/mma_application.cpp +++ b/contrib/mma/src/mma_application.cpp @@ -135,7 +135,7 @@ int main(int argc, char** argv) std::cout << app_version_header << std::endl << ecal_version_header << std::endl << std::endl; // initialize eCAL API - if (eCAL::Initialize(0, nullptr, MMA_APPLICATION_NAME, eCAL::Init::Publisher) < 0) + if (eCAL::Initialize(MMA_APPLICATION_NAME, eCAL::Init::Publisher) < 0) { std::cout << "eCAL initialization failed !"; return 1; diff --git a/doc/rst/configuration/runtime_configuration.rst b/doc/rst/configuration/runtime_configuration.rst index 2d7c981380..08ed8f0a88 100644 --- a/doc/rst/configuration/runtime_configuration.rst +++ b/doc/rst/configuration/runtime_configuration.rst @@ -12,7 +12,7 @@ The corresponding structure reflects the configuration file (:ref:`configuration Custom types ============ -In order to rule out configuration errors, custom datatypes for IP addresses (IpAddressV4) and sizes (ConstrainedInteger) are introduced. +In order to rule out configuration errors, a custom datatype for IP addresses (IpAddressV4) is introduced. **IpAddressV4:** For assigning an IP address simply assign a string with the desired address. Decimal and hexadecimal format is supported. @@ -25,17 +25,6 @@ The IP address can be used like a normal string object. For example: eCAL::Types::IpAddressV4 ip_address = "192.168.7.1"; // in hex: "C0.A8.7.1" std::cout << ip_address << "\n"; -**ConstrainedInteger**: ConstrainedInteger are specified with a minimum (default: 0), step (default: 1) and maximum (default: maximum of int) value. -In case the assigned value does not fit into the specified limitation, the type will throw a std::invalid_argument exception. - -The size object can be used like a normal integer. - -.. code-block:: c++ - - eCAL::Types::ConstrainedInteger<1024, 512, 8192> size_4mb = 1024 + 6 * 512; - std::cout << size_4mb << "\n"; - -For specifying sizes in the ecal configuration object, refer to the .yaml file or "ecal/config/configuration.h" for the limitations. Global configuration initialization =================================== diff --git a/doc/rst/configuration/src/publisher_config/main.cpp b/doc/rst/configuration/src/publisher_config/main.cpp index a2bf982cba..d601f26d91 100644 --- a/doc/rst/configuration/src/publisher_config/main.cpp +++ b/doc/rst/configuration/src/publisher_config/main.cpp @@ -8,7 +8,7 @@ int main(int argc, char** argv) { // initialize eCAL API - eCAL::Initialize(0, nullptr, "PublisherConfig", eCAL::Init::All); + eCAL::Initialize("PublisherConfig", eCAL::Init::All); // create publisher config eCAL::Publisher::Configuration pub_config; diff --git a/doc/rst/getting_started/src/hello_world/hello_world_rec/main.cpp b/doc/rst/getting_started/src/hello_world/hello_world_rec/main.cpp index 6819eca603..4a41c48f9c 100644 --- a/doc/rst/getting_started/src/hello_world/hello_world_rec/main.cpp +++ b/doc/rst/getting_started/src/hello_world/hello_world_rec/main.cpp @@ -13,7 +13,7 @@ void HelloWorldCallback(const std::string& message) int main(int argc, char** argv) { // Initialize eCAL - eCAL::Initialize(argc, argv, "Hello World Subscriber"); + eCAL::Initialize("Hello World Subscriber"); // Create a subscriber that listenes on the "hello_world_topic" eCAL::string::CSubscriber subscriber("hello_world_topic"); diff --git a/doc/rst/getting_started/src/hello_world/hello_world_snd/main.cpp b/doc/rst/getting_started/src/hello_world/hello_world_snd/main.cpp index 4c5abbf915..2e00d3e2df 100644 --- a/doc/rst/getting_started/src/hello_world/hello_world_snd/main.cpp +++ b/doc/rst/getting_started/src/hello_world/hello_world_snd/main.cpp @@ -7,7 +7,7 @@ int main(int argc, char** argv) { // Initialize eCAL. The name of our Process will be "Hello World Publisher" - eCAL::Initialize(argc, argv, "Hello World Publisher"); + eCAL::Initialize("Hello World Publisher"); // Create a String Publisher that publishes on the topic "hello_world_topic" eCAL::string::CPublisher publisher("hello_world_topic"); diff --git a/doc/rst/getting_started/src/hello_world_protobuf/protobuf_rec/main.cpp b/doc/rst/getting_started/src/hello_world_protobuf/protobuf_rec/main.cpp index d8aef90297..b480240306 100644 --- a/doc/rst/getting_started/src/hello_world_protobuf/protobuf_rec/main.cpp +++ b/doc/rst/getting_started/src/hello_world_protobuf/protobuf_rec/main.cpp @@ -16,7 +16,7 @@ void HelloWorldCallback(const proto_messages::HelloWorld& hello_world_msg) int main(int argc, char** argv) { // Initialize eCAL and create a protobuf subscriber - eCAL::Initialize(argc, argv, "Hello World Protobuf Subscriber"); + eCAL::Initialize("Hello World Protobuf Subscriber"); eCAL::protobuf::CSubscriber subscriber("hello_world_protobuf"); // Set the Callback diff --git a/doc/rst/getting_started/src/hello_world_protobuf/protobuf_snd/main.cpp b/doc/rst/getting_started/src/hello_world_protobuf/protobuf_snd/main.cpp index 59ec17c5bb..8e879f45d4 100644 --- a/doc/rst/getting_started/src/hello_world_protobuf/protobuf_snd/main.cpp +++ b/doc/rst/getting_started/src/hello_world_protobuf/protobuf_snd/main.cpp @@ -9,7 +9,7 @@ int main(int argc, char** argv) { // Initialize eCAL and create a protobuf publisher - eCAL::Initialize(argc, argv, "Hello World Protobuf Publisher"); + eCAL::Initialize("Hello World Protobuf Publisher"); eCAL::protobuf::CPublisher publisher("hello_world_protobuf"); // Ask the user to input his name diff --git a/ecal/core/CMakeLists.txt b/ecal/core/CMakeLists.txt index c2cf533fb2..f6b7b313eb 100644 --- a/ecal/core/CMakeLists.txt +++ b/ecal/core/CMakeLists.txt @@ -66,7 +66,6 @@ endif() ###################################### set(ecal_config_src src/config/default_configuration.cpp - src/config/ecal_cmd_parser.cpp src/config/ecal_config.cpp src/config/ecal_config_initializer.cpp src/config/transport_layer.cpp @@ -484,7 +483,6 @@ set(ecal_c_src src/cimpl/ecal_monitoring_cimpl.cpp src/cimpl/ecal_process_cimpl.cpp src/cimpl/ecal_publisher_cimpl.cpp - src/cimpl/ecal_registration_cimpl.cpp src/cimpl/ecal_server_cimpl.cpp src/cimpl/ecal_subscriber_cimpl.cpp src/cimpl/ecal_time_cimpl.cpp @@ -506,11 +504,19 @@ endif() # public header ###################################### set(ecal_header_cmn - include/ecal/types/logging.h - include/ecal/types/monitoring.h + include/ecal/config/application.h include/ecal/config/configuration.h + include/ecal/config/logging.h + include/ecal/config/monitoring.h include/ecal/config/publisher.h + include/ecal/config/registration.h + include/ecal/config/service.h include/ecal/config/subscriber.h + include/ecal/config/time.h + include/ecal/config/transport_layer.h + include/ecal/config/user_arguments.h + include/ecal/types/logging.h + include/ecal/types/monitoring.h include/ecal/ecal.h include/ecal/ecal_callback.h include/ecal/ecal_client.h @@ -548,7 +554,6 @@ set(ecal_header_cimpl include/ecal/cimpl/ecal_monitoring_cimpl.h include/ecal/cimpl/ecal_process_cimpl.h include/ecal/cimpl/ecal_publisher_cimpl.h - include/ecal/cimpl/ecal_registration_cimpl.h include/ecal/cimpl/ecal_server_cimpl.h include/ecal/cimpl/ecal_service_info_cimpl.h include/ecal/cimpl/ecal_subscriber_cimpl.h @@ -561,6 +566,7 @@ set(ecal_header_cimpl set(ecal_header_msg include/ecal/msg/protobuf/client.h + include/ecal/msg/protobuf/dynamic_json_subscriber.h include/ecal/msg/protobuf/dynamic_publisher.h include/ecal/msg/protobuf/dynamic_subscriber.h include/ecal/msg/protobuf/publisher.h diff --git a/ecal/core/include/ecal/cimpl/ecal_core_cimpl.h b/ecal/core/include/ecal/cimpl/ecal_core_cimpl.h index 109a1e449a..62b25d767d 100644 --- a/ecal/core/include/ecal/cimpl/ecal_core_cimpl.h +++ b/ecal/core/include/ecal/cimpl/ecal_core_cimpl.h @@ -57,7 +57,7 @@ extern "C" * * @return Zero if succeeded. **/ - ECALC_API int eCAL_GetVersion(int* major_, int* minor_, int* patch_); + ECALC_API eCAL_SVersion eCAL_GetVersion(); /** * @brief Initialize eCAL API. @@ -69,7 +69,7 @@ extern "C" * * @return Zero if succeeded, 1 if already initialized, -1 if failed. **/ - ECALC_API int eCAL_Initialize(int argc_, char **argv_, const char *unit_name_, unsigned int components_); + ECALC_API int eCAL_Initialize(const char *unit_name_, unsigned int components_); /** * @brief Set/change the unit name of current module. @@ -90,11 +90,9 @@ extern "C" /** * @brief Check eCAL initialize state. * - * @param component_ Check specific component or 0 for general state of eCAL core. - * * @return None zero if eCAL is initialized. **/ - ECALC_API int eCAL_IsInitialized(unsigned int component_); + ECALC_API int eCAL_IsInitialized(); /** * @brief Return the eCAL process state. diff --git a/ecal/core/include/ecal/cimpl/ecal_registration_cimpl.h b/ecal/core/include/ecal/cimpl/ecal_registration_cimpl.h deleted file mode 100644 index 7b11172c11..0000000000 --- a/ecal/core/include/ecal/cimpl/ecal_registration_cimpl.h +++ /dev/null @@ -1,176 +0,0 @@ -/* ========================= eCAL LICENSE ================================= - * - * Copyright (C) 2016 - 2024 Continental Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ========================= eCAL LICENSE ================================= -*/ - -/** - * @file ecal_registration_cimpl.h - * @brief eCAL registration c interface -**/ - -#ifndef ecal_registration_cimpl_h_included -#define ecal_registration_cimpl_h_included - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif /*__cplusplus*/ - /** - * @brief Gets type name of the specified topic. - * - * @param topic_name_ Topic name. - * @param [out] topic_type_ Pointer to store the type name information. - * @param topic_type_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if - * eCAL should allocate the buffer for you (see eCAL_FreeMem). - * - * @return Type name buffer length or zero if failed. - **/ - ECALC_API int eCAL_Registration_GetTopicTypeName(const char* topic_name_, void* topic_type_, int topic_type_len_); - - /** - * @brief Gets encoding of the specified topic. - * - * @param topic_name_ Topic name. - * @param [out] topic_encoding_ Pointer to store the encoding information. - * @param topic_encoding__len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if - * eCAL should allocate the buffer for you (see eCAL_FreeMem). - * - * @return Type name buffer length or zero if failed. - **/ - ECALC_API int eCAL_Registration_GetTopicEncoding(const char* topic_name_, void* topic_encoding_, int topic_encoding_len_); - - /** - * @brief Gets type description of the specified topic. - * - * @param topic_name_ Topic name. - * @param [out] topic_desc_ Pointer to store the type description0 information. - * @param topic_desc_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if - * eCAL should allocate the buffer for you (see eCAL_FreeMem). - * - * @return Type name buffer length or zero if failed. - **/ - ECALC_API int eCAL_Registration_GetTopicDescription(const char* topic_name_, void* topic_desc_, int topic_desc_len_); - - /** - * @brief Gets service method request type name. - * - * @param service_name_ Service name. - * @param method_name_ Method name. - * @param [out] req_type_ Pointer to store the request type. - * @param req_type_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if - * eCAL should allocate the buffer for you (see eCAL_FreeMem). - * - * @return Type name buffer length or zero if failed. - **/ - ECALC_API int eCAL_Registration_GetServiceRequestTypeName(const char* service_name_, const char* method_name_, void* req_type_, int req_type_len_); - - /** - * @brief Gets service method response type name. - * - * @param service_name_ Service name. - * @param method_name_ Method name. - * @param [out] resp_type_ Pointer to store the response type. - * @param resp_type_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if - * - * @return Type name buffer length or zero if failed. - **/ - ECALC_API int eCAL_Registration_GetServiceResponseTypeName(const char* service_name_, const char* method_name_, void* resp_type_, int resp_type_len_); - - /** - * @brief Gets service method request description. - * - * @param service_name_ Service name. - * @param method_name_ Method name. - * @param [out] req_desc_ Pointer to store the request description. - * @param req_desc_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if - * eCAL should allocate the buffer for you (see eCAL_FreeMem). - * - * @return Request description buffer length or zero if failed. - **/ - ECALC_API int eCAL_Registration_GetServiceRequestDescription(const char* service_name_, const char* method_name_, void* req_desc_, int req_desc_len_); - - /** - * @brief Gets service method response description. - * - * @param service_name_ Service name. - * @param method_name_ Method name. - * @param [out] resp_desc_ Pointer to store the response description. - * @param resp_desc_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if - * eCAL should allocate the buffer for you (see eCAL_FreeMem). - * - * @return Response description buffer length or zero if failed. - **/ - ECALC_API int eCAL_Registration_GetServiceResponseDescription(const char* service_name_, const char* method_name_, void* resp_desc_, int resp_desc_len_); - - /** - * @brief Gets client method request type name. - * - * @param client_name_ Client name. - * @param method_name_ Method name. - * @param [out] req_type_ Pointer to store the request type. - * @param req_type_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if - * eCAL should allocate the buffer for you (see eCAL_FreeMem). - * - * @return Type name buffer length or zero if failed. - **/ - ECALC_API int eCAL_Registration_GetClientRequestTypeName(const char* client_name_, const char* method_name_, void* req_type_, int req_type_len_); - - /** - * @brief Gets client method response type name. - * - * @param client_name_ Client name. - * @param method_name_ Method name. - * @param [out] resp_type_ Pointer to store the response type. - * @param resp_type_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if - * - * @return Type name buffer length or zero if failed. - **/ - ECALC_API int eCAL_Registration_GetClientResponseTypeName(const char* client_name_, const char* method_name_, void* resp_type_, int resp_type_len_); - - /** - * @brief Gets client method request description. - * - * @param client_name_ Client name. - * @param method_name_ Method name. - * @param [out] req_desc_ Pointer to store the request description. - * @param req_desc_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if - * eCAL should allocate the buffer for you (see eCAL_FreeMem). - * - * @return Request description buffer length or zero if failed. - **/ - ECALC_API int eCAL_Registration_GetClientRequestDescription(const char* client_name_, const char* method_name_, void* req_desc_, int req_desc_len_); - - /** - * @brief Gets client method response description. - * - * @param client_name_ Client name. - * @param method_name_ Method name. - * @param [out] resp_desc_ Pointer to store the response description. - * @param resp_desc_len_ Length of allocated buffer or ECAL_ALLOCATE_4ME if - * eCAL should allocate the buffer for you (see eCAL_FreeMem). - * - * @return Response description buffer length or zero if failed. - **/ - ECALC_API int eCAL_Registration_GetClientResponseDescription(const char* client_name_, const char* method_name_, void* resp_desc_, int resp_desc_len_); -#ifdef __cplusplus -} -#endif /*__cplusplus*/ - -#endif /*ecal_registration_cimpl_h_included*/ diff --git a/ecal/core/include/ecal/cimpl/ecal_util_cimpl.h b/ecal/core/include/ecal/cimpl/ecal_util_cimpl.h index 02cbd273cb..96d011a892 100644 --- a/ecal/core/include/ecal/cimpl/ecal_util_cimpl.h +++ b/ecal/core/include/ecal/cimpl/ecal_util_cimpl.h @@ -49,20 +49,6 @@ extern "C" * @brief Send shutdown event to all local user processes. **/ ECALC_API void eCAL_Util_ShutdownProcesses(); - - /** - * @brief Send shutdown event to all local core components. - **/ - ECALC_API void eCAL_Util_ShutdownCore(); - - /** - * @brief Enable eCAL message loop back, - * that means subscriber will receive messages from - * publishers of the same process (default == false). - * - * @param state_ Switch on message loop back.. - **/ - ECALC_API void eCAL_Util_EnableLoopback(int state_); #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/ecal/core/include/ecal/config/configuration.h b/ecal/core/include/ecal/config/configuration.h index 47c4b3fc53..a99f7832b3 100644 --- a/ecal/core/include/ecal/config/configuration.h +++ b/ecal/core/include/ecal/config/configuration.h @@ -60,8 +60,6 @@ namespace eCAL Cli::Configuration command_line_arguments; ECAL_API Configuration(); - ECAL_API Configuration(int argc_, char** argv_); - ECAL_API Configuration(const std::vector& args_); ECAL_API void InitFromConfig(); ECAL_API void InitFromFile(const std::string& yaml_path_); diff --git a/ecal/core/include/ecal/config/publisher.h b/ecal/core/include/ecal/config/publisher.h index 7ab4316a6e..1b1874d0d5 100644 --- a/ecal/core/include/ecal/config/publisher.h +++ b/ecal/core/include/ecal/config/publisher.h @@ -105,14 +105,14 @@ namespace eCAL { struct Configuration { - bool enable { true }; //!< enable layer + bool enable { true }; //!< enable layer - bool zero_copy_mode { false }; //!< Enable zero copy shared memory transport mode - unsigned int acknowledge_timeout_ms { 0U }; /*!< Force connected subscribers to send acknowledge event after processing the message. - The publisher send call is blocked on this event with this timeout (0 == no handshake).*/ - unsigned int memfile_buffer_count { 1U }; /*!< Maximum number of used buffers (needs to be greater than 1, default = 1) */ - Types::ConstrainedInteger<4096, 4096> memfile_min_size_bytes { 4096 }; //!< Default memory file size for new publisher (Default: 4096) - Types::ConstrainedInteger<50, 1, 100> memfile_reserve_percent { 50 }; //!< Dynamic file size reserve before recreating memory file if topic size changes (Default: 50) + bool zero_copy_mode { false }; //!< Enable zero copy shared memory transport mode + unsigned int acknowledge_timeout_ms { 0U }; /*!< Force connected subscribers to send acknowledge event after processing the message. + The publisher send call is blocked on this event with this timeout (0 == no handshake).*/ + unsigned int memfile_buffer_count { 1U }; /*!< Maximum number of used buffers (needs to be greater than 1, default = 1) */ + unsigned int memfile_min_size_bytes { 4096 }; //!< Default memory file size for new publisher (Default: 4096) + unsigned int memfile_reserve_percent { 50 }; //!< Dynamic file size reserve before recreating memory file if topic size changes (Default: 50) }; } diff --git a/ecal/core/include/ecal/config/transport_layer.h b/ecal/core/include/ecal/config/transport_layer.h index b22866056e..0a30caedc2 100644 --- a/ecal/core/include/ecal/config/transport_layer.h +++ b/ecal/core/include/ecal/config/transport_layer.h @@ -55,24 +55,23 @@ namespace eCAL struct Configuration { - Types::UdpConfigVersion config_version { Types::UdpConfigVersion::V2 }; /*!< UDP configuration version (Since eCAL 5.12.) - v1: default behavior - v2: new behavior, comes with a bit more intuitive handling regarding masking of the groups (Default: v2) */ - unsigned int port { 14002 }; /*!< UDP multicast port number (Default: 14002) */ - Types::UDPMode mode { Types::UDPMode::LOCAL }; /*!< Valid modes: local, network (Default: local)*/ - Types::IpAddressV4 mask { "255.255.255.240" }; /*!< v1: Mask maximum number of dynamic multicast group (Default: 0.0.0.1-0.0.0.255) - v2: masks are now considered like routes masking (Default: 255.0.0.0-255.255.255.255)*/ - - // TODO PG: are these minimum limits correct? - Types::ConstrainedInteger<5242880, 1024> send_buffer { 5242880 }; //!< UDP send buffer in bytes (Default: 5242880) - Types::ConstrainedInteger<5242880, 1024> receive_buffer { 5242880 }; //!< UDP receive buffer in bytes (Default: 5242880) - bool join_all_interfaces { false }; /*!< Linux specific setting to enable joining multicast groups on all network interfacs - independent of their link state. Enabling this makes sure that eCAL processes - receive data if they are started before network devices are up and running. (Default: false)*/ - bool npcap_enabled { false }; //!< Enable to receive UDP traffic with the Npcap based receiver (Default: false) + Types::UdpConfigVersion config_version { Types::UdpConfigVersion::V2 }; /*!< UDP configuration version (Since eCAL 5.12.) + v1: default behavior + v2: new behavior, comes with a bit more intuitive handling regarding masking of the groups (Default: v2) */ + unsigned int port { 14002 }; /*!< UDP multicast port number (Default: 14002) */ + Types::UDPMode mode { Types::UDPMode::LOCAL }; /*!< Valid modes: local, network (Default: local)*/ + Types::IpAddressV4 mask { "255.255.255.240" }; /*!< v1: Mask maximum number of dynamic multicast group (Default: 0.0.0.1-0.0.0.255) + v2: masks are now considered like routes masking (Default: 255.0.0.0-255.255.255.255)*/ + + unsigned int send_buffer { 5242880 }; //!< UDP send buffer in bytes (Default: 5242880) + unsigned int receive_buffer { 5242880 }; //!< UDP receive buffer in bytes (Default: 5242880) + bool join_all_interfaces { false }; /*!< Linux specific setting to enable joining multicast groups on all network interfacs + independent of their link state. Enabling this makes sure that eCAL processes + receive data if they are started before network devices are up and running. (Default: false)*/ + bool npcap_enabled { false }; //!< Enable to receive UDP traffic with the Npcap based receiver (Default: false) - Network::Configuration network; - const Local::Configuration local; + Network::Configuration network; + const Local::Configuration local; ECAL_API Configuration& operator=(const Configuration& other); }; diff --git a/ecal/core/include/ecal/config/user_arguments.h b/ecal/core/include/ecal/config/user_arguments.h index a5af144620..50eb06d211 100644 --- a/ecal/core/include/ecal/config/user_arguments.h +++ b/ecal/core/include/ecal/config/user_arguments.h @@ -35,7 +35,7 @@ namespace eCAL struct Configuration { std::string user_yaml { "" }; //!< The used eCAL yaml file (Default: "") - bool dump_config { false }; //!< If specified, output configuration via standart output (Default: false) + bool dump_config { false }; //!< If specified, output configuration via standard output (Default: false) }; } } \ No newline at end of file diff --git a/ecal/core/include/ecal/ecal_core.h b/ecal/core/include/ecal/ecal_core.h index a725191b75..9c6b2088c5 100644 --- a/ecal/core/include/ecal/ecal_core.h +++ b/ecal/core/include/ecal/ecal_core.h @@ -32,6 +32,7 @@ #include #include +#include namespace eCAL { @@ -40,48 +41,31 @@ namespace eCAL * * @return Full eCAL version string. **/ - ECAL_API const char* GetVersionString(); + ECAL_API std::string GetVersionString(); /** * @brief Get eCAL version date. * * @return Full eCAL version date string. **/ - ECAL_API const char* GetVersionDateString(); + ECAL_API std::string GetVersionDateString(); /** - * @brief Get eCAL version as separated integer values. + * @brief Get eCAL version as separated integer values. * - * @param [out] major_ The eCAL major version number. - * @param [out] minor_ The eCAL minor version number. - * @param [out] patch_ The eCAL patch version number. - * - * @return Zero if succeeded. + * @return struct SVersion that contains major, minor and patch value. **/ - ECAL_API int GetVersion(int* major_, int* minor_, int* patch_); + ECAL_API SVersion GetVersion(); /** * @brief Initialize eCAL API. * - * @param argc_ Number of command line arguments. - * @param argv_ Array of command line arguments. - * @param unit_name_ Defines the name of the eCAL unit. - * @param components_ Defines which component to initialize. - * - * @return Zero if succeeded, 1 if already initialized, -1 if failed. - **/ - ECAL_API int Initialize(int argc_ = 0, char **argv_ = nullptr, const char *unit_name_ = nullptr, unsigned int components_ = Init::Default); - - /** - * @brief Initialize eCAL API. - * - * @param args_ Vector of config arguments to overwrite (["arg1", "value1", "arg2", "arg3", "value3" ..]). * @param unit_name_ Defines the name of the eCAL unit. * @param components_ Defines which component to initialize. * * @return Zero if succeeded, 1 if already initialized, -1 if failed. **/ - ECAL_API int Initialize(std::vector args_, const char *unit_name_ = nullptr, unsigned int components_ = Init::Default); + ECAL_API int Initialize(const std::string& unit_name_ = "", unsigned int components_ = Init::Default); /** * @brief Initialize eCAL API. @@ -92,7 +76,7 @@ namespace eCAL * * @return Zero if succeeded, 1 if already initialized, -1 if failed. **/ - ECAL_API int Initialize(eCAL::Configuration& config_, const char *unit_name_ = nullptr, unsigned int components_ = Init::Default); + ECAL_API int Initialize(eCAL::Configuration& config_, const std::string& unit_name_ = "", unsigned int components_ = Init::Default); /** * @brief Finalize eCAL API. @@ -104,11 +88,19 @@ namespace eCAL /** * @brief Check eCAL initialize state. * - * @param component_ Check specific component or 0 for general state of eCAL core. - * * @return 1 if eCAL is initialized. **/ - ECAL_API int IsInitialized(unsigned int component_ = 0); + ECAL_API int IsInitialized(); + + /** + * @brief Check initialization state for a specific component. + * + * @param component_ Specific component to check + * + * @return 1 if eCAL component is initialized. + **/ + ECAL_API int IsInitialized(unsigned int component_); + /** * @brief Set/change the unit name of current module. @@ -117,7 +109,7 @@ namespace eCAL * * @return Zero if succeeded. **/ - ECAL_API int SetUnitName(const char *unit_name_); + ECAL_API int SetUnitName(const std::string& unit_name_); /** * @brief Return the eCAL process state. diff --git a/ecal/core/include/ecal/ecal_deprecate.h b/ecal/core/include/ecal/ecal_deprecate.h index c583fbbdd5..879826f567 100644 --- a/ecal/core/include/ecal/ecal_deprecate.h +++ b/ecal/core/include/ecal/ecal_deprecate.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,33 +29,8 @@ //uncomment this line if you do want to get deprecation warnings inside eCAL core //#undef ECAL_NO_DEPRECATION_WARNINGS -#if !defined(ECAL_NO_DEPRECATION_WARNINGS) && ECAL_VERSION_INTEGER >= ECAL_VERSION_CALCULATE(5, 4, 0) -#define ECAL_DEPRECATE_SINCE_5_4(__message__) [[deprecated(__message__)]] //!< Deprecate the following function with eCAL Version 5.4.0 +#if !defined(ECAL_NO_DEPRECATION_WARNINGS) && ECAL_VERSION_INTEGER >= ECAL_VERSION_CALCULATE(6, 0, 0) +#define ECAL_DEPRECATE_SINCE_6_0(__message__) [[deprecated(__message__)]] //!< Deprecate the following function with eCAL Version 5.13.0 #else -#define ECAL_DEPRECATE_SINCE_5_4(__message__) //!< Deprecate the following function with eCAL Version 5.4.0 -#endif - - -#if !defined(ECAL_NO_DEPRECATION_WARNINGS) && ECAL_VERSION_INTEGER >= ECAL_VERSION_CALCULATE(5, 10, 0) -#define ECAL_DEPRECATE_SINCE_5_10(__message__) [[deprecated(__message__)]] //!< Deprecate the following function with eCAL Version 5.10.0 -#else -#define ECAL_DEPRECATE_SINCE_5_10(__message__) //!< Deprecate the following function with eCAL Version 5.10.0 -#endif - -#if !defined(ECAL_NO_DEPRECATION_WARNINGS) && ECAL_VERSION_INTEGER >= ECAL_VERSION_CALCULATE(5, 11, 0) -#define ECAL_DEPRECATE_SINCE_5_11(__message__) [[deprecated(__message__)]] //!< Deprecate the following function with eCAL Version 5.11.0 -#else -#define ECAL_DEPRECATE_SINCE_5_11(__message__) //!< Deprecate the following function with eCAL Version 5.11.0 -#endif - -#if !defined(ECAL_NO_DEPRECATION_WARNINGS) && ECAL_VERSION_INTEGER >= ECAL_VERSION_CALCULATE(5, 12, 0) -#define ECAL_DEPRECATE_SINCE_5_12(__message__) [[deprecated(__message__)]] //!< Deprecate the following function with eCAL Version 5.12.0 -#else -#define ECAL_DEPRECATE_SINCE_5_12(__message__) //!< Deprecate the following function with eCAL Version 5.12.0 -#endif - -#if !defined(ECAL_NO_DEPRECATION_WARNINGS) && ECAL_VERSION_INTEGER >= ECAL_VERSION_CALCULATE(5, 13, 0) -#define ECAL_DEPRECATE_SINCE_5_13(__message__) [[deprecated(__message__)]] //!< Deprecate the following function with eCAL Version 5.13.0 -#else -#define ECAL_DEPRECATE_SINCE_5_13(__message__) //!< Deprecate the following function with eCAL Version 5.13.0 -#endif +#define ECAL_DEPRECATE_SINCE_6_0(__message__) //!< Deprecate the following function with eCAL Version 5.13.0 +#endif \ No newline at end of file diff --git a/ecal/core/include/ecal/ecal_process.h b/ecal/core/include/ecal/ecal_process.h index 1282d45b9c..cca66d526a 100644 --- a/ecal/core/include/ecal/ecal_process.h +++ b/ecal/core/include/ecal/ecal_process.h @@ -70,7 +70,7 @@ namespace eCAL ECAL_API std::string GetUnitName(); /** - * @brief Get current process parameter (defined via eCAL::Initialize(argc_, arg_v). + * @brief Get current process parameter (defined via eCAL::Initialize(argc, argv). * * @param sep_ Separator. * diff --git a/ecal/core/include/ecal/ecal_registration.h b/ecal/core/include/ecal/ecal_registration.h index 4222efa840..b477441273 100644 --- a/ecal/core/include/ecal/ecal_registration.h +++ b/ecal/core/include/ecal/ecal_registration.h @@ -38,50 +38,6 @@ namespace eCAL { namespace Registration { - // enumeration of quality bits used for detecting how good a data information is - enum class DescQualityFlags : std::uint8_t - { - NO_QUALITY = 0, //!< Special value for initialization - DESCRIPTION_AVAILABLE = 0x1 << 3, //!< Having a type descriptor available - ENCODING_AVAILABLE = 0x1 << 2, //!< Having a type encoding - TYPENAME_AVAILABLE = 0x1 << 1, //!< Having a type name available - INFO_COMES_FROM_PRODUCER = 0x1 << 0 //!< Info is coming from the producer (like a publisher, service) - }; - - constexpr inline DescQualityFlags operator~ (DescQualityFlags a) { return static_cast( ~static_cast::type>(a) ); } - constexpr inline DescQualityFlags operator| (DescQualityFlags a, DescQualityFlags b) { return static_cast( static_cast::type>(a) | static_cast::type>(b) ); } - constexpr inline DescQualityFlags operator& (DescQualityFlags a, DescQualityFlags b) { return static_cast( static_cast::type>(a) & static_cast::type>(b) ); } - constexpr inline DescQualityFlags operator^ (DescQualityFlags a, DescQualityFlags b) { return static_cast( static_cast::type>(a) ^ static_cast::type>(b) ); } - inline DescQualityFlags& operator|= (DescQualityFlags& a, DescQualityFlags b) { return reinterpret_cast( reinterpret_cast::type&>(a) |= static_cast::type>(b) ); } - inline DescQualityFlags& operator&= (DescQualityFlags& a, DescQualityFlags b) { return reinterpret_cast( reinterpret_cast::type&>(a) &= static_cast::type>(b) ); } - inline DescQualityFlags& operator^= (DescQualityFlags& a, DescQualityFlags b) { return reinterpret_cast( reinterpret_cast::type&>(a) ^= static_cast::type>(b) ); } - - using TopicId = std::uint64_t; - struct SQualityTopicInfo - { - SDataTypeInformation info; - DescQualityFlags quality = DescQualityFlags::NO_QUALITY; - - bool operator<(const SQualityTopicInfo& other) const - { - return std::tie(quality, info) < std::tie(other.quality, info); - } - }; - using QualityTopicInfoMultiMap = std::multimap; - using QualityTopicInfoSet = std::set; - - using ServiceId = std::uint64_t; - struct SQualityServiceInfo - { - SServiceMethodInformation info; - DescQualityFlags request_quality = DescQualityFlags::NO_QUALITY; - DescQualityFlags response_quality = DescQualityFlags::NO_QUALITY; - - bool operator<(const SQualityServiceInfo& other) const - { - return std::tie(request_quality, response_quality) < std::tie(other.request_quality, other.response_quality); - } - }; struct SServiceMethod { std::string service_name; @@ -92,8 +48,6 @@ namespace eCAL return std::tie(service_name, method_name) < std::tie(other.service_name, other.method_name); } }; - using QualityServiceInfoMultimap = std::multimap; - using SQualityServiceInfoSet = std::set; using CallbackToken = std::size_t; @@ -104,7 +58,7 @@ namespace eCAL }; using TopicIDCallbackT = std::function; - using ServiceIDCallbackT = std::function; + using ServiceIDCallbackT = std::function; /** * @brief Get complete snapshot of all known publisher. @@ -118,7 +72,7 @@ namespace eCAL * * @return True if information could be queried. **/ - ECAL_API bool GetPublisherInfo(const STopicId& id_, SQualityTopicInfo& topic_info_); + ECAL_API bool GetPublisherInfo(const STopicId& id_, SDataTypeInformation& topic_info_); /** * @brief Register a callback function to be notified when a new publisher becomes available. @@ -150,7 +104,7 @@ namespace eCAL * * @return True if information could be queried. **/ - ECAL_API bool GetSubscriberInfo(const STopicId& id_, SQualityTopicInfo& topic_info_); + ECAL_API bool GetSubscriberInfo(const STopicId& id_, SDataTypeInformation& topic_info_); /** * @brief Register a callback function to be notified when a new subscriber becomes available. @@ -175,108 +129,28 @@ namespace eCAL * * @return Set of service id's. **/ - ECAL_API std::set GetServiceIDs(); + ECAL_API std::set GetServiceIDs(); /** * @brief Get service method information with quality for specific service. * * @return True if information could be queried. **/ - ECAL_API bool GetServiceInfo(const SServiceId& id_, SQualityServiceInfo& service_info_); + ECAL_API bool GetServiceInfo(const SServiceMethodId& id_, SServiceMethodInformation& service_method_info_); /** * @brief Get complete snapshot of all known clients. * * @return Set of service id's. **/ - ECAL_API std::set GetClientIDs(); + ECAL_API std::set GetClientIDs(); /** * @brief Get service method information with quality for specific client. * * @return True if information could be queried. **/ - ECAL_API bool GetClientInfo(const SServiceId& id_, SQualityServiceInfo& service_info_); - - /** - * @brief Get complete snapshot of data type information with quality and topic id for all known publisher. - * - * @return MultiMap containing the quality datatype information and the topic id's. - **/ - ECAL_API QualityTopicInfoMultiMap GetPublishers(); - - /** - * @brief Get data type information with quality and topic id for this publishers. - * - * @param topic_name_ Topic name. - * - * @return Set containing the quality datatype information for this publisher. - **/ - ECAL_API QualityTopicInfoSet GetPublishers(const std::string& topic_name_); - - /** - * @brief Get complete snapshot of data type information with quality and topic id for all known subscribers. - * - * @return MultiMap containing the quality datatype information and the topic id's. - **/ - ECAL_API QualityTopicInfoMultiMap GetSubscribers(); - - /** - * @brief Get data type information with quality and topic id for this subscriber. - * - * @param topic_name_ Topic name. - * - * @return Set containing the quality datatype information for this subscriber. - **/ - ECAL_API QualityTopicInfoSet GetSubscribers(const std::string& topic_name_); - - /** - * @brief Get highest quality data type information out of a set of quality data type information. - * - * @param quality_topic_info_set_ Set of quality data type information - * - * @return Highest quality data type information. - **/ - ECAL_API SDataTypeInformation GetHighestQualityDataTypeInformation(const QualityTopicInfoSet& quality_topic_info_set_); - - /** - * @brief Get complete snapshot of service method information with quality and service id for all known services. - * - * @return MultiMap containing the quality datatype information and the service id's. - **/ - ECAL_API QualityServiceInfoMultimap GetServices(); - - /** - * @brief Get complete snapshot of service method information with quality and client id for all known clients. - * - * @return MultiMap containing the quality datatype information and the client id's. - **/ - ECAL_API QualityServiceInfoMultimap GetClients(); - - /** - * @brief Get highest quality service method type information out of a set of quality service method information. - * - * @param quality_service_info_set_ Set of quality service method information - * - * @return Highest quality service method information. - **/ - ECAL_API SServiceMethodInformation GetHighestQualityServiceMethodInformation(const SQualityServiceInfoSet& quality_service_info_set_); - - /** - * @brief Get complete topic map. - * - * @param data_type_info_map_ Map to store the datatype information. - * Map { TopicName -> SDataTypeInformation } mapping of all currently known publisher/subscriber. - **/ - ECAL_API void GetTopics(std::map& data_type_info_map_); - - /** - * @brief Get complete quality topic map. - * - * @param quality_topic_info_map_ Map to store the quality datatype information. - * Map { TopicName -> SQualityDataTypeInformation } mapping of all currently known publisher/subscriber. - **/ - ECAL_API void GetTopics(std::map& quality_topic_info_map_); + ECAL_API bool GetClientInfo(const SServiceMethodId& id_, SServiceMethodInformation& service_method_info_); /** * @brief Get all topic names. @@ -285,32 +159,6 @@ namespace eCAL **/ ECAL_API void GetTopicNames(std::set& topic_names_); - /** - * @brief Gets description of the specified topic. - * - * @param topic_name_ Topic name. - * @param data_type_info_ SDataTypeInformation to be filled by this function. - * - * @return True if TopicInformation for specified topic could be retrieved, false otherwise. - **/ - ECAL_API bool GetTopicDataTypeInformation(const std::string& topic_name_, SDataTypeInformation& data_type_info_); - - /** - * @brief Get complete service map. - * - * @param service_method_info_map_ Map to store the service/method descriptions. - * Map { (ServiceName, MethodName) -> SServiceMethodInformation } mapping of all currently known services. - **/ - ECAL_API void GetServices(std::map& service_method_info_map_); - - /** - * @brief Get complete quality service map. - * - * @param quality_service_info_map_ Map to store the quality service/method descriptions. - * Map { (ServiceName, MethodName) -> SQualityServiceMethodInformation } mapping of all currently known services. - **/ - ECAL_API void GetServices(std::map& quality_service_info_map_); - /** * @brief Get all service/method names. * @@ -318,75 +166,11 @@ namespace eCAL **/ ECAL_API void GetServiceMethodNames(std::set& service_method_names_); - /** - * @brief Gets service method request and response type names. - * - * @param service_name_ Service name. - * @param method_name_ Method name. - * @param req_type_ String to store request type. - * @param resp_type_ String to store response type. - * - * @return True if succeeded. - **/ - ECAL_API bool GetServiceTypeNames(const std::string& service_name_, const std::string& method_name_, std::string& req_type_, std::string& resp_type_); - - /** - * @brief Gets service method request and response descriptions. - * - * @param service_name_ Service name. - * @param method_name_ Method name. - * @param req_desc_ String to store request description. - * @param resp_desc_ String to store response description. - * - * @return True if succeeded. - **/ - ECAL_API bool GetServiceDescription(const std::string& service_name_, const std::string& method_name_, std::string& req_desc_, std::string& resp_desc_); - - /** - * @brief Get complete client map. - * - * @param client_method_info_map_ Map to store the client/method descriptions. - * Map { (ClientName, MethodName) -> SServiceMethodInformation } mapping of all currently known clients. - **/ - ECAL_API void GetClients(std::map& client_method_info_map_); - - /** - * @brief Get complete quality client map. - * - * @param quality_client_info_map_ Map to store the quality client/method descriptions. - * Map { (ClientName, MethodName) -> SQualityServiceMethodInformation } mapping of all currently known clients. - **/ - ECAL_API void GetClients(std::map& quality_client_info_map_); - /** * @brief Get all client/method names. * * @param client_method_names_ Set to store the client/method names (Set { (ClientName, MethodName) }). **/ ECAL_API void GetClientMethodNames(std::set& client_method_names_); - - /** - * @brief Gets client method request and response type names. - * - * @param client_name_ Client name. - * @param method_name_ Method name. - * @param req_type_ String to store request type. - * @param resp_type_ String to store response type. - * - * @return True if succeeded. - **/ - ECAL_API bool GetClientTypeNames(const std::string& client_name_, const std::string& method_name_, std::string& req_type_, std::string& resp_type_); - - /** - * @brief Gets client method request and response descriptions. - * - * @param client_name_ Client name. - * @param method_name_ Method name. - * @param req_desc_ String to store request description. - * @param resp_desc_ String to store response description. - * - * @return True if succeeded. - **/ - ECAL_API bool GetClientDescription(const std::string& client_name_, const std::string& method_name_, std::string& req_desc_, std::string& resp_desc_); } } diff --git a/ecal/core/include/ecal/ecal_tlayer.h b/ecal/core/include/ecal/ecal_tlayer.h index 3542c5a181..d8628519db 100644 --- a/ecal/core/include/ecal/ecal_tlayer.h +++ b/ecal/core/include/ecal/ecal_tlayer.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,27 +41,5 @@ namespace eCAL tlayer_tcp = 5, tlayer_all = 255 }; - - /** - * @brief eCAL transport layer modes. - **/ - enum eSendMode - { - smode_none = -1, - smode_off = 0, - smode_on, - smode_auto - }; - - // TODO: Do weed need this ? - /** - * @brief eCAL transport layer state struct. - **/ - struct ECAL_API STLayer - { - eSendMode sm_udp_mc{smode_none}; //!< udp multicast - eSendMode sm_shm{smode_none}; //!< shared memory - eSendMode sm_tcp{smode_none}; //!< tcp - }; } } diff --git a/ecal/core/include/ecal/ecal_types.h b/ecal/core/include/ecal/ecal_types.h index e446c25bd4..e4883af14c 100644 --- a/ecal/core/include/ecal/ecal_types.h +++ b/ecal/core/include/ecal/ecal_types.h @@ -29,6 +29,16 @@ namespace eCAL { + /** + * @brief eCAL version struct + **/ + struct SVersion + { + const int major; //!< major version number + const int minor; //!< minor version number + const int patch; //!< patch version number + }; + /** * @brief Optional compile time information associated with a given topic * (necessary for reflection / runtime type checking) @@ -141,18 +151,18 @@ namespace eCAL return os; } - struct SServiceId + struct SServiceMethodId { SEntityId service_id; std::string service_name; std::string method_name; - bool operator==(const SServiceId& other) const + bool operator==(const SServiceMethodId& other) const { return service_id == other.service_id && service_name == other.service_name && method_name == other.method_name; } - bool operator<(const SServiceId& other) const + bool operator<(const SServiceMethodId& other) const { return std::tie(service_id, service_name, method_name) < std::tie(other.service_id, other.service_name, other.method_name); } diff --git a/ecal/core/include/ecal/ecal_util.h b/ecal/core/include/ecal/ecal_util.h index ba4fa07c09..de6bd24641 100644 --- a/ecal/core/include/ecal/ecal_util.h +++ b/ecal/core/include/ecal/ecal_util.h @@ -25,6 +25,7 @@ #pragma once #include +#include #include #include @@ -87,36 +88,6 @@ namespace eCAL **/ ECAL_API void ShutdownProcesses(); - /** - * @brief Send shutdown event to all local core components. - **/ - ECAL_API void ShutdownCore(); - - /** - * @brief Enable eCAL message loop back, - * that means subscriber will receive messages from - * publishers of the same process (default == false). - * - * @param state_ Switch on message loop back. - **/ - ECAL_API void EnableLoopback(bool state_); - - /** - * @brief Enable process wide eCAL publisher topic type sharing - * that is needed for reflection on subscriber side. - * - * @param state_ Switch on type sharing - **/ - ECAL_API void PubShareType(bool state_); - - /** - * @brief Enable process wide eCAL publisher topic description sharing - * that is needed for reflection on subscriber side. - * - * @param state_ Switch on description sharing - **/ - ECAL_API void PubShareDescription(bool state_); - /** * @brief Splits the topic type (eCAL < 5.12) into encoding and types (>= eCAL 5.12) * @@ -124,6 +95,7 @@ namespace eCAL * * @return std::pair(encoding, typename). **/ + ECAL_DEPRECATE_SINCE_6_0("Please refactor your code to use SDatatypeInformation. This function will be removed with eCAL 7") ECAL_API std::pair SplitCombinedTopicType(const std::string& combined_topic_type_); /** @@ -134,6 +106,7 @@ namespace eCAL * * @return "Old" typename. ( encoding:typename ). **/ + ECAL_DEPRECATE_SINCE_6_0("Please refactor your code to use SDatatypeInformation. This function will be removed with eCAL 7") ECAL_API std::string CombinedTopicEncodingAndType(const std::string& topic_encoding_, const std::string& topic_type_); } } diff --git a/ecal/core/include/ecal/ecalc.h b/ecal/core/include/ecal/ecalc.h index b9ff42d094..b1a212f923 100644 --- a/ecal/core/include/ecal/ecalc.h +++ b/ecal/core/include/ecal/ecalc.h @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include diff --git a/ecal/core/include/ecal/ecalc_types.h b/ecal/core/include/ecal/ecalc_types.h index 61d88706fd..48637f6db9 100644 --- a/ecal/core/include/ecal/ecalc_types.h +++ b/ecal/core/include/ecal/ecalc_types.h @@ -35,4 +35,14 @@ **/ typedef void* ECAL_HANDLE; +/** + * @brief eCAL version struct (C variant) + **/ +typedef struct +{ + int major; //!< major version number + int minor; //!< minor version number + int patch; //!< patch version number +} eCAL_SVersion; + #endif /* ecalc_types_h_included */ diff --git a/ecal/core/include/ecal/msg/dynamic.h b/ecal/core/include/ecal/msg/dynamic.h index 1d09b6df4c..ff2bde729e 100644 --- a/ecal/core/include/ecal/msg/dynamic.h +++ b/ecal/core/include/ecal/msg/dynamic.h @@ -84,7 +84,6 @@ namespace eCAL * @param topic_name_ Unique topic name. **/ CDynamicMessageSubscriber(const std::string& topic_name_) : CSubscriber() - , m_topic_name(topic_name_) , m_deserializer() { CSubscriber::Create(topic_name_); @@ -110,7 +109,6 @@ namespace eCAL **/ CDynamicMessageSubscriber(CDynamicMessageSubscriber&& rhs) : CSubscriber(std::move(rhs)) - , m_topic_name(std::move(rhs.m_topic_name)) , m_cb_callback(std::move(rhs.m_cb_callback)) , m_deserializer(std::move(rhs.m_deserializer)) { @@ -141,52 +139,16 @@ namespace eCAL return(CSubscriber::Destroy()); } - /** - * @brief Receive deserialized message. - * - * @param [out] time_ Optional receive time stamp. - * @param rcv_timeout_ Receive timeout in ms. - * - * @return std::optional which holds the value if a value could be received, and std::nullopt if it couldn't. - **/ - // Do we want to call error callbacks on receive? Probably not! std::expected wouuld be a good thing to return the reason why things went wrong. - std::optional Receive(long long* time_ = nullptr, int rcv_timeout_ = 0) - { - std::string rec_buf; - bool success = CSubscriber::ReceiveBuffer(rec_buf, time_, rcv_timeout_); - if (!success) - { - return std::nullopt; - } - // In the future, I would like to get m_datatype_info from the ReceiveBuffer function! - - PopulateDatatypeInfo(); - // We can't possibly receive anything if we don't have datatype info available - if (!m_datatype_info_received) - { - return std::nullopt; - } - - try - { - return(m_deserializer.Deserialize(rec_buf.c_str(), rec_buf.size(), m_datatype_info_received.value())); - } - catch (const DynamicReflectionException& /*e*/) - { - return std::nullopt; - } - } - /** * @brief eCAL message receive callback function * - * @param topic_name_ Topic name of the data source (publisher). - * @param msg_ Message content. - * @param time_ Message time stamp. - * @param clock_ Message writer clock. - * @param id_ Message id. + * @param topic_id_ Topic id of the data source (publisher). + * @param msg_ Message content. + * @param time_ Message time stamp. + * @param clock_ Message writer clock. + * @param id_ Message id. **/ - using MsgReceiveCallbackT = std::function; + using MsgReceiveCallbackT = std::function; /** * @brief Add receive callback for incoming messages. @@ -203,7 +165,8 @@ namespace eCAL std::lock_guard callback_lock(m_cb_callback_mutex); m_cb_callback = callback_; } - auto callback = std::bind(&CDynamicMessageSubscriber::ReceiveCallback, this, std::placeholders::_1, std::placeholders::_2); + + ReceiveIDCallbackT callback = std::bind(&CDynamicMessageSubscriber::ReceiveCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); return(CSubscriber::AddReceiveCallback(callback)); } @@ -258,7 +221,7 @@ namespace eCAL } private: - void ReceiveCallback(const char* topic_name_, const struct eCAL::SReceiveCallbackData* data_) + void ReceiveCallback(const Registration::STopicId& topic_id_, const SDataTypeInformation& topic_info_, const struct SReceiveCallbackData& data_) { MsgReceiveCallbackT fn_callback = nullptr; { @@ -268,19 +231,10 @@ namespace eCAL if (fn_callback == nullptr) return; - PopulateDatatypeInfo(); - - if (!m_datatype_info_received) - { - CallErrorCallback("Dynamic Deserialization: No Prototype available."); - return; - } - try { - // In the future, I would like to get m_datatype_info from the ReceiveBuffer function! - auto msg = m_deserializer.Deserialize(data_->buf, data_->size, m_datatype_info_received.value()); - fn_callback(topic_name_, msg, data_->time, data_->clock, data_->id); + auto msg = m_deserializer.Deserialize(data_.buf, data_.size, topic_info_); + fn_callback(topic_id_, msg, data_.time, data_.clock, data_.id); } catch (const DynamicReflectionException& e) { @@ -288,20 +242,6 @@ namespace eCAL } } - void PopulateDatatypeInfo() - { - if (!m_datatype_info_received) - { - SDataTypeInformation datatype_info_received; - auto received_info = eCAL::Registration::GetTopicDataTypeInformation(m_topic_name, datatype_info_received); - // empty datatype informations are not valid to do reflection on! - if (received_info && datatype_info_received != SDataTypeInformation{}) - { - m_datatype_info_received = datatype_info_received; - } - } - } - void CallErrorCallback(const std::string& message) { ErrorCallbackT error_callback = nullptr; @@ -315,13 +255,11 @@ namespace eCAL } } - std::string m_topic_name; - std::mutex m_cb_callback_mutex; - MsgReceiveCallbackT m_cb_callback; - std::mutex m_error_callback_mutex; - ErrorCallbackT m_error_callback; - DynamicDeserializer m_deserializer; - std::optional m_datatype_info_received = std::nullopt; + std::mutex m_cb_callback_mutex; + MsgReceiveCallbackT m_cb_callback; + std::mutex m_error_callback_mutex; + ErrorCallbackT m_error_callback; + DynamicDeserializer m_deserializer; }; } diff --git a/ecal/core/include/ecal/msg/protobuf/client.h b/ecal/core/include/ecal/msg/protobuf/client.h index 409f51c839..7d934863f6 100644 --- a/ecal/core/include/ecal/msg/protobuf/client.h +++ b/ecal/core/include/ecal/msg/protobuf/client.h @@ -131,72 +131,6 @@ namespace eCAL return CallAsync(method_name_, request_.SerializeAsString(), timeout_); } - /** - * @brief Call method of this service, for specific host (deprecated). - * - * This method is deprecated. Instead using - * - * @code - * eCAL::SServiceResponse srv_response; - * - * pb::protobuf_message_request_type msg_request_pb; - * pb::protobuf_message_response_type msg_response_pb; - * - * auto success = my_service.Call("host_name", "service_name", msg_request_pb, srv_response, msg_response_pb); - * if (success) - * { - * // process msg_response_pb here - * } - * @endcode - * - * you should use the new Call API function returning a vector of all service responses like this - * - * @code - * eCAL::ServiceResponseVecT srv_response_vec; - * - * pb::protobuf_message_request_type msg_request_pb; - * pb::protobuf_message_response_type msg_response_pb; - * - * auto success = my_service.Call("service_name", msg_request_pb, -1, &srv_response_vec); - * if (success) - * { - * for (auto srv_response : srv_response_vec) - * { - * msg_response_pb.ParseFromString(service_response.response); - * - * // process msg_response_pb here - * } - * } - * @endcode - * - * @param host_name_ Host name. - * @param method_name_ Method name. - * @param request_ Request message. - * @param [out] service_response_ Service response struct for detailed informations. - * @param [out] response_ Response message. - * - * @return True if successful. - **/ - ECAL_DEPRECATE_SINCE_5_10("Please use the method bool Call(const std::string& method_name_, const google::protobuf::Message& request_, const int timeout_, ServiceResponseVecT* service_response_vec_) instead. This function will be removed in eCAL6.") - bool Call(const std::string& host_name_, const std::string& method_name_, const google::protobuf::Message& request_, struct SServiceResponse& service_response_, google::protobuf::Message& response_) - { - ServiceResponseVecT service_response_vec; - const int timeout_(-1); - SetHostName(host_name_); - if (Call(method_name_, request_.SerializeAsString(), timeout_, &service_response_vec)) - { - if (!service_response_vec.empty()) - { - service_response_ = service_response_vec[0]; - response_.ParseFromString(service_response_vec[0].response); - return true; - } - } - return false; - } - - using eCAL::v5::CServiceClient::Call; - using eCAL::v5::CServiceClient::CallAsync; private: ServiceMethodInformationMapT CreateMethodInformationMap() { diff --git a/ecal/core/include/ecal/msg/protobuf/dynamic_json_subscriber.h b/ecal/core/include/ecal/msg/protobuf/dynamic_json_subscriber.h index aa0d236983..fca3ba4632 100644 --- a/ecal/core/include/ecal/msg/protobuf/dynamic_json_subscriber.h +++ b/ecal/core/include/ecal/msg/protobuf/dynamic_json_subscriber.h @@ -63,7 +63,7 @@ namespace eCAL public: std::string Deserialize(const void* buffer_, size_t size_, const SDataTypeInformation& datatype_info_) { - google::protobuf::util::JsonOptions options; + google::protobuf::util::JsonPrintOptions options; #if GOOGLE_PROTOBUF_VERSION >= 5026000 options.always_print_fields_with_no_presence = true; #else diff --git a/ecal/core/include/ecal/types/ecal_custom_data_types.h b/ecal/core/include/ecal/types/ecal_custom_data_types.h index 00ab7b7cbd..6907519f1f 100644 --- a/ecal/core/include/ecal/types/ecal_custom_data_types.h +++ b/ecal/core/include/ecal/types/ecal_custom_data_types.h @@ -66,43 +66,6 @@ namespace eCAL std::string m_ip_address{}; }; - /** - * @brief Template class to specify sizes with a concrete minimum, maximum and step size definition. - * - * @tparam MIN Optional minimum possible size. Default: 0 - * @tparam STEP Optional step size. Default: 1 - * @tparam MAX Optional maximum possible size. Default: std::numeric_limits::max() - * - * @param size_ Optional size value. If not set, ConstrainedInteger will return the MIN value. - * - * @throws std::invalid_argument exception. - **/ - template::max()> - class ConstrainedInteger - { - public: - ConstrainedInteger(int size_ = MIN) - { - if (size_ >= MIN && size_ <= MAX && size_ % STEP == 0 && MAX >= MIN) - { - m_size = size_; - } - else - { - throw std::invalid_argument("[ConstrainedInteger] Faulty size configuration or assignment. MIN: " + std::to_string(MIN) + " MAX: " + std::to_string(MAX) + " STEP: " + std::to_string(STEP) + " VALUE:" + std::to_string(size_)); - } - }; - - operator int() const { return m_size; }; - bool operator==(const ConstrainedInteger& other) const { return this->m_size == other; }; - bool operator==(const unsigned int value) const { return this->m_size == static_cast(value); }; - bool operator==(const int value) const { return this->m_size == value; }; - - - private: - int m_size{}; - }; - enum class UdpConfigVersion { V1 = 1, diff --git a/ecal/core/src/cimpl/ecal_core_cimpl.cpp b/ecal/core/src/cimpl/ecal_core_cimpl.cpp index ead763f96d..bf0a12214f 100644 --- a/ecal/core/src/cimpl/ecal_core_cimpl.cpp +++ b/ecal/core/src/cimpl/ecal_core_cimpl.cpp @@ -29,31 +29,29 @@ extern "C" { ECALC_API const char* eCAL_GetVersionString() { - return(ECAL_VERSION); + return ECAL_VERSION; } ECALC_API const char* eCAL_GetVersionDateString() { - return(ECAL_DATE); + return ECAL_DATE; } - ECALC_API int eCAL_GetVersion(int* major_, int* minor_, int* patch_) + ECALC_API eCAL_SVersion eCAL_GetVersion() { - if ((major_ == nullptr) || (minor_ == nullptr) || (patch_ == nullptr)) return(-1); - *major_ = ECAL_VERSION_MAJOR; - *minor_ = ECAL_VERSION_MINOR; - *patch_ = ECAL_VERSION_PATCH; - return(0); + return eCAL_SVersion{ eCAL::GetVersion().major, eCAL::GetVersion().minor, eCAL::GetVersion().patch }; } - ECALC_API int eCAL_Initialize(int argc_, char** argv_, const char* unit_name_, unsigned int components_) + ECALC_API int eCAL_Initialize(const char* unit_name_, unsigned int components_) { - return(eCAL::Initialize(argc_, argv_, unit_name_, components_)); + const std::string unit_name = (unit_name_ != nullptr) ? std::string(unit_name_) : std::string(""); + return eCAL::Initialize(unit_name, components_); } ECALC_API int eCAL_SetUnitName(const char* unit_name_) { - return(eCAL::SetUnitName(unit_name_)); + const std::string unit_name = (unit_name_ != nullptr) ? std::string(unit_name_) : std::string(""); + return(eCAL::SetUnitName(unit_name)); } ECALC_API int eCAL_Finalize() @@ -61,9 +59,9 @@ extern "C" return(eCAL::Finalize()); } - ECALC_API int eCAL_IsInitialized(unsigned int component_) + ECALC_API int eCAL_IsInitialized() { - return(eCAL::IsInitialized(component_)); + return(eCAL::IsInitialized()); } ECALC_API int eCAL_Ok() diff --git a/ecal/core/src/cimpl/ecal_registration_cimpl.cpp b/ecal/core/src/cimpl/ecal_registration_cimpl.cpp deleted file mode 100644 index b01590e934..0000000000 --- a/ecal/core/src/cimpl/ecal_registration_cimpl.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* ========================= eCAL LICENSE ================================= - * - * Copyright (C) 2016 - 2024 Continental Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ========================= eCAL LICENSE ================================= -*/ - -/** - * @file ecal_registration_cimpl.cpp - * @brief eCAL registration c interface -**/ - -#include -#include - -#include "ecal_common_cimpl.h" - -extern "C" -{ - ECALC_API int eCAL_Registration_GetTopicTypeName(const char* topic_name_, void* topic_type_, int topic_type_len_) - { - if (topic_name_ == nullptr) return(0); - if (topic_type_ == nullptr) return(0); - eCAL::SDataTypeInformation topic_info; - if (eCAL::Registration::GetTopicDataTypeInformation(topic_name_, topic_info)) - { - return(CopyBuffer(topic_type_, topic_type_len_, topic_info.name)); - } - return(0); - } - - ECALC_API int eCAL_Registration_GetTopicEncoding(const char* topic_name_, void* topic_encoding_, int topic_encoding_len_) - { - if (topic_name_ == nullptr) return(0); - if (topic_encoding_ == nullptr) return(0); - eCAL::SDataTypeInformation topic_info; - if (eCAL::Registration::GetTopicDataTypeInformation(topic_name_, topic_info)) - { - return(CopyBuffer(topic_encoding_, topic_encoding_len_, topic_info.encoding)); - } - return(0); - } - - ECALC_API int eCAL_Registration_GetTopicDescription(const char* topic_name_, void* topic_desc_, int topic_desc_len_) - { - if (topic_name_ == nullptr) return(0); - if (topic_desc_ == nullptr) return(0); - eCAL::SDataTypeInformation topic_info; - if (eCAL::Registration::GetTopicDataTypeInformation(topic_name_, topic_info)) - { - return(CopyBuffer(topic_desc_, topic_desc_len_, topic_info.descriptor)); - } - return(0); - } - - ECALC_API int eCAL_Registration_GetServiceRequestTypeName(const char* service_name_, const char* method_name_, void* req_type_, int req_type_len_) - { - if (service_name_ == nullptr) return(0); - if (method_name_ == nullptr) return(0); - if (req_type_ == nullptr) return(0); - std::string req_type; - std::string resp_type; - if (eCAL::Registration::GetServiceTypeNames(service_name_, method_name_, req_type, resp_type)) - { - return(CopyBuffer(req_type_, req_type_len_, req_type)); - } - return 0; - } - - ECALC_API int eCAL_Registration_GetServiceResponseTypeName(const char* service_name_, const char* method_name_, void* resp_type_, int resp_type_len_) - { - if (service_name_ == nullptr) return(0); - if (method_name_ == nullptr) return(0); - if (resp_type_ == nullptr) return(0); - std::string req_type; - std::string resp_type; - if (eCAL::Registration::GetServiceTypeNames(service_name_, method_name_, req_type, resp_type)) - { - return(CopyBuffer(resp_type_, resp_type_len_, resp_type)); - } - return 0; - } - - ECALC_API int eCAL_Registration_GetServiceRequestDescription(const char* service_name_, const char* method_name_, void* req_desc_, int req_desc_len_) - { - if (service_name_ == nullptr) return(0); - if (method_name_ == nullptr) return(0); - if (req_desc_ == nullptr) return(0); - std::string req_desc; - std::string resp_desc; - if (eCAL::Registration::GetServiceDescription(service_name_, method_name_, req_desc, resp_desc)) - { - return(CopyBuffer(req_desc_, req_desc_len_, req_desc)); - } - return 0; - } - - ECALC_API int eCAL_Registration_GetServiceResponseDescription(const char* service_name_, const char* method_name_, void* resp_desc_, int resp_desc_len_) - { - if (service_name_ == nullptr) return(0); - if (method_name_ == nullptr) return(0); - if (resp_desc_ == nullptr) return(0); - std::string req_desc; - std::string resp_desc; - if (eCAL::Registration::GetServiceDescription(service_name_, method_name_, req_desc, resp_desc)) - { - return(CopyBuffer(resp_desc_, resp_desc_len_, resp_desc)); - } - return 0; - } - - ECALC_API int eCAL_Registration_GetClientRequestTypeName(const char* client_name_, const char* method_name_, void* req_type_, int req_type_len_) - { - if (client_name_ == nullptr) return(0); - if (method_name_ == nullptr) return(0); - if (req_type_ == nullptr) return(0); - std::string req_type; - std::string resp_type; - if (eCAL::Registration::GetClientTypeNames(client_name_, method_name_, req_type, resp_type)) - { - return(CopyBuffer(req_type_, req_type_len_, req_type)); - } - return 0; - } - - ECALC_API int eCAL_Registration_GetClientResponseTypeName(const char* client_name_, const char* method_name_, void* resp_type_, int resp_type_len_) - { - if (client_name_ == nullptr) return(0); - if (method_name_ == nullptr) return(0); - if (resp_type_ == nullptr) return(0); - std::string req_type; - std::string resp_type; - if (eCAL::Registration::GetClientTypeNames(client_name_, method_name_, req_type, resp_type)) - { - return(CopyBuffer(resp_type_, resp_type_len_, resp_type)); - } - return 0; - } - - ECALC_API int eCAL_Registration_GetClientRequestDescription(const char* client_name_, const char* method_name_, void* req_desc_, int req_desc_len_) - { - if (client_name_ == nullptr) return(0); - if (method_name_ == nullptr) return(0); - if (req_desc_ == nullptr) return(0); - std::string req_desc; - std::string resp_desc; - if (eCAL::Registration::GetClientDescription(client_name_, method_name_, req_desc, resp_desc)) - { - return(CopyBuffer(req_desc_, req_desc_len_, req_desc)); - } - return 0; - } - - ECALC_API int eCAL_Registration_GetClientResponseDescription(const char* client_name_, const char* method_name_, void* resp_desc_, int resp_desc_len_) - { - if (client_name_ == nullptr) return(0); - if (method_name_ == nullptr) return(0); - if (resp_desc_ == nullptr) return(0); - std::string req_desc; - std::string resp_desc; - if (eCAL::Registration::GetClientDescription(client_name_, method_name_, req_desc, resp_desc)) - { - return(CopyBuffer(resp_desc_, resp_desc_len_, resp_desc)); - } - return 0; - } -} diff --git a/ecal/core/src/cimpl/ecal_util_cimpl.cpp b/ecal/core/src/cimpl/ecal_util_cimpl.cpp index cdf16d0dbe..16136ea3e5 100644 --- a/ecal/core/src/cimpl/ecal_util_cimpl.cpp +++ b/ecal/core/src/cimpl/ecal_util_cimpl.cpp @@ -45,15 +45,5 @@ extern "C" { eCAL::Util::ShutdownProcesses(); } - - ECALC_API void eCAL_Util_ShutdownCore() - { - eCAL::Util::ShutdownCore(); - } #endif // ECAL_CORE_MONITORING - - ECALC_API void eCAL_Util_EnableLoopback(int state_) - { - eCAL::Util::EnableLoopback(state_ != 0); - } } diff --git a/ecal/core/src/config/configuration_to_yaml.cpp b/ecal/core/src/config/configuration_to_yaml.cpp index 8cf3f94e35..e49f2d85ff 100644 --- a/ecal/core/src/config/configuration_to_yaml.cpp +++ b/ecal/core/src/config/configuration_to_yaml.cpp @@ -10,14 +10,6 @@ namespace YAML member = node_[key].as(); } - // Operator overload for assigning a ConstrainedInteger to a YAML::Node - template - YAML::Node operator<<(YAML::Node node, const eCAL::Types::ConstrainedInteger& constrainedInt) - { - node = static_cast(constrainedInt); - return node; - } - eCAL_Logging_Filter ParseLogLevel(const std::vector& filter_) { // create excluding filter list @@ -250,8 +242,8 @@ namespace YAML node["mode"] = config_.mode == eCAL::Types::UDPMode::LOCAL ? "local" : "network"; node["port"] = config_.port; node["mask"] = config_.mask.Get(); - node["send_buffer"] << config_.send_buffer; - node["receive_buffer"] << config_.receive_buffer; + node["send_buffer"] = config_.send_buffer; + node["receive_buffer"] = config_.receive_buffer; node["join_all_interfaces"] = config_.join_all_interfaces; node["npcap_enabled"] = config_.npcap_enabled; node["network"] = config_.network; @@ -308,8 +300,8 @@ namespace YAML node["zero_copy_mode"] = config_.zero_copy_mode; node["acknowledge_timeout_ms"] = config_.acknowledge_timeout_ms; node["memfile_buffer_count"] = config_.memfile_buffer_count; - node["memfile_min_size_bytes"] << config_.memfile_min_size_bytes; - node["memfile_reserve_percent"] << config_.memfile_reserve_percent; + node["memfile_min_size_bytes"] = config_.memfile_min_size_bytes; + node["memfile_reserve_percent"] = config_.memfile_reserve_percent; return node; } diff --git a/ecal/core/src/config/ecal_cmd_parser.cpp b/ecal/core/src/config/ecal_cmd_parser.cpp deleted file mode 100644 index 0d9c26af50..0000000000 --- a/ecal/core/src/config/ecal_cmd_parser.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* ========================= eCAL LICENSE ================================= - * - * Copyright (C) 2016 - 2024 Continental Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ========================= eCAL LICENSE ================================= -*/ - -#include "config/ecal_cmd_parser.h" - -#include "ecal/ecal_defs.h" -#include "ecal_def.h" - -#if ECAL_CORE_COMMAND_LINE - #include "util/advanced_tclap_output.h" -#endif - -#include - - -namespace eCAL -{ - namespace Config - { - CmdParser::CmdParser() - : m_dump_config{false} - {} - - CmdParser::CmdParser(const std::vector& arguments_) - : CmdParser() - { - parseArguments(arguments_); - } - - void CmdParser::parseArguments(const std::vector& arguments_) - { -#if ECAL_CORE_COMMAND_LINE - if (!arguments_.empty()) - { - // define command line object - TCLAP::CmdLine cmd("", ' ', ECAL_VERSION); - - // define command line arguments - TCLAP::SwitchArg dump_config_arg ("", "ecal-dump-config", "Dump current configuration.", false); - TCLAP::ValueArg default_ini_file_arg("", "ecal-config-file", "Load default configuration from that file.", false, ECAL_DEFAULT_CFG, "string"); - - TCLAP::UnlabeledMultiArg dummy_arg("__dummy__", "Dummy", false, ""); // Dummy arg to eat all unrecognized arguments - - cmd.add(dump_config_arg); - cmd.add(default_ini_file_arg); - cmd.add(dummy_arg); - - CustomTclap::AdvancedTclapOutput advanced_tclap_output(&std::cout, 75); - advanced_tclap_output.setArgumentHidden(&dummy_arg, true); - cmd.setOutput(&advanced_tclap_output); - - std::vector arguments = arguments_; - // parse command line - cmd.parse(arguments); - - // set globals - if (dump_config_arg.isSet()) - { - m_dump_config = true; - } - if (default_ini_file_arg.isSet()) - { - m_user_ini = default_ini_file_arg.getValue(); - } - } -#endif - } - - bool CmdParser::getDumpConfig() const { return m_dump_config; } - std::string& CmdParser::getUserIni() { return m_user_ini; } - } -} diff --git a/ecal/core/src/config/ecal_cmd_parser.h b/ecal/core/src/config/ecal_cmd_parser.h deleted file mode 100644 index bc0dec7c86..0000000000 --- a/ecal/core/src/config/ecal_cmd_parser.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ========================= eCAL LICENSE ================================= - * - * Copyright (C) 2016 - 2024 Continental Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ========================= eCAL LICENSE ================================= -*/ - -/** - * @brief Utility class for parsing cmd line arguments into eCAL useful structures. -**/ - -#pragma once - -#include - -#include -#include -#include - -namespace eCAL -{ - namespace Config - { - /** - * @brief Class for parsing and storing command line arguments and their values. - * Defaults as empty strings, vectors and false booleans. - * - * @param argc_ Number of arguments - * @param argv_ Array of arguments - * - **/ - class CmdParser - { - public: - CmdParser(const std::vector& arguments_); - CmdParser(); - - void parseArguments(const std::vector& arguments_); - - bool getDumpConfig() const; - std::string& getUserIni(); - - private: - bool m_dump_config; - std::string m_user_ini; - }; - } -} \ No newline at end of file diff --git a/ecal/core/src/config/ecal_config_initializer.cpp b/ecal/core/src/config/ecal_config_initializer.cpp index 830acb3a7c..9d005ef577 100644 --- a/ecal/core/src/config/ecal_config_initializer.cpp +++ b/ecal/core/src/config/ecal_config_initializer.cpp @@ -28,7 +28,6 @@ #include "ecal_def.h" #include "ecal/ecal_process.h" -#include "config/ecal_cmd_parser.h" #ifdef ECAL_CORE_CONFIGURATION #include "configuration_reader.h" @@ -59,6 +58,7 @@ #include #include +#include namespace { @@ -206,22 +206,6 @@ namespace return found_path + config_file_; } - - std::vector ConvertArgcArgvToVector(int argc_, char** argv_) - { - std::vector arguments; - if (argc_ > 0 && argv_ != nullptr) - { - for (size_t i = 0; i < static_cast(argc_); ++i) - { - if (argv_[i] != nullptr) - { - arguments.emplace_back(argv_[i]); - } - } - } - return arguments; - } } namespace eCAL @@ -244,36 +228,12 @@ namespace eCAL } } - Configuration::Configuration(int argc_ , char **argv_) - : Configuration(ConvertArgcArgvToVector(argc_, argv_)) - { - } - - Configuration::Configuration(const std::vector& args_) - { - Config::CmdParser parser(args_); - - command_line_arguments.user_yaml = parser.getUserIni(); - command_line_arguments.dump_config = parser.getDumpConfig(); - - if (!command_line_arguments.user_yaml.empty()) - { - InitFromFile(command_line_arguments.user_yaml); - } - else - { - InitFromConfig(); - } - } - void Configuration::InitFromConfig() { InitFromFile(g_default_ini_file); } - Configuration::Configuration() - { - } + Configuration::Configuration() = default; std::string Configuration::GetYamlFilePath() { diff --git a/ecal/core/src/ecal.cpp b/ecal/core/src/ecal.cpp index 5fbd3296e8..e689e4012c 100644 --- a/ecal/core/src/ecal.cpp +++ b/ecal/core/src/ecal.cpp @@ -24,7 +24,6 @@ #include "ecal_def.h" #include "ecal_event.h" #include "ecal_globals.h" -#include "config/ecal_cmd_parser.h" #include #include @@ -55,9 +54,9 @@ namespace eCAL * * @return Full eCAL version string. **/ - const char* GetVersionString() + std::string GetVersionString() { - return(ECAL_VERSION); + return ECAL_VERSION; } /** @@ -65,58 +64,32 @@ namespace eCAL * * @return Full eCAL version date string. **/ - const char* GetVersionDateString() + std::string GetVersionDateString() { - return(ECAL_DATE); + return ECAL_DATE; } /** * @brief Get eCAL version as separated integer values. * - * @param [out] major_ The eCAL major version number. - * @param [out] minor_ The eCAL minor version number. - * @param [out] patch_ The eCAL patch version number. - * - * @return Zero if succeeded. + * @return struct SVersion that contains major, minor and patch value. **/ - int GetVersion(int* major_, int* minor_, int* patch_) + SVersion GetVersion() { - if((major_ == nullptr) || (minor_ == nullptr) || (patch_ == nullptr)) return(-1); - *major_ = ECAL_VERSION_MAJOR; - *minor_ = ECAL_VERSION_MINOR; - *patch_ = ECAL_VERSION_PATCH; - return(0); + return SVersion{ ECAL_VERSION_MAJOR, ECAL_VERSION_MINOR, ECAL_VERSION_PATCH }; } /** * @brief Initialize eCAL API. * - * @param argc_ Number of command line arguments. - * @param argv_ Array of command line arguments. - * @param unit_name_ Defines the name of the eCAL unit. - * @param components_ Defines which component to initialize. - * - * @return Zero if succeeded, 1 if already initialized, -1 if failed. - **/ - int Initialize(int argc_ , char **argv_, const char *unit_name_, unsigned int components_) - { - eCAL::Configuration config(argc_, argv_); - - return Initialize(config, unit_name_, components_); - } - - /** - * @brief Initialize eCAL API. - * - * @param args_ Vector of config arguments to overwrite (["arg1", "value1", "arg2", "arg3", "value3" ..]). * @param unit_name_ Defines the name of the eCAL unit. * @param components_ Defines which component to initialize. * * @return Zero if succeeded, 1 if already initialized, -1 if failed. **/ - int Initialize(std::vector args_, const char *unit_name_, unsigned int components_) //-V826 + int Initialize(const std::string& unit_name_ /*= ""*/, unsigned int components_ /*= Init::Default*/) { - eCAL::Configuration config(args_); + eCAL::Configuration config; return Initialize(config, unit_name_, components_); } @@ -130,16 +103,13 @@ namespace eCAL * * @return Zero if succeeded, 1 if already initialized, -1 if failed. **/ - int Initialize(eCAL::Configuration& config_, const char *unit_name_ /*= nullptr*/, unsigned int components_ /*= Init::Default*/) + int Initialize(eCAL::Configuration& config_, const std::string& unit_name_ /*= nullptr*/, unsigned int components_ /*= Init::Default*/) { InitGlobals(); g_ecal_configuration = config_; - if (unit_name_ != nullptr) - { - SetGlobalUnitName(unit_name_); - } + SetGlobalUnitName(unit_name_.c_str()); g_globals_ctx_ref_cnt++; @@ -154,6 +124,20 @@ namespace eCAL return success; } + /** + * @brief Check eCAL initialize state. + * + * @param component_ Check specific component or 0 for general state of eCAL core. + * + * @return 1 if eCAL is initialized. + **/ + int IsInitialized() + { + if (g_globals_ctx == nullptr) return(0); + if(g_globals()->IsInitialized()) return(1); + return(0); + } + /** * @brief Check eCAL initialize state. * @@ -164,7 +148,7 @@ namespace eCAL int IsInitialized(unsigned int component_) { if (g_globals_ctx == nullptr) return(0); - if(g_globals()->IsInitialized(component_)) return(1); + if (g_globals()->IsInitialized(component_)) return(1); return(0); } @@ -175,14 +159,10 @@ namespace eCAL * * @return Zero if succeeded, -1 if failed. **/ - int SetUnitName(const char *unit_name_) + int SetUnitName(const std::string& unit_name_) { - if (unit_name_ == nullptr) return -1; - - const std::string uname = unit_name_; - if (uname.empty()) return -1; - - g_unit_name = uname; + if (unit_name_.empty()) return -1; + g_unit_name = unit_name_; return 0; } diff --git a/ecal/core/src/ecal_descgate.cpp b/ecal/core/src/ecal_descgate.cpp index 786f28ea97..0a143f0643 100644 --- a/ecal/core/src/ecal_descgate.cpp +++ b/ecal/core/src/ecal_descgate.cpp @@ -27,26 +27,11 @@ namespace { - eCAL::Registration::DescQualityFlags GetDataTypeInfoQuality(const eCAL::SDataTypeInformation& data_type_info_, bool is_producer_) - { - eCAL::Registration::DescQualityFlags quality = eCAL::Registration::DescQualityFlags::NO_QUALITY; - if (!data_type_info_.name.empty()) - quality |= eCAL::Registration::DescQualityFlags::TYPENAME_AVAILABLE; - if (!data_type_info_.encoding.empty()) - quality |= eCAL::Registration::DescQualityFlags::ENCODING_AVAILABLE; - if (!data_type_info_.descriptor.empty()) - quality |= eCAL::Registration::DescQualityFlags::DESCRIPTION_AVAILABLE; - if(is_producer_) quality |= eCAL::Registration::DescQualityFlags::INFO_COMES_FROM_PRODUCER; - return quality; - } - eCAL::Registration::SEntityId ConvertToEntityId(const eCAL::Registration::SampleIdentifier& sample_identifier) { eCAL::Registration::SEntityId id{ sample_identifier.entity_id, sample_identifier.process_id, sample_identifier.host_name}; return id; } - - } namespace eCAL @@ -59,7 +44,7 @@ namespace eCAL return GetTopicIDs(m_publisher_info_map); } - bool CDescGate::GetPublisherInfo(const Registration::STopicId& id_, Registration::SQualityTopicInfo& topic_info_) const + bool CDescGate::GetPublisherInfo(const Registration::STopicId& id_, SDataTypeInformation& topic_info_) const { return GetTopic(id_, m_publisher_info_map, topic_info_); } @@ -85,7 +70,7 @@ namespace eCAL return GetTopicIDs(m_subscriber_info_map); } - bool CDescGate::GetSubscriberInfo(const Registration::STopicId& id_, Registration::SQualityTopicInfo& topic_info_) const + bool CDescGate::GetSubscriberInfo(const Registration::STopicId& id_, SDataTypeInformation& topic_info_) const { return GetTopic(id_, m_subscriber_info_map, topic_info_); } @@ -106,27 +91,27 @@ namespace eCAL m_subscriber_callback_map.map.erase(token_); } - std::set CDescGate::GetServiceIDs() const + std::set CDescGate::GetServiceIDs() const { return GetServiceIDs(m_service_info_map); } - bool CDescGate::GetServiceInfo(const Registration::SServiceId& id_, Registration::SQualityServiceInfo& service_info_) const + bool CDescGate::GetServiceInfo(const Registration::SServiceMethodId& id_, SServiceMethodInformation& service_info_) const { return GetService(id_, m_service_info_map, service_info_); } - std::set CDescGate::GetClientIDs() const + std::set CDescGate::GetClientIDs() const { return GetServiceIDs(m_client_info_map); } - bool CDescGate::GetClientInfo(const Registration::SServiceId& id_, Registration::SQualityServiceInfo& service_info_) const + bool CDescGate::GetClientInfo(const Registration::SServiceMethodId& id_, SServiceMethodInformation& service_info_) const { return GetService(id_, m_client_info_map, service_info_); } - std::set CDescGate::GetTopicIDs(const SQualityTopicIdMap& topic_info_map_) + std::set CDescGate::GetTopicIDs(const STopicIdInfoMap& topic_info_map_) { std::set topic_id_set; @@ -138,7 +123,7 @@ namespace eCAL return topic_id_set; } - bool CDescGate::GetTopic(const Registration::STopicId& id_, const SQualityTopicIdMap& topic_info_map_, Registration::SQualityTopicInfo& topic_info_) + bool CDescGate::GetTopic(const Registration::STopicId& id_, const STopicIdInfoMap& topic_info_map_, SDataTypeInformation& topic_info_) { const std::lock_guard lock(topic_info_map_.mtx); auto iter = topic_info_map_.map.find(id_); @@ -153,9 +138,9 @@ namespace eCAL } } - std::set CDescGate::GetServiceIDs(const SQualityServiceIdMap& service_method_info_map_) + std::set CDescGate::GetServiceIDs(const SServiceIdInfoMap& service_method_info_map_) { - std::set service_id_set; + std::set service_id_set; const std::lock_guard lock(service_method_info_map_.mtx); for (const auto& service_method_info_map_it : service_method_info_map_.id_map) @@ -165,7 +150,7 @@ namespace eCAL return service_id_set; } - bool CDescGate::GetService(const Registration::SServiceId& id_, const SQualityServiceIdMap& service_method_info_map_, Registration::SQualityServiceInfo& service_method_info_) + bool CDescGate::GetService(const Registration::SServiceMethodId& id_, const SServiceIdInfoMap& service_method_info_map_, SServiceMethodInformation& service_method_info_) { const std::lock_guard lock(service_method_info_map_.mtx); auto iter = service_method_info_map_.id_map.find(id_); @@ -201,7 +186,7 @@ namespace eCAL response_type.name = method.resp_type; response_type.descriptor = method.resp_desc; - ApplyServiceDescription(m_service_info_map, sample_.identifier, sample_.service.sname, method.mname, request_type, response_type, GetDataTypeInfoQuality(request_type, true), GetDataTypeInfoQuality(response_type, true)); + ApplyServiceDescription(m_service_info_map, sample_.identifier, sample_.service.sname, method.mname, request_type, response_type); } } break; @@ -219,20 +204,20 @@ namespace eCAL response_type.name = method.resp_type; response_type.descriptor = method.resp_desc; - ApplyServiceDescription(m_client_info_map, sample_.identifier, sample_.client.sname, method.mname, request_type, response_type, GetDataTypeInfoQuality(request_type, false), GetDataTypeInfoQuality(response_type, false)); + ApplyServiceDescription(m_client_info_map, sample_.identifier, sample_.client.sname, method.mname, request_type, response_type); } break; case bct_unreg_client: RemServiceDescription(m_client_info_map, sample_.identifier, sample_.client.sname); break; case bct_reg_publisher: - ApplyTopicDescription(m_publisher_info_map, m_publisher_callback_map, sample_.identifier, sample_.topic.tname, sample_.topic.tdatatype, GetDataTypeInfoQuality(sample_.topic.tdatatype, true)); + ApplyTopicDescription(m_publisher_info_map, m_publisher_callback_map, sample_.identifier, sample_.topic.tname, sample_.topic.tdatatype); break; case bct_unreg_publisher: RemTopicDescription(m_publisher_info_map, m_publisher_callback_map, sample_.identifier, sample_.topic.tname); break; case bct_reg_subscriber: - ApplyTopicDescription(m_subscriber_info_map, m_subscriber_callback_map, sample_.identifier, sample_.topic.tname, sample_.topic.tdatatype, GetDataTypeInfoQuality(sample_.topic.tdatatype, false)); + ApplyTopicDescription(m_subscriber_info_map, m_subscriber_callback_map, sample_.identifier, sample_.topic.tname, sample_.topic.tdatatype); break; case bct_unreg_subscriber: RemTopicDescription(m_subscriber_info_map, m_subscriber_callback_map, sample_.identifier, sample_.topic.tname); @@ -245,12 +230,11 @@ namespace eCAL } } - void CDescGate::ApplyTopicDescription(SQualityTopicIdMap& topic_info_map_, + void CDescGate::ApplyTopicDescription(STopicIdInfoMap& topic_info_map_, const STopicIdCallbackMap& topic_callback_map_, const Registration::SampleIdentifier& topic_id_, const std::string& topic_name_, - const SDataTypeInformation& topic_info_, - const Registration::DescQualityFlags topic_quality_) + const SDataTypeInformation& topic_info_) { const auto topic_info_key = Registration::STopicId{ ConvertToEntityId(topic_id_), topic_name_ }; @@ -258,16 +242,15 @@ namespace eCAL bool new_topic_info(false); { const std::unique_lock lock(topic_info_map_.mtx); - QualityTopicIdMap::iterator topic_info_quality_iter = topic_info_map_.map.find(topic_info_key); + TopicIdInfoMap::iterator topic_info_quality_iter = topic_info_map_.map.find(topic_info_key); new_topic_info = topic_info_quality_iter == topic_info_map_.map.end(); if (new_topic_info) { - std::tie(topic_info_quality_iter, std::ignore) = topic_info_map_.map.emplace(topic_info_key, Registration::SQualityTopicInfo{}); + std::tie(topic_info_quality_iter, std::ignore) = topic_info_map_.map.emplace(topic_info_key, SDataTypeInformation{}); } - topic_info_quality_iter->second.info = topic_info_; - topic_info_quality_iter->second.quality = topic_quality_; + topic_info_quality_iter->second = topic_info_; } // notify publisher / subscriber registration callbacks about new entity @@ -284,7 +267,7 @@ namespace eCAL } } - void CDescGate::RemTopicDescription(SQualityTopicIdMap& topic_info_map_, + void CDescGate::RemTopicDescription(STopicIdInfoMap& topic_info_map_, const STopicIdCallbackMap& topic_callback_map_, const Registration::SampleIdentifier& topic_id_, const std::string& topic_name_) @@ -312,32 +295,28 @@ namespace eCAL } } - void CDescGate::ApplyServiceDescription(SQualityServiceIdMap& service_method_info_map_, + void CDescGate::ApplyServiceDescription(SServiceIdInfoMap& service_method_info_map_, const Registration::SampleIdentifier& service_id_, const std::string& service_name_, const std::string& method_name_, const SDataTypeInformation& request_type_information_, - const SDataTypeInformation& response_type_information_, - const Registration::DescQualityFlags request_type_quality_, - const Registration::DescQualityFlags response_type_quality_) + const SDataTypeInformation& response_type_information_) { - const auto service_method_info_key = Registration::SServiceId{ ConvertToEntityId(service_id_), service_name_, method_name_}; + const auto service_method_info_key = Registration::SServiceMethodId{ ConvertToEntityId(service_id_), service_name_, method_name_}; - Registration::SQualityServiceInfo service_quality_info; - service_quality_info.info.request_type = request_type_information_; - service_quality_info.info.response_type = response_type_information_; - service_quality_info.request_quality = request_type_quality_; - service_quality_info.response_quality = response_type_quality_; + SServiceMethodInformation service_info; + service_info.request_type = request_type_information_; + service_info.response_type = response_type_information_; const std::lock_guard lock(service_method_info_map_.mtx); - service_method_info_map_.id_map[service_method_info_key] = service_quality_info; + service_method_info_map_.id_map[service_method_info_key] = service_info; } - void CDescGate::RemServiceDescription(SQualityServiceIdMap& service_method_info_map_, + void CDescGate::RemServiceDescription(SServiceIdInfoMap& service_method_info_map_, const Registration::SampleIdentifier& service_id_, const std::string& service_name_) { - std::list service_method_info_keys_to_remove; + std::list service_method_info_keys_to_remove; const std::lock_guard lock(service_method_info_map_.mtx); diff --git a/ecal/core/src/ecal_descgate.h b/ecal/core/src/ecal_descgate.h index 76262e45e5..94bfca8bf3 100644 --- a/ecal/core/src/ecal_descgate.h +++ b/ecal/core/src/ecal_descgate.h @@ -49,23 +49,23 @@ namespace eCAL // get publisher information std::set GetPublisherIDs() const; - bool GetPublisherInfo(const Registration::STopicId& id_, Registration::SQualityTopicInfo& topic_info_) const; + bool GetPublisherInfo(const Registration::STopicId& id_, SDataTypeInformation& topic_info_) const; Registration::CallbackToken AddPublisherEventCallback(const Registration::TopicIDCallbackT& callback_); void RemPublisherEventCallback(Registration::CallbackToken token_); // get subscriber information std::set GetSubscriberIDs() const; - bool GetSubscriberInfo(const Registration::STopicId& id_, Registration::SQualityTopicInfo& topic_info_) const; + bool GetSubscriberInfo(const Registration::STopicId& id_, SDataTypeInformation& topic_info_) const; Registration::CallbackToken AddSubscriberEventCallback(const Registration::TopicIDCallbackT& callback_); void RemSubscriberEventCallback(Registration::CallbackToken token_); // get service information - std::set GetServiceIDs() const; - bool GetServiceInfo(const Registration::SServiceId& id_, Registration::SQualityServiceInfo& service_info_) const; + std::set GetServiceIDs() const; + bool GetServiceInfo(const Registration::SServiceMethodId& id_, SServiceMethodInformation& service_info_) const; // get client information - std::set GetClientIDs() const; - bool GetClientInfo(const Registration::SServiceId& id_, Registration::SQualityServiceInfo& service_info_) const; + std::set GetClientIDs() const; + bool GetClientInfo(const Registration::SServiceMethodId& id_, SServiceMethodInformation& service_info_) const; // delete copy constructor and copy assignment operator CDescGate(const CDescGate&) = delete; @@ -76,11 +76,11 @@ namespace eCAL CDescGate& operator=(CDescGate&&) = delete; protected: - using QualityTopicIdMap = std::map; - struct SQualityTopicIdMap + using TopicIdInfoMap = std::map; + struct STopicIdInfoMap { mutable std::mutex mtx; - QualityTopicIdMap map; + TopicIdInfoMap map; }; using TopicIdCallbackMap = std::map; @@ -90,56 +90,53 @@ namespace eCAL TopicIdCallbackMap map; }; - using QualityServiceIdMap = std::map; - struct SQualityServiceIdMap + using ServiceIdInfoMap = std::map; + struct SServiceIdInfoMap { mutable std::mutex mtx; - QualityServiceIdMap id_map; + ServiceIdInfoMap id_map; }; - static std::set GetTopicIDs(const SQualityTopicIdMap& topic_info_map_); - static bool GetTopic (const Registration::STopicId& id_, const SQualityTopicIdMap& topic_info_map_, Registration::SQualityTopicInfo& topic_info_); + static std::set GetTopicIDs(const STopicIdInfoMap& topic_info_map_); + static bool GetTopic (const Registration::STopicId& id_, const STopicIdInfoMap& topic_info_map_, SDataTypeInformation& topic_info_); - static std::set GetServiceIDs(const SQualityServiceIdMap& service_method_info_map_); - static bool GetService (const Registration::SServiceId& id_, const SQualityServiceIdMap& service_method_info_map_, Registration::SQualityServiceInfo& service_method_info_); + static std::set GetServiceIDs(const SServiceIdInfoMap& service_method_info_map_); + static bool GetService (const Registration::SServiceMethodId& id_, const SServiceIdInfoMap& service_method_info_map_, SServiceMethodInformation& service_method_info_); - static void ApplyTopicDescription(SQualityTopicIdMap& topic_info_map_, + static void ApplyTopicDescription(STopicIdInfoMap& topic_info_map_, const STopicIdCallbackMap& topic_callback_map_, const Registration::SampleIdentifier& topic_id_, const std::string& topic_name_, - const SDataTypeInformation& topic_info_, - Registration::DescQualityFlags topic_quality_); + const SDataTypeInformation& topic_info_); - static void RemTopicDescription(SQualityTopicIdMap& topic_info_map_, + static void RemTopicDescription(STopicIdInfoMap& topic_info_map_, const STopicIdCallbackMap& topic_callback_map_, const Registration::SampleIdentifier& topic_id_, const std::string& topic_name_); - static void ApplyServiceDescription(SQualityServiceIdMap& service_method_info_map_, + static void ApplyServiceDescription(SServiceIdInfoMap& service_method_info_map_, const Registration::SampleIdentifier& service_id_, const std::string& service_name_, const std::string& method_name_, const SDataTypeInformation& request_type_information_, - const SDataTypeInformation& response_type_information_, - Registration::DescQualityFlags request_type_quality_, - Registration::DescQualityFlags response_type_quality_); + const SDataTypeInformation& response_type_information_); - static void RemServiceDescription(SQualityServiceIdMap& service_method_info_map_, + static void RemServiceDescription(SServiceIdInfoMap& service_method_info_map_, const Registration::SampleIdentifier& service_id_, const std::string& service_name_); Registration::CallbackToken CreateToken(); // internal quality topic info publisher/subscriber maps - SQualityTopicIdMap m_publisher_info_map; - STopicIdCallbackMap m_publisher_callback_map; + STopicIdInfoMap m_publisher_info_map; + STopicIdCallbackMap m_publisher_callback_map; - SQualityTopicIdMap m_subscriber_info_map; - STopicIdCallbackMap m_subscriber_callback_map; + STopicIdInfoMap m_subscriber_info_map; + STopicIdCallbackMap m_subscriber_callback_map; // internal quality service info service/client maps - SQualityServiceIdMap m_service_info_map; - SQualityServiceIdMap m_client_info_map; + SServiceIdInfoMap m_service_info_map; + SServiceIdInfoMap m_client_info_map; mutable std::mutex m_callback_token_mtx; std::atomic m_callback_token{ 0 }; diff --git a/ecal/core/src/ecal_globals.cpp b/ecal/core/src/ecal_globals.cpp index 70eeeb3ec3..40d7aca23a 100644 --- a/ecal/core/src/ecal_globals.cpp +++ b/ecal/core/src/ecal_globals.cpp @@ -239,14 +239,13 @@ namespace eCAL else return 1; } - bool CGlobals::IsInitialized(unsigned int component_) + bool CGlobals::IsInitialized() { - // check common initialization - if (component_ == 0) - { - return(initialized); - } + return initialized; + } + bool CGlobals::IsInitialized(unsigned int component_) + { // check single component initialization switch (component_) { diff --git a/ecal/core/src/ecal_globals.h b/ecal/core/src/ecal_globals.h index 1104452960..72dd12e60e 100644 --- a/ecal/core/src/ecal_globals.h +++ b/ecal/core/src/ecal_globals.h @@ -62,6 +62,7 @@ namespace eCAL ~CGlobals(); int Initialize ( unsigned int components_); + bool IsInitialized (); bool IsInitialized ( unsigned int component_ ); unsigned int GetComponents() const { return(components); }; diff --git a/ecal/core/src/ecal_util.cpp b/ecal/core/src/ecal_util.cpp index 6e11e4ecbd..050c995f0d 100644 --- a/ecal/core/src/ecal_util.cpp +++ b/ecal/core/src/ecal_util.cpp @@ -33,34 +33,13 @@ namespace eCAL { namespace Util { - void EnableLoopback(bool state_) - { -#if ECAL_CORE_REGISTRATION - if (g_registration_receiver() != nullptr) g_registration_receiver()->EnableLoopback(state_); -#endif - } - - void PubShareType(bool state_) - { -#if ECAL_CORE_PUBLISHER - if (g_pubgate() != nullptr) g_pubgate()->ShareType(state_); -#endif - } - - void PubShareDescription(bool state_) - { -#if ECAL_CORE_PUBLISHER - if (g_pubgate() != nullptr) g_pubgate()->ShareDescription(state_); -#endif - } - #if ECAL_CORE_MONITORING // take monitoring snapshot static Monitoring::SMonitoring GetMonitoring() { if (IsInitialized(Init::Monitoring) == 0) { - Initialize(0, nullptr, "", Init::Monitoring); + Initialize("", Init::Monitoring); Process::SleepMS(1000); } @@ -99,7 +78,7 @@ namespace eCAL EventHandleT event; if (gOpenNamedEvent(&event, event_name, true)) { - std::cout << "Shutdown local eCAL process " << process_id_ << '\n'; + //std::cout << "Shutdown local eCAL process " << process_id_ << '\n'; gSetEvent(event); gCloseEvent(event); } diff --git a/ecal/core/src/monitoring/ecal_monitoring_impl.cpp b/ecal/core/src/monitoring/ecal_monitoring_impl.cpp index dc2e10a253..aee83cfafe 100644 --- a/ecal/core/src/monitoring/ecal_monitoring_impl.cpp +++ b/ecal/core/src/monitoring/ecal_monitoring_impl.cpp @@ -49,9 +49,6 @@ namespace eCAL { if (m_init) return; - // enable loopback to monitor process internal entities as well - eCAL::Util::EnableLoopback(true); - // utilize registration receiver to enrich monitor information g_registration_receiver()->SetCustomApplySampleCallback("monitoring", [this](const auto& sample_){this->ApplySample(sample_, tl_none);}); diff --git a/ecal/core/src/pubsub/config/builder/reader_attribute_builder.cpp b/ecal/core/src/pubsub/config/builder/reader_attribute_builder.cpp index f97fed54fb..2703e0a499 100644 --- a/ecal/core/src/pubsub/config/builder/reader_attribute_builder.cpp +++ b/ecal/core/src/pubsub/config/builder/reader_attribute_builder.cpp @@ -29,7 +29,7 @@ namespace eCAL attributes.network_enabled = reg_config_.network_enabled; attributes.loopback = reg_config_.loopback; attributes.drop_out_of_order_messages = sub_config_.drop_out_of_order_messages; - attributes.registation_timeout_ms = reg_config_.registration_timeout; + attributes.registration_timeout_ms = reg_config_.registration_timeout; attributes.topic_name = topic_name_; attributes.host_name = Process::GetHostName(); attributes.host_group_name = Process::GetHostGroupName(); diff --git a/ecal/core/src/pubsub/ecal_pubgate.cpp b/ecal/core/src/pubsub/ecal_pubgate.cpp index 1ca992191c..19e52073f7 100644 --- a/ecal/core/src/pubsub/ecal_pubgate.cpp +++ b/ecal/core/src/pubsub/ecal_pubgate.cpp @@ -37,11 +37,7 @@ namespace eCAL // CPubGate ////////////////////////////////////////////////////////////////// std::atomic CPubGate::m_created; - CPubGate::CPubGate() : - m_share_type(true), - m_share_desc(true) - { - } + CPubGate::CPubGate() = default; CPubGate::~CPubGate() { @@ -69,16 +65,6 @@ namespace eCAL m_created = false; } - void CPubGate::ShareType(bool state_) - { - m_share_type = state_; - } - - void CPubGate::ShareDescription(bool state_) - { - m_share_desc = state_; - } - bool CPubGate::Register(const std::string& topic_name_, const std::shared_ptr& datawriter_) { if(!m_created) return(false); diff --git a/ecal/core/src/pubsub/ecal_pubgate.h b/ecal/core/src/pubsub/ecal_pubgate.h index 0db416cc06..cc73d36bc7 100644 --- a/ecal/core/src/pubsub/ecal_pubgate.h +++ b/ecal/core/src/pubsub/ecal_pubgate.h @@ -44,12 +44,6 @@ namespace eCAL void Start(); void Stop(); - void ShareType(bool state_); - bool TypeShared() const { return m_share_type; }; - - void ShareDescription(bool state_); - bool DescriptionShared() const { return m_share_desc; }; - bool Register(const std::string& topic_name_, const std::shared_ptr& datawriter_); bool Unregister(const std::string& topic_name_, const std::shared_ptr& datawriter_); @@ -60,8 +54,6 @@ namespace eCAL protected: static std::atomic m_created; - bool m_share_type; - bool m_share_desc; using TopicNameDataWriterMapT = std::multimap>; std::shared_timed_mutex m_topic_name_datawriter_sync; diff --git a/ecal/core/src/readwrite/config/attributes/reader_attributes.h b/ecal/core/src/readwrite/config/attributes/reader_attributes.h index 0d8ad85e1a..117a8ddac4 100644 --- a/ecal/core/src/readwrite/config/attributes/reader_attributes.h +++ b/ecal/core/src/readwrite/config/attributes/reader_attributes.h @@ -59,7 +59,7 @@ namespace eCAL bool network_enabled; bool drop_out_of_order_messages; bool loopback; - unsigned int registation_timeout_ms; + unsigned int registration_timeout_ms; SUDPAttributes udp; STCPAttributes tcp; diff --git a/ecal/core/src/readwrite/config/builder/shm_attribute_builder.cpp b/ecal/core/src/readwrite/config/builder/shm_attribute_builder.cpp index f1b7105a74..f822810157 100644 --- a/ecal/core/src/readwrite/config/builder/shm_attribute_builder.cpp +++ b/ecal/core/src/readwrite/config/builder/shm_attribute_builder.cpp @@ -28,7 +28,7 @@ namespace eCAL SHM::SAttributes attributes; attributes.process_id = attr_.process_id; - attributes.registration_timeout_ms = attr_.registation_timeout_ms; + attributes.registration_timeout_ms = attr_.registration_timeout_ms; return attributes; } diff --git a/ecal/core/src/registration/ecal_registration.cpp b/ecal/core/src/registration/ecal_registration.cpp index 72713cc248..1759521660 100644 --- a/ecal/core/src/registration/ecal_registration.cpp +++ b/ecal/core/src/registration/ecal_registration.cpp @@ -30,133 +30,6 @@ #include "registration/ecal_registration_receiver.h" #include "pubsub/ecal_pubgate.h" -namespace -{ - /** - * @brief Extract a set of all SQualityTopicInfo matching the given topic name. - * - * @param topic_name_ The topic name. - * @param quality_data_type_info_multi_map_ MultiMap { TopicName -> SQualityTopicInfo }. - * - * @return Set of SQualityTopicInfo - **/ - std::set GetQualityTopicInfoSet(const std::string& topic_name_, const eCAL::Registration::QualityTopicInfoMultiMap& quality_data_type_info_multi_map_) - { - std::set quality_topic_info_set; - - const auto topic_info_range = quality_data_type_info_multi_map_.equal_range(topic_name_); - for (auto topic_info_range_it = topic_info_range.first; topic_info_range_it != topic_info_range.second; ++topic_info_range_it) - { - quality_topic_info_set.insert(topic_info_range_it->second); - } - - return quality_topic_info_set; - } - - /** - * @brief Extract a set of all SQualityServiceInfo matching the given service name/method name. - * - * @param service_name_ The service name. - * @param method_name_ The method name. - * @param quality_service_info_multi_map_ MultiMap { -> SQualityServiceInfo }. - * - * @return Set of SQualityServiceInfo - **/ - std::set GetQualityServiceInfoSet(const std::string& service_name_, const std::string& method_name_, const eCAL::Registration::QualityServiceInfoMultimap& quality_service_info_multi_map_) - { - std::set quality_service_info_set; - - eCAL::Registration::SServiceMethod key; - key.service_name = service_name_; - key.method_name = method_name_; - const auto service_info_range = quality_service_info_multi_map_.equal_range(key); - for (auto service_info_range_it = service_info_range.first; service_info_range_it != service_info_range.second; ++service_info_range_it) - { - quality_service_info_set.insert(service_info_range_it->second); - } - - return quality_service_info_set; - } - - /** - * @brief Reducing std::map<(TopicName, TopicID), SQualityTopicInfo> to - * std::map based on the quality - * - * @param source_map_ std::map<(TopicName, TopicID), SQualityTopicInfo>. - * - * @return std::map - **/ - std::map ReduceQualityTopicIdMap(const eCAL::Registration::QualityTopicInfoMultiMap& source_map_) - { - std::map target_map; - - for (const auto& source_pair : source_map_) - { - const auto& source_key = source_pair.first; - const auto& source_value = source_pair.second; - - auto target_it = target_map.find(source_key); - if (target_it != target_map.end()) - { - // key exists in target map - if (source_value.quality > target_it->second.quality) - { - // source quality is greater, overwrite - target_it->second = source_value; - } - } - else - { - // key does not exist in target map, insert source pair - target_map.insert(std::make_pair(source_key, source_value)); - } - } - - return target_map; - } - - /** - * @brief Reducing std::map<(ServiceName, ServiceId, MethodName), SQualityServiceInfo> to - * std::map, SQualityServiceInfo> based on the quality - * - * @param source_map_ std::map<(ServiceName, ServiceId, MethodName), SQualityServiceInfo>. - * - * @return std::map, SQualityServiceInfo> - **/ - std::map ReduceQualityServiceIdMap(const eCAL::Registration::QualityServiceInfoMultimap& source_map_) - { - std::map target_map; - - for (const auto& source_pair : source_map_) - { - const auto& source_key = source_pair.first; - const auto& source_value = source_pair.second; - - eCAL::Registration::SServiceMethod target_key; - target_key.service_name = source_key.service_name; - target_key.method_name = source_key.method_name; - auto target_it = target_map.find(target_key); - if (target_it != target_map.end()) - { - // key exists in target map - if ( (source_value.request_quality > target_it->second.request_quality) - || (source_value.response_quality > target_it->second.response_quality)) - { - // source quality is greater, overwrite - target_it->second = source_value; - } - } - else - { - // key does not exist in target map, insert source pair - target_map.insert(std::make_pair(target_key, source_pair.second)); - } - } - - return target_map; - } -} - namespace eCAL { namespace Registration @@ -167,7 +40,7 @@ namespace eCAL return g_descgate()->GetPublisherIDs(); } - bool GetPublisherInfo(const STopicId& id_, SQualityTopicInfo& topic_info_) + bool GetPublisherInfo(const STopicId& id_, SDataTypeInformation& topic_info_) { if (g_descgate() == nullptr) return false; return g_descgate()->GetPublisherInfo(id_, topic_info_); @@ -191,7 +64,7 @@ namespace eCAL return g_descgate()->GetSubscriberIDs(); } - bool GetSubscriberInfo(const STopicId& id_, SQualityTopicInfo& topic_info_) + bool GetSubscriberInfo(const STopicId& id_, SDataTypeInformation& topic_info_) { if (g_descgate() == nullptr) return false; return g_descgate()->GetSubscriberInfo(id_, topic_info_); @@ -209,301 +82,69 @@ namespace eCAL return g_descgate()->RemSubscriberEventCallback(token_); } - std::set GetServiceIDs() + std::set GetServiceIDs() { - if (g_descgate() == nullptr) return std::set(); + if (g_descgate() == nullptr) return std::set(); return g_descgate()->GetServiceIDs(); } - bool GetServiceInfo(const SServiceId& id_, SQualityServiceInfo& service_info_) + bool GetServiceInfo(const SServiceMethodId& id_, SServiceMethodInformation& service_info_) { if (g_descgate() == nullptr) return false; return g_descgate()->GetServiceInfo(id_, service_info_); } - std::set GetClientIDs() + std::set GetClientIDs() { - if (g_descgate() == nullptr) return std::set(); + if (g_descgate() == nullptr) return std::set(); return g_descgate()->GetClientIDs(); } - bool GetClientInfo(const SServiceId& id_, SQualityServiceInfo& service_info_) + bool GetClientInfo(const SServiceMethodId& id_, SServiceMethodInformation& service_info_) { if (g_descgate() == nullptr) return false; return g_descgate()->GetClientInfo(id_, service_info_); } - QualityTopicInfoMultiMap GetPublishers() - { - const std::set id_set = GetPublisherIDs(); - - Registration::QualityTopicInfoMultiMap multi_map; - for (const auto& id : id_set) - { - SQualityTopicInfo quality_info; - if (GetPublisherInfo(id, quality_info)) - { - multi_map.insert(std::pair(id.topic_name, quality_info)); - } - } - return multi_map; - } - - QualityTopicInfoSet GetPublishers(const std::string& topic_name_) - { - return ::GetQualityTopicInfoSet(topic_name_, GetPublishers()); - } - - QualityTopicInfoMultiMap GetSubscribers() - { - const std::set id_set = GetSubscriberIDs(); - - Registration::QualityTopicInfoMultiMap multi_map; - for (const auto& id : id_set) - { - SQualityTopicInfo quality_info; - if (GetSubscriberInfo(id, quality_info)) - { - multi_map.insert(std::pair(id.topic_name, quality_info)); - } - } - return multi_map; - } - - QualityTopicInfoSet GetSubscribers(const std::string& topic_name_) - { - return ::GetQualityTopicInfoSet(topic_name_, GetSubscribers()); - } - - SDataTypeInformation GetHighestQualityDataTypeInformation(const QualityTopicInfoSet& quality_topic_info_set_) - { - SQualityTopicInfo highest_quality_topic_info; - for (const auto& info : quality_topic_info_set_) - { - if (info.quality > highest_quality_topic_info.quality) - { - highest_quality_topic_info = info; - } - } - return highest_quality_topic_info.info; - } - - QualityServiceInfoMultimap GetServices() - { - const std::set id_set = GetServiceIDs(); - - Registration::QualityServiceInfoMultimap multi_map; - for (const auto& id : id_set) - { - SQualityServiceInfo quality_info; - if (GetServiceInfo(id, quality_info)) - { - multi_map.insert(std::pair(SServiceMethod{ id.service_name, id.method_name }, quality_info)); - } - } - return multi_map; - } - - QualityServiceInfoMultimap GetClients() - { - const std::set id_set = GetClientIDs(); - - Registration::QualityServiceInfoMultimap multi_map; - for (const auto& id : id_set) - { - SQualityServiceInfo quality_info; - if (GetClientInfo(id, quality_info)) - { - multi_map.insert(std::pair(SServiceMethod{ id.service_name, id.method_name }, quality_info)); - } - } - return multi_map; - } - - SServiceMethodInformation GetHighestQualityServiceMethodInformation(const SQualityServiceInfoSet& quality_service_info_set_) - { - SQualityServiceInfo highest_quality_service_info; - for (const auto& info : quality_service_info_set_) - { - if ( (info.request_quality > highest_quality_service_info.request_quality) - || (info.response_quality > highest_quality_service_info.response_quality)) - { - highest_quality_service_info = info; - } - } - return highest_quality_service_info.info; - } - - void GetTopics(std::map& data_type_info_map_) - { - data_type_info_map_.clear(); - - std::map quality_data_type_info_map; - GetTopics(quality_data_type_info_map); - - // transform into target map - for (const auto& quality_data_type_info : quality_data_type_info_map) - { - data_type_info_map_.insert(std::pair(quality_data_type_info.first, quality_data_type_info.second.info)); - } - } - - void GetTopics(std::map& quality_topic_info_map_) - { - quality_topic_info_map_.clear(); - - QualityTopicInfoMultiMap pub_sub_map = GetPublishers(); - QualityTopicInfoMultiMap sub_map = GetSubscribers(); - pub_sub_map.insert(sub_map.begin(), sub_map.end()); - - // transform into a map with the highest quality data type information - quality_topic_info_map_ = ReduceQualityTopicIdMap(pub_sub_map); - } - void GetTopicNames(std::set& topic_names_) { topic_names_.clear(); - // get publisher & subscriber multi maps - auto pub_multi_map = GetPublishers(); - auto sub_multi_map = GetSubscribers(); - - // filter out unique topic names into a set - for (const auto& publisher : pub_multi_map) + // get publisher & subscriber id sets and insert names into the topic_names set + const std::set pub_id_set = GetPublisherIDs(); + for (const auto& pub_id : pub_id_set) { - topic_names_.insert(publisher.first); + topic_names_.insert(pub_id.topic_name); } - for (const auto& subscriber : sub_multi_map) - { - topic_names_.insert(subscriber.first); - } - } - - bool GetTopicDataTypeInformation(const std::string& topic_name_, SDataTypeInformation& data_type_info_) - { - auto info_set = GetPublishers(topic_name_); - const auto sub_info_set = GetSubscribers(topic_name_); - - info_set.insert(sub_info_set.begin(), sub_info_set.end()); - data_type_info_ = GetHighestQualityDataTypeInformation(info_set); - - return !info_set.empty(); - } - - void GetServices(std::map& service_method_info_map_) - { - service_method_info_map_.clear(); - - std::map quality_service_method_info_map; - GetServices(quality_service_method_info_map); - - // transform into target map - for (const auto& quality_service_method_info : quality_service_method_info_map) + const std::set sub_id_set = GetSubscriberIDs(); + for (const auto& sub_id : sub_id_set) { - service_method_info_map_.insert(std::pair(quality_service_method_info.first, quality_service_method_info.second.info)); + topic_names_.insert(sub_id.topic_name); } } - void GetServices(std::map& quality_service_info_map_) - { - quality_service_info_map_.clear(); - - // transform into a map with the highest quality service method information - quality_service_info_map_ = ReduceQualityServiceIdMap(GetServices()); - } - void GetServiceMethodNames(std::set& service_method_names_) { service_method_names_.clear(); - // get services multi map - auto multi_map = GetServices(); - - // filter out unique service names into a set - for (const auto& service : multi_map) + // get services id set and insert names into the service_method_names set + const std::set service_id_set = GetServiceIDs(); + for (const auto& service_id : service_id_set) { - service_method_names_.insert(service.first); + service_method_names_.insert({ service_id.service_name, service_id.method_name }); } } - bool GetServiceTypeNames(const std::string& service_name_, const std::string& method_name_, std::string& req_type_, std::string& resp_type_) - { - const auto service_method_info_set = GetQualityServiceInfoSet(service_name_, method_name_, GetServices()); - - const SServiceMethodInformation service_method_info = GetHighestQualityServiceMethodInformation(service_method_info_set); - req_type_ = service_method_info.request_type.name; - resp_type_ = service_method_info.response_type.name; - - return !service_method_info_set.empty(); - } - - bool GetServiceDescription(const std::string& service_name_, const std::string& method_name_, std::string& req_desc_, std::string& resp_desc_) - { - const auto service_method_info_set = GetQualityServiceInfoSet(service_name_, method_name_, GetServices()); - - const SServiceMethodInformation service_method_info = GetHighestQualityServiceMethodInformation(service_method_info_set); - req_desc_ = service_method_info.request_type.descriptor; - resp_desc_ = service_method_info.response_type.descriptor; - - return !service_method_info_set.empty(); - } - - void GetClients(std::map& client_method_info_map_) - { - client_method_info_map_.clear(); - - std::map quality_client_method_info_map_; - GetClients(quality_client_method_info_map_); - - // transform into target map - for (const auto& quality_client_method_info : quality_client_method_info_map_) - { - client_method_info_map_.insert(std::pair(quality_client_method_info.first, quality_client_method_info.second.info)); - } - } - - void GetClients(std::map& quality_client_info_map_) - { - quality_client_info_map_.clear(); - - // transform into a map with the highest quality service method information - quality_client_info_map_ = ReduceQualityServiceIdMap(GetClients()); - } - void GetClientMethodNames(std::set& client_method_names_) { client_method_names_.clear(); - // get services multi map - auto multi_map = GetClients(); - - // filter out unique service names into a set - for (const auto& service : multi_map) + // get clients id set and insert names into the client_method_names set + const std::set client_id_set = GetClientIDs(); + for (const auto& client_id : client_id_set) { - client_method_names_.insert(service.first); + client_method_names_.insert({ client_id.service_name, client_id.method_name }); } } - - bool GetClientTypeNames(const std::string& client_name_, const std::string& method_name_, std::string& req_type_, std::string& resp_type_) - { - const auto service_method_info_set = GetQualityServiceInfoSet(client_name_, method_name_, GetClients()); - - const SServiceMethodInformation service_method_info = GetHighestQualityServiceMethodInformation(service_method_info_set); - req_type_ = service_method_info.request_type.name; - resp_type_ = service_method_info.response_type.name; - - return !service_method_info_set.empty(); - } - - bool GetClientDescription(const std::string& client_name_, const std::string& method_name_, std::string& req_desc_, std::string& resp_desc_) - { - const auto service_method_info_set = GetQualityServiceInfoSet(client_name_, method_name_, GetClients()); - - const SServiceMethodInformation service_method_info = GetHighestQualityServiceMethodInformation(service_method_info_set); - req_desc_ = service_method_info.request_type.descriptor; - resp_desc_ = service_method_info.response_type.descriptor; - - return !service_method_info_set.empty(); - } } } diff --git a/ecal/core/src/registration/ecal_registration_receiver.cpp b/ecal/core/src/registration/ecal_registration_receiver.cpp index 2a688654f1..8353ca4086 100644 --- a/ecal/core/src/registration/ecal_registration_receiver.cpp +++ b/ecal/core/src/registration/ecal_registration_receiver.cpp @@ -138,11 +138,6 @@ namespace eCAL m_created = false; } - void CRegistrationReceiver::EnableLoopback(bool state_) - { - m_sample_applier.EnableLoopback(state_); - } - bool CRegistrationReceiver::AddRegistrationCallback(enum eCAL_Registration_Event event_, const RegistrationCallbackT& callback_) { return m_user_applier.AddRegistrationCallback(event_, callback_); diff --git a/ecal/core/src/registration/ecal_registration_receiver.h b/ecal/core/src/registration/ecal_registration_receiver.h index 91ca5d8592..e264e21c12 100644 --- a/ecal/core/src/registration/ecal_registration_receiver.h +++ b/ecal/core/src/registration/ecal_registration_receiver.h @@ -67,8 +67,6 @@ namespace eCAL void Start(); void Stop(); - void EnableLoopback(bool state_); - bool AddRegistrationCallback(enum eCAL_Registration_Event event_, const RegistrationCallbackT& callback_); bool RemRegistrationCallback(enum eCAL_Registration_Event event_); diff --git a/ecal/core/src/registration/ecal_registration_sample_applier.cpp b/ecal/core/src/registration/ecal_registration_sample_applier.cpp index af9c240faa..516a5a58db 100644 --- a/ecal/core/src/registration/ecal_registration_sample_applier.cpp +++ b/ecal/core/src/registration/ecal_registration_sample_applier.cpp @@ -31,11 +31,6 @@ namespace eCAL { } - void CSampleApplier::EnableLoopback(bool state_) - { - m_attributes.loopback = state_; - } - bool CSampleApplier::ApplySample(const Registration::Sample& sample_) { if (!AcceptRegistrationSample(sample_)) diff --git a/ecal/core/src/registration/ecal_registration_sample_applier.h b/ecal/core/src/registration/ecal_registration_sample_applier.h index 5b340340d7..0369624f8c 100644 --- a/ecal/core/src/registration/ecal_registration_sample_applier.h +++ b/ecal/core/src/registration/ecal_registration_sample_applier.h @@ -45,8 +45,6 @@ namespace eCAL public: CSampleApplier(const SampleApplier::SAttributes& attr_); - // to be removed for eCAL 6, but keep until eCAL 5.14 - void EnableLoopback(bool state_); bool ApplySample(const Registration::Sample& sample_); using ApplySampleCallbackT = std::function; diff --git a/ecal/samples/c/pubsub/string/minimal_rec/src/minimal_rec.c b/ecal/samples/c/pubsub/string/minimal_rec/src/minimal_rec.c index ed528a9c05..825b8b3497 100644 --- a/ecal/samples/c/pubsub/string/minimal_rec/src/minimal_rec.c +++ b/ecal/samples/c/pubsub/string/minimal_rec/src/minimal_rec.c @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include #include -int main(int argc, char **argv) +int main() { ECAL_HANDLE sub = 0; int success = 0; @@ -29,7 +29,7 @@ int main(int argc, char **argv) long long time = 0; // initialize eCAL API - eCAL_Initialize(argc, argv, "minimalc_rec", eCAL_Init_Default); + eCAL_Initialize("minimalc_rec", eCAL_Init_Default); // create subscriber "Hello" sub = eCAL_Sub_New(); @@ -54,7 +54,7 @@ int main(int argc, char **argv) eCAL_Sub_Destroy(sub); // finalize eCAL API - eCAL_Finalize(eCAL_Init_All); + eCAL_Finalize(); return(0); } diff --git a/ecal/samples/c/pubsub/string/minimal_rec_cb/src/minimal_rec_cb.c b/ecal/samples/c/pubsub/string/minimal_rec_cb/src/minimal_rec_cb.c index fcadd04ab7..6d6d6e04da 100644 --- a/ecal/samples/c/pubsub/string/minimal_rec_cb/src/minimal_rec_cb.c +++ b/ecal/samples/c/pubsub/string/minimal_rec_cb/src/minimal_rec_cb.c @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,12 +28,12 @@ void OnReceive(const char* topic_name_, const struct SReceiveCallbackDataC* data printf("\"%.*s\"\n", (int)(data_->size), (char*)(data_->buf)); } -int main(int argc, char **argv) +int main() { ECAL_HANDLE sub = 0; // initialize eCAL API - eCAL_Initialize(argc, argv, "minimalc_rec_cb", eCAL_Init_Default); + eCAL_Initialize("minimalc_rec_cb", eCAL_Init_Default); // create subscriber "Hello" sub = eCAL_Sub_New(); @@ -53,7 +53,7 @@ int main(int argc, char **argv) eCAL_Sub_Destroy(sub); // finalize eCAL API - eCAL_Finalize(eCAL_Init_All); + eCAL_Finalize(); return(0); } diff --git a/ecal/samples/c/pubsub/string/minimal_snd/src/minimal_snd.c b/ecal/samples/c/pubsub/string/minimal_snd/src/minimal_snd.c index 3b2d5cae43..c8d9721452 100644 --- a/ecal/samples/c/pubsub/string/minimal_snd/src/minimal_snd.c +++ b/ecal/samples/c/pubsub/string/minimal_snd/src/minimal_snd.c @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,14 @@ #include #include -int main(int argc, char **argv) +int main() { ECAL_HANDLE pub = 0; char snd_s[] = "HELLO WORLD FROM C"; int sent = 0; // initialize eCAL API - eCAL_Initialize(argc, argv, "minimalc_snd", eCAL_Init_Default); + eCAL_Initialize("minimalc_snd", eCAL_Init_Default); // create publisher "Hello" pub = eCAL_Pub_New(); @@ -47,7 +47,7 @@ int main(int argc, char **argv) } // finalize eCAL API - eCAL_Finalize(eCAL_Init_All); + eCAL_Finalize(); return(0); } diff --git a/ecal/samples/c/services/minimal_client_c/src/minimal_client_c.c b/ecal/samples/c/services/minimal_client_c/src/minimal_client_c.c index 25d98a9cac..6ee05760f8 100644 --- a/ecal/samples/c/services/minimal_client_c/src/minimal_client_c.c +++ b/ecal/samples/c/services/minimal_client_c/src/minimal_client_c.c @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +20,13 @@ #include #include -int main(int argc, char **argv) +int main() { // the client handle ECAL_HANDLE hclient = 0; // initialize eCAL API - eCAL_Initialize(argc, argv, "minimal client c", eCAL_Init_Default); + eCAL_Initialize("minimal client c", eCAL_Init_Default); // create client for "service1" hclient = eCAL_Client_Create("service1"); @@ -71,7 +71,7 @@ int main(int argc, char **argv) eCAL_Client_Destroy(hclient); // finalize eCAL API - eCAL_Finalize(eCAL_Init_All); + eCAL_Finalize(); return(0); } diff --git a/ecal/samples/c/services/minimal_server_c/src/minimal_server_c.c b/ecal/samples/c/services/minimal_server_c/src/minimal_server_c.c index 26a07c6bc5..ae9923233e 100644 --- a/ecal/samples/c/services/minimal_server_c/src/minimal_server_c.c +++ b/ecal/samples/c/services/minimal_server_c/src/minimal_server_c.c @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,12 +47,12 @@ int OnMethodCallback(const char* method_, const char* req_type_, const char* res return 42; } -int main(int argc, char **argv) +int main() { ECAL_HANDLE hserver = 0; // initialize eCAL API - eCAL_Initialize(argc, argv, "minimal server c", eCAL_Init_Default); + eCAL_Initialize("minimal server c", eCAL_Init_Default); // create server "service1" hserver = eCAL_Server_Create("service1"); @@ -71,7 +71,7 @@ int main(int argc, char **argv) eCAL_Server_Destroy(hserver); // finalize eCAL API - eCAL_Finalize(eCAL_Init_All); + eCAL_Finalize(); return(0); } diff --git a/ecal/samples/cpp/benchmarks/counter_rec/src/counter_rec.cpp b/ecal/samples/cpp/benchmarks/counter_rec/src/counter_rec.cpp index 986371abfc..614d0a380c 100644 --- a/ecal/samples/cpp/benchmarks/counter_rec/src/counter_rec.cpp +++ b/ecal/samples/cpp/benchmarks/counter_rec/src/counter_rec.cpp @@ -21,10 +21,10 @@ #include -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "counter_rec_cb"); + eCAL::Initialize("counter_rec_cb"); // create subscriber for topic "Counter" eCAL::SDataTypeInformation datatype_information; diff --git a/ecal/samples/cpp/benchmarks/counter_snd/src/counter_snd.cpp b/ecal/samples/cpp/benchmarks/counter_snd/src/counter_snd.cpp index 9f372db897..6833ec518f 100644 --- a/ecal/samples/cpp/benchmarks/counter_snd/src/counter_snd.cpp +++ b/ecal/samples/cpp/benchmarks/counter_snd/src/counter_snd.cpp @@ -31,7 +31,7 @@ int main(int argc, char **argv) if(payload_size < 1) payload_size = 1; // initialize eCAL API - eCAL::Initialize(argc, argv, "counter_snd"); + eCAL::Initialize("counter_snd"); // create publisher for topic "Counter" eCAL::CPublisher pub("Counter", { "", "long long", "" }); diff --git a/ecal/samples/cpp/benchmarks/datarate_rec/src/datarate_rec.cpp b/ecal/samples/cpp/benchmarks/datarate_rec/src/datarate_rec.cpp index 2d3dc63a1c..97010ba096 100644 --- a/ecal/samples/cpp/benchmarks/datarate_rec/src/datarate_rec.cpp +++ b/ecal/samples/cpp/benchmarks/datarate_rec/src/datarate_rec.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) std::cout << "Topic name = " << topic_name << std::endl; // initialize eCAL API - eCAL::Initialize(argc, argv, "datarate_rec"); + eCAL::Initialize("datarate_rec"); // new subscriber eCAL::CSubscriber sub(topic_name); diff --git a/ecal/samples/cpp/benchmarks/datarate_snd/src/datarate_snd.cpp b/ecal/samples/cpp/benchmarks/datarate_snd/src/datarate_snd.cpp index 90e491acdd..df987b2228 100644 --- a/ecal/samples/cpp/benchmarks/datarate_snd/src/datarate_snd.cpp +++ b/ecal/samples/cpp/benchmarks/datarate_snd/src/datarate_snd.cpp @@ -62,7 +62,7 @@ int main(int argc, char **argv) std::cout << "Acknowledgement time = " << acknowledge_time << " ms" << std::endl; // initialize eCAL API - eCAL::Initialize(argc, argv, "datarate_snd"); + eCAL::Initialize("datarate_snd"); // create publisher config eCAL::Publisher::Configuration pub_config; diff --git a/ecal/samples/cpp/benchmarks/dynsize_snd/src/dynsize_snd.cpp b/ecal/samples/cpp/benchmarks/dynsize_snd/src/dynsize_snd.cpp index 460949672e..6aac3a5896 100644 --- a/ecal/samples/cpp/benchmarks/dynsize_snd/src/dynsize_snd.cpp +++ b/ecal/samples/cpp/benchmarks/dynsize_snd/src/dynsize_snd.cpp @@ -21,10 +21,10 @@ #include #include -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "dynsize_snd"); + eCAL::Initialize("dynsize_snd"); // publisher for topic "Performance" eCAL::CPublisher pub("Performance"); diff --git a/ecal/samples/cpp/benchmarks/latency_rec/src/latency_rec.cpp b/ecal/samples/cpp/benchmarks/latency_rec/src/latency_rec.cpp index 87a074cb01..a5c33af7d2 100644 --- a/ecal/samples/cpp/benchmarks/latency_rec/src/latency_rec.cpp +++ b/ecal/samples/cpp/benchmarks/latency_rec/src/latency_rec.cpp @@ -59,7 +59,7 @@ void on_receive(const struct eCAL::SReceiveCallbackData* data_, SCallbackPar* pa void do_run(int delay_, std::string& log_file_) { // initialize eCAL API - eCAL::Initialize(0, nullptr, "latency_rec"); + eCAL::Initialize("latency_rec"); // subscriber eCAL::CSubscriber sub("ping"); diff --git a/ecal/samples/cpp/benchmarks/latency_snd/src/latency_snd.cpp b/ecal/samples/cpp/benchmarks/latency_snd/src/latency_snd.cpp index d4822471ec..33f25c277e 100644 --- a/ecal/samples/cpp/benchmarks/latency_snd/src/latency_snd.cpp +++ b/ecal/samples/cpp/benchmarks/latency_snd/src/latency_snd.cpp @@ -47,7 +47,7 @@ void do_run(const int runs, int snd_size /*kB*/, int mem_buffer, bool zero_copy) } // initialize eCAL API - eCAL::Initialize(0, nullptr, "latency_snd"); + eCAL::Initialize("latency_snd"); // create publisher config eCAL::Publisher::Configuration pub_config; diff --git a/ecal/samples/cpp/benchmarks/many_connections_rec/src/many_connections_rec.cpp b/ecal/samples/cpp/benchmarks/many_connections_rec/src/many_connections_rec.cpp index 188badb2b2..fb8bf4105a 100644 --- a/ecal/samples/cpp/benchmarks/many_connections_rec/src/many_connections_rec.cpp +++ b/ecal/samples/cpp/benchmarks/many_connections_rec/src/many_connections_rec.cpp @@ -56,10 +56,10 @@ class SubscriberCreator }; -int main(int argc, char** argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "many_connections_rec"); + eCAL::Initialize("many_connections_rec"); // create many subscriber const SubscriberCreator subscribers(10000); diff --git a/ecal/samples/cpp/benchmarks/many_connections_snd/src/many_connections_snd.cpp b/ecal/samples/cpp/benchmarks/many_connections_snd/src/many_connections_snd.cpp index 623d8a4dbf..03470088e4 100644 --- a/ecal/samples/cpp/benchmarks/many_connections_snd/src/many_connections_snd.cpp +++ b/ecal/samples/cpp/benchmarks/many_connections_snd/src/many_connections_snd.cpp @@ -55,10 +55,10 @@ class PublisherCreator }; -int main(int argc, char** argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "many_connections_snd"); + eCAL::Initialize("many_connections_snd"); // create many publisher PublisherCreator publishers(10000); diff --git a/ecal/samples/cpp/benchmarks/massive_pub_sub/src/massive_pub_sub.cpp b/ecal/samples/cpp/benchmarks/massive_pub_sub/src/massive_pub_sub.cpp index dc2b46e6e4..61765cd85e 100644 --- a/ecal/samples/cpp/benchmarks/massive_pub_sub/src/massive_pub_sub.cpp +++ b/ecal/samples/cpp/benchmarks/massive_pub_sub/src/massive_pub_sub.cpp @@ -54,7 +54,7 @@ std::string GenerateSizedString(const std::string& name, size_t totalSize) return result; } -int main(int argc, char** argv) +int main() { // set eCAL configuration eCAL::Configuration configuration; @@ -187,7 +187,7 @@ int main(int argc, char** argv) num_pub = pub_ids.size(); for (const auto& id : pub_ids) { - eCAL::Registration::SQualityTopicInfo topic_info; + eCAL::SDataTypeInformation topic_info; eCAL::Registration::GetPublisherInfo(id, topic_info); } diff --git a/ecal/samples/cpp/benchmarks/multiple_rec/src/multiple_rec.cpp b/ecal/samples/cpp/benchmarks/multiple_rec/src/multiple_rec.cpp index e60c548cfb..444ab54167 100644 --- a/ecal/samples/cpp/benchmarks/multiple_rec/src/multiple_rec.cpp +++ b/ecal/samples/cpp/benchmarks/multiple_rec/src/multiple_rec.cpp @@ -57,10 +57,10 @@ void OnReceive(const char* topic_name_) g_overalll_read++; } -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "multiple_rec_cb"); + eCAL::Initialize("multiple_rec_cb"); // create dummy subscriber std::cout << "create subscribers .." << std::endl; diff --git a/ecal/samples/cpp/benchmarks/multiple_snd/src/multiple_snd.cpp b/ecal/samples/cpp/benchmarks/multiple_snd/src/multiple_snd.cpp index 95ef14fe66..4a33e06548 100644 --- a/ecal/samples/cpp/benchmarks/multiple_snd/src/multiple_snd.cpp +++ b/ecal/samples/cpp/benchmarks/multiple_snd/src/multiple_snd.cpp @@ -31,10 +31,10 @@ #define PRINT_LOG 0 #define PUBLISHER_NUMBER 200 -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "multiple_snd"); + eCAL::Initialize("multiple_snd"); // create publisher struct SPubCount diff --git a/ecal/samples/cpp/benchmarks/performance_rec/src/performance_rec.cpp b/ecal/samples/cpp/benchmarks/performance_rec/src/performance_rec.cpp index 00ada63324..e734b07109 100644 --- a/ecal/samples/cpp/benchmarks/performance_rec/src/performance_rec.cpp +++ b/ecal/samples/cpp/benchmarks/performance_rec/src/performance_rec.cpp @@ -48,10 +48,10 @@ void PrintStatistic(const std::string& topic_name_, const std::chrono::duration< } // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "performance_rec"); + eCAL::Initialize("performance_rec"); // create subscriber for topic "Performance" eCAL::CSubscriber sub("Performance"); diff --git a/ecal/samples/cpp/benchmarks/performance_snd/src/performance_snd.cpp b/ecal/samples/cpp/benchmarks/performance_snd/src/performance_snd.cpp index 3889442710..fdd392d0ad 100644 --- a/ecal/samples/cpp/benchmarks/performance_snd/src/performance_snd.cpp +++ b/ecal/samples/cpp/benchmarks/performance_snd/src/performance_snd.cpp @@ -40,7 +40,7 @@ int main(int argc, char **argv) if(payload_size < 1) payload_size = 1; // initialize eCAL API - eCAL::Initialize(argc, argv, "performance_snd"); + eCAL::Initialize("performance_snd"); // create payload CBinaryPayload binary_payload(payload_size); diff --git a/ecal/samples/cpp/benchmarks/perftool/src/main.cpp b/ecal/samples/cpp/benchmarks/perftool/src/main.cpp index de88ae405b..d17d2d2e4c 100644 --- a/ecal/samples/cpp/benchmarks/perftool/src/main.cpp +++ b/ecal/samples/cpp/benchmarks/perftool/src/main.cpp @@ -196,8 +196,7 @@ int main(int argc, char** argv) const unsigned long long payload_size_bytes = std::stoull(args[4]); // Initialize eCAL - eCAL::Initialize(argc, argv, "ecal-perftool"); - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("ecal-perftool"); const Publisher publisher(topic_name, frequency_hz, payload_size_bytes, quiet_arg, verbose_print_times); @@ -224,8 +223,7 @@ int main(int argc, char** argv) // Initialize eCAL - eCAL::Initialize(argc, argv, "ecal-perftool"); - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("ecal-perftool"); const Subscriber subscriber(topic_name, callback_delay, busy_wait_arg, hickup_arg, hickup_time, hickup_delay, quiet_arg, verbose_print_times); diff --git a/ecal/samples/cpp/benchmarks/pubsub_throughput/src/pubsub_throughput.cpp b/ecal/samples/cpp/benchmarks/pubsub_throughput/src/pubsub_throughput.cpp index 734b9ba051..4d5ab63208 100644 --- a/ecal/samples/cpp/benchmarks/pubsub_throughput/src/pubsub_throughput.cpp +++ b/ecal/samples/cpp/benchmarks/pubsub_throughput/src/pubsub_throughput.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +51,8 @@ void throughput_test(int snd_size, int snd_loops, eCAL::TLayer::eTransportLayer case eCAL::TLayer::tlayer_tcp: pub_config.layer.tcp.enable = true; break; + default: + break; } // enable zero copy mode @@ -106,13 +108,10 @@ void throughput_test(int snd_size, int snd_loops, eCAL::TLayer::eTransportLayer } // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "pubsub_throughput"); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("pubsub_throughput"); std::cout << "---------------------------" << '\n'; std::cout << "LAYER: SHM" << '\n'; diff --git a/ecal/samples/cpp/misc/config/src/config_sample.cpp b/ecal/samples/cpp/misc/config/src/config_sample.cpp index ebe041c551..e55a53447f 100644 --- a/ecal/samples/cpp/misc/config/src/config_sample.cpp +++ b/ecal/samples/cpp/misc/config/src/config_sample.cpp @@ -22,10 +22,10 @@ #include -int main(int argc, char **argv) +int main() { // creating config object - eCAL::Configuration my_config(argc, argv); + eCAL::Configuration my_config; // setting a configuration my_config.registration.network_enabled = true; diff --git a/ecal/samples/cpp/misc/process/src/process.cpp b/ecal/samples/cpp/misc/process/src/process.cpp index cfeb4f0681..78a1c88482 100644 --- a/ecal/samples/cpp/misc/process/src/process.cpp +++ b/ecal/samples/cpp/misc/process/src/process.cpp @@ -25,10 +25,10 @@ const char* proc_name = "notepad.exe"; const char* proc_name = "gedit"; #endif // ECAL_OS_WINDOWS -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "process", eCAL::Init::None); + eCAL::Initialize("process", eCAL::Init::None); // start process eCAL::Process::StartProcess(proc_name, "", "", false, proc_smode_normal, false); diff --git a/ecal/samples/cpp/misc/time/src/time.cpp b/ecal/samples/cpp/misc/time/src/time.cpp index e3b1d3cb31..2a85115aef 100644 --- a/ecal/samples/cpp/misc/time/src/time.cpp +++ b/ecal/samples/cpp/misc/time/src/time.cpp @@ -21,10 +21,10 @@ #include #include -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "timer"); + eCAL::Initialize("timer"); std::cout << "eCAL Time Interface : " << eCAL::Time::GetName() << std::endl; std::cout << "eCAL Time is Synchronized : " << eCAL::Time::IsSynchronized() << std::endl; diff --git a/ecal/samples/cpp/misc/timer/src/timer.cpp b/ecal/samples/cpp/misc/timer/src/timer.cpp index e7a385b589..242574a568 100644 --- a/ecal/samples/cpp/misc/timer/src/timer.cpp +++ b/ecal/samples/cpp/misc/timer/src/timer.cpp @@ -25,10 +25,10 @@ const int timout_ms = 10; -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "person publisher"); + eCAL::Initialize("person publisher"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/ecal/samples/cpp/monitoring/monitoring_get_services/src/monitoring_get_services.cpp b/ecal/samples/cpp/monitoring/monitoring_get_services/src/monitoring_get_services.cpp index 0d52b41719..5f619bc697 100644 --- a/ecal/samples/cpp/monitoring/monitoring_get_services/src/monitoring_get_services.cpp +++ b/ecal/samples/cpp/monitoring/monitoring_get_services/src/monitoring_get_services.cpp @@ -25,28 +25,30 @@ #include #include -int main(int argc, char **argv) +int main() { int run(0), runs(1000); std::chrono::steady_clock::time_point start_time; // initialize eCAL core API - eCAL::Initialize(argc, argv, "monitoring get services"); + eCAL::Initialize("monitoring get services"); // monitor for ever while(eCAL::Ok()) { // GetServices { + std::set service_method_id_set; + std::map service_info_map; start_time = std::chrono::steady_clock::now(); for (run = 0; run < runs; ++run) { - eCAL::Registration::GetServices(service_info_map); + service_method_id_set = eCAL::Registration::GetServiceIDs(); } - auto num_services = service_info_map.size(); + auto num_services = service_method_id_set.size(); auto diff_time = std::chrono::duration_cast(std::chrono::steady_clock::now() - start_time); std::cout << "GetServices : " << static_cast(diff_time.count()) / runs << " ms" << " (" << num_services << " services)" << std::endl; std::cout << std::endl; diff --git a/ecal/samples/cpp/monitoring/monitoring_get_topics/src/monitoring_get_topics.cpp b/ecal/samples/cpp/monitoring/monitoring_get_topics/src/monitoring_get_topics.cpp index e1d1fb0a11..eecef464e5 100644 --- a/ecal/samples/cpp/monitoring/monitoring_get_topics/src/monitoring_get_topics.cpp +++ b/ecal/samples/cpp/monitoring/monitoring_get_topics/src/monitoring_get_topics.cpp @@ -25,28 +25,30 @@ #include #include -int main(int argc, char **argv) +int main() { int run(0), runs(10); std::chrono::steady_clock::time_point start_time; // initialize eCAL core API - eCAL::Initialize(argc, argv, "monitoring get topics"); + eCAL::Initialize("monitoring get topics"); // monitor for ever while(eCAL::Ok()) { // GetTopics { - std::map topic_info_map; + std::set topic_id_pub_set; + std::set topic_id_sub_set; start_time = std::chrono::steady_clock::now(); for (run = 0; run < runs; ++run) { - eCAL::Registration::GetTopics(topic_info_map); + topic_id_pub_set = eCAL::Registration::GetPublisherIDs(); + topic_id_sub_set = eCAL::Registration::GetSubscriberIDs(); } - auto num_topics = topic_info_map.size(); + auto num_topics = topic_id_pub_set.size() + topic_id_sub_set.size(); auto diff_time = std::chrono::duration_cast(std::chrono::steady_clock::now() - start_time); std::cout << "GetTopics : " << static_cast(diff_time.count()) / runs << " ms" << " (" << num_topics << " topics)" << std::endl; } diff --git a/ecal/samples/cpp/monitoring/monitoring_performance/src/monitoring_performance.cpp b/ecal/samples/cpp/monitoring/monitoring_performance/src/monitoring_performance.cpp index 7a6aefcf90..fba9e39a45 100644 --- a/ecal/samples/cpp/monitoring/monitoring_performance/src/monitoring_performance.cpp +++ b/ecal/samples/cpp/monitoring/monitoring_performance/src/monitoring_performance.cpp @@ -34,10 +34,10 @@ #define MEASURE_VARIANT_STRING 1 #define MEASURE_VARIANT_STRUCT 1 -int main(int argc, char **argv) +int main() { // initialize eCAL core API - eCAL::Initialize(argc, argv, "monitoring performance", eCAL::Init::All); + eCAL::Initialize("monitoring performance", eCAL::Init::All); int runs(100); int run(0); diff --git a/ecal/samples/cpp/monitoring/monitoring_rec/src/monitoring_rec.cpp b/ecal/samples/cpp/monitoring/monitoring_rec/src/monitoring_rec.cpp index b8bde04b0f..fdb1c7bc62 100644 --- a/ecal/samples/cpp/monitoring/monitoring_rec/src/monitoring_rec.cpp +++ b/ecal/samples/cpp/monitoring/monitoring_rec/src/monitoring_rec.cpp @@ -42,10 +42,10 @@ namespace std::string g_services_filt_string = ""; // specify service name to monitor ("" == all services) } -int main(int argc, char** argv) +int main() { // initialize eCAL core API - eCAL::Initialize(argc, argv, "monitoring", eCAL::Init::All); + eCAL::Initialize("monitoring", eCAL::Init::All); // monitoring instance to store snapshot eCAL::pb::Monitoring monitoring; diff --git a/ecal/samples/cpp/monitoring/monitoring_reg/src/monitoring_reg.cpp b/ecal/samples/cpp/monitoring/monitoring_reg/src/monitoring_reg.cpp index adc8a7f79b..5504aa6004 100644 --- a/ecal/samples/cpp/monitoring/monitoring_reg/src/monitoring_reg.cpp +++ b/ecal/samples/cpp/monitoring/monitoring_reg/src/monitoring_reg.cpp @@ -99,10 +99,10 @@ void OnPublisherRegistration(const char* sample_, int sample_size_) } } -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "monitoring registrations", eCAL::Init::None); + eCAL::Initialize("monitoring registrations", eCAL::Init::None); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/ecal/samples/cpp/orchestration/component1/src/component1.cpp b/ecal/samples/cpp/orchestration/component1/src/component1.cpp index 26285ea2b1..6e1f779d26 100644 --- a/ecal/samples/cpp/orchestration/component1/src/component1.cpp +++ b/ecal/samples/cpp/orchestration/component1/src/component1.cpp @@ -69,11 +69,11 @@ class ComponentServiceImpl final : public orchestrator::ComponentService eCAL::protobuf::CPublisher publisher_vec; }; -int main(int argc, char** argv) +int main() { // initialize eCAL API const std::string component("component1"); - eCAL::Initialize(argc, argv, component.c_str()); + eCAL::Initialize(component); // start the component service std::shared_ptr component_service_impl = std::make_shared(); diff --git a/ecal/samples/cpp/orchestration/component2/src/component2.cpp b/ecal/samples/cpp/orchestration/component2/src/component2.cpp index 90990c43ce..dd7d20095f 100644 --- a/ecal/samples/cpp/orchestration/component2/src/component2.cpp +++ b/ecal/samples/cpp/orchestration/component2/src/component2.cpp @@ -90,11 +90,11 @@ class ComponentServiceImpl final : public orchestrator::ComponentService int err_cnt = 0; }; -int main(int argc, char** argv) +int main() { // initialize eCAL API const std::string component("component2"); - eCAL::Initialize(argc, argv, component.c_str()); + eCAL::Initialize(component); // start the component service std::shared_ptr component_service_impl = std::make_shared(); diff --git a/ecal/samples/cpp/orchestration/orchestrator/src/orchestrator.cpp b/ecal/samples/cpp/orchestration/orchestrator/src/orchestrator.cpp index 8240e184d2..b3123f1f23 100644 --- a/ecal/samples/cpp/orchestration/orchestrator/src/orchestrator.cpp +++ b/ecal/samples/cpp/orchestration/orchestrator/src/orchestrator.cpp @@ -24,10 +24,10 @@ #include -int main(int argc, char** argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "orchestrator"); + eCAL::Initialize("orchestrator"); eCAL::protobuf::CServiceClient component1("component1"); eCAL::protobuf::CServiceClient component2("component2"); diff --git a/ecal/samples/cpp/pubsub/binary/binary_rec/src/binary_rec.cpp b/ecal/samples/cpp/pubsub/binary/binary_rec/src/binary_rec.cpp index f5653c1776..70ada568cf 100644 --- a/ecal/samples/cpp/pubsub/binary/binary_rec/src/binary_rec.cpp +++ b/ecal/samples/cpp/pubsub/binary/binary_rec/src/binary_rec.cpp @@ -40,10 +40,10 @@ void OnReceive(const char* /*topic_name_*/, const struct eCAL::SReceiveCallbackD std::cout << std::endl; } -int main(int argc, char** argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "binary_rec"); + eCAL::Initialize("binary_rec"); // subscriber for topic "blob" eCAL::CSubscriber sub("blob"); diff --git a/ecal/samples/cpp/pubsub/binary/binary_snd/src/binary_snd.cpp b/ecal/samples/cpp/pubsub/binary/binary_snd/src/binary_snd.cpp index da9b49d4af..af9bcb57c9 100644 --- a/ecal/samples/cpp/pubsub/binary/binary_snd/src/binary_snd.cpp +++ b/ecal/samples/cpp/pubsub/binary/binary_snd/src/binary_snd.cpp @@ -22,10 +22,10 @@ #include #include -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "binary_snd"); + eCAL::Initialize("binary_snd"); // publisher for topic "blob" eCAL::CPublisher pub("blob"); diff --git a/ecal/samples/cpp/pubsub/binary/binary_zero_copy_rec/src/binary_zero_copy_rec.cpp b/ecal/samples/cpp/pubsub/binary/binary_zero_copy_rec/src/binary_zero_copy_rec.cpp index 33436914b7..8ffe03eb43 100644 --- a/ecal/samples/cpp/pubsub/binary/binary_zero_copy_rec/src/binary_zero_copy_rec.cpp +++ b/ecal/samples/cpp/pubsub/binary/binary_zero_copy_rec/src/binary_zero_copy_rec.cpp @@ -72,13 +72,13 @@ void OnReceive(const char* /*topic_name_*/, const struct eCAL::SReceiveCallbackD std::cout << *static_cast(data_->buf) << std::endl; } -int main(int argc, char** argv) +int main() { const char* nodeName = "binary_zero_copy_rec"; const char* topicName = "simple_struct"; // initialize eCAL API - eCAL::Initialize(argc, argv, nodeName); + eCAL::Initialize(nodeName); // create the subscriber eCAL::CSubscriber sub(topicName); diff --git a/ecal/samples/cpp/pubsub/binary/binary_zero_copy_snd/src/binary_zero_copy_snd.cpp b/ecal/samples/cpp/pubsub/binary/binary_zero_copy_snd/src/binary_zero_copy_snd.cpp index 065353cd1c..dfac65c5eb 100644 --- a/ecal/samples/cpp/pubsub/binary/binary_zero_copy_snd/src/binary_zero_copy_snd.cpp +++ b/ecal/samples/cpp/pubsub/binary/binary_zero_copy_snd/src/binary_zero_copy_snd.cpp @@ -114,14 +114,14 @@ class CStructPayload : public eCAL::CPayloadWriter uint32_t clock = 0; }; -int main(int argc, char** argv) +int main() { const char* nodeName = "binary_zero_copy_snd"; const char* topicName = "simple_struct"; const char* structTypeName = "SSimpleStruct"; // initialize eCAL API - eCAL::Initialize(argc, argv, nodeName); + eCAL::Initialize(nodeName); // create publisher config eCAL::Publisher::Configuration pub_config; diff --git a/ecal/samples/cpp/pubsub/binary/ping/src/ping.cpp b/ecal/samples/cpp/pubsub/binary/ping/src/ping.cpp index 90a931d9b7..de58733d6d 100644 --- a/ecal/samples/cpp/pubsub/binary/ping/src/ping.cpp +++ b/ecal/samples/cpp/pubsub/binary/ping/src/ping.cpp @@ -24,10 +24,10 @@ const int pings = 10000; long long diff_array[pings] = { 0 }; -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "ping"); + eCAL::Initialize("ping"); eCAL::SDataTypeInformation topic_info{ "long long", "", "" }; eCAL::CPublisher pub_pulse("pulse_send", topic_info); diff --git a/ecal/samples/cpp/pubsub/binary/pong/src/pong.cpp b/ecal/samples/cpp/pubsub/binary/pong/src/pong.cpp index 31503963d3..b87162d810 100644 --- a/ecal/samples/cpp/pubsub/binary/pong/src/pong.cpp +++ b/ecal/samples/cpp/pubsub/binary/pong/src/pong.cpp @@ -21,10 +21,10 @@ #include -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "pong"); + eCAL::Initialize("pong"); eCAL::SDataTypeInformation topic_info{ "long long", "", "" }; eCAL::CSubscriber sub_pulse("pulse_send", topic_info); diff --git a/ecal/samples/cpp/pubsub/protobuf/person_events_rec/src/person_events_rec.cpp b/ecal/samples/cpp/pubsub/protobuf/person_events_rec/src/person_events_rec.cpp index 3d705a1778..48dc957adb 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_events_rec/src/person_events_rec.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/person_events_rec/src/person_events_rec.cpp @@ -56,10 +56,10 @@ void OnEvent(const char* topic_name_, const struct eCAL::SSubEventCallbackData* std::cout << std::endl; } -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "person subscriber events"); + eCAL::Initialize("person subscriber events"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/ecal/samples/cpp/pubsub/protobuf/person_events_snd/src/person_events_snd.cpp b/ecal/samples/cpp/pubsub/protobuf/person_events_snd/src/person_events_snd.cpp index 80ccb3c2f6..953eb1a4b6 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_events_snd/src/person_events_snd.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/person_events_snd/src/person_events_snd.cpp @@ -53,10 +53,10 @@ void OnEvent(const char* topic_name_, const struct eCAL::SPubEventCallbackData* std::cout << std::endl; } -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "person publisher events"); + eCAL::Initialize("person publisher events"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/ecal/samples/cpp/pubsub/protobuf/person_loopback/src/person_loopback.cpp b/ecal/samples/cpp/pubsub/protobuf/person_loopback/src/person_loopback.cpp index afbcc2b45d..38680aea6e 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_loopback/src/person_loopback.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/person_loopback/src/person_loopback.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,17 +25,14 @@ #include "person.pb.h" -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "person publisher"); + eCAL::Initialize("person publisher"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); - // enable to receive our own messages - eCAL::Util::EnableLoopback(true); - // create a publisher (topic name "person") eCAL::protobuf::CPublisher pub("person"); @@ -43,7 +40,7 @@ int main(int argc, char **argv) pb::People::Person person; eCAL::protobuf::CSubscriber sub("person"); - auto receive_lambda = [&sub](const char* /*topic_name_*/, const pb::People::Person& person_, const long long /*time_*/, const long long /*clock_*/, const long long /*id_*/){ + auto receive_lambda = [](const char* /*topic_name_*/, const pb::People::Person& person_, const long long /*time_*/, const long long /*clock_*/, const long long /*id_*/){ std::cout << "------------------------------------------" << std::endl; std::cout << " RECEIVED " << std::endl; std::cout << "------------------------------------------" << std::endl; diff --git a/ecal/samples/cpp/pubsub/protobuf/person_rec/src/person_rec.cpp b/ecal/samples/cpp/pubsub/protobuf/person_rec/src/person_rec.cpp index 63a80c26a6..9abb00d137 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_rec/src/person_rec.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/person_rec/src/person_rec.cpp @@ -45,10 +45,10 @@ void OnPerson(const char* topic_name_, const pb::People::Person& person_, const std::cout << std::endl; } -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "person subscriber"); + eCAL::Initialize("person subscriber"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/ecal/samples/cpp/pubsub/protobuf/person_snd/src/person_snd.cpp b/ecal/samples/cpp/pubsub/protobuf/person_snd/src/person_snd.cpp index ae57c0b723..093e171cda 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_snd/src/person_snd.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/person_snd/src/person_snd.cpp @@ -24,10 +24,10 @@ #include "person.pb.h" -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "person publisher"); + eCAL::Initialize("person publisher"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/ecal/samples/cpp/pubsub/protobuf/person_snd_tcp/src/person_snd_tcp.cpp b/ecal/samples/cpp/pubsub/protobuf/person_snd_tcp/src/person_snd_tcp.cpp index b7feae04aa..7e10d90f8a 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_snd_tcp/src/person_snd_tcp.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/person_snd_tcp/src/person_snd_tcp.cpp @@ -24,10 +24,10 @@ #include "person.pb.h" -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "person publisher tcp"); + eCAL::Initialize("person publisher tcp"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/ecal/samples/cpp/pubsub/protobuf/person_snd_udp/src/person_snd_udp.cpp b/ecal/samples/cpp/pubsub/protobuf/person_snd_udp/src/person_snd_udp.cpp index e5a8d1f786..a1004ca69e 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_snd_udp/src/person_snd_udp.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/person_snd_udp/src/person_snd_udp.cpp @@ -24,10 +24,10 @@ #include "person.pb.h" -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "person publisher multicast"); + eCAL::Initialize("person publisher multicast"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/src/proto_dyn_json_rec.cpp b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/src/proto_dyn_json_rec.cpp index 795890c04e..676f021280 100644 --- a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/src/proto_dyn_json_rec.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/src/proto_dyn_json_rec.cpp @@ -25,20 +25,20 @@ const std::string MESSAGE_NAME("person"); -void ProtoMsgCallback(const char* topic_name_, const std::string& msg_, long long /*time_*/, long long /*clock_*/, long long /*id_*/) +void ProtoMsgCallback(const eCAL::Registration::STopicId& topic_id_, const std::string& msg_) { - std::cout << topic_name_ << " : " << msg_ << std::endl; + std::cout << topic_id_.topic_name << " : " << msg_ << std::endl; std::cout << std::endl; } -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "proto_dyn"); + eCAL::Initialize("proto_dyn"); // create dynamic subscribers for receiving and decoding messages eCAL::protobuf::CDynamicJSONSubscriber sub(MESSAGE_NAME); - sub.AddReceiveCallback(ProtoMsgCallback); + sub.AddReceiveCallback(std::bind(ProtoMsgCallback, std::placeholders::_1, std::placeholders::_2)); // enter main loop while(eCAL::Ok()) diff --git a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/src/proto_dyn_rec.cpp b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/src/proto_dyn_rec.cpp index c5ba31e7d6..e7f3ba4214 100644 --- a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/src/proto_dyn_rec.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/src/proto_dyn_rec.cpp @@ -270,16 +270,16 @@ void ProcProtoMsg(const google::protobuf::Message& msg_, const std::string& pref } } -void ProtoMsgCallback(const char* topic_name_, const std::shared_ptr& msg_) +void ProtoMsgCallback(const eCAL::Registration::STopicId& topic_id_, const std::shared_ptr& msg_) { - ProcProtoMsg(*msg_, topic_name_); + ProcProtoMsg(*msg_, topic_id_.topic_name); std::cout << std::endl; } -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "proto_dyn"); + eCAL::Initialize("proto_dyn"); // create dynamic subscribers for receiving and decoding messages eCAL::protobuf::CDynamicSubscriber sub(MESSAGE_NAME); diff --git a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_snd/src/proto_dyn_snd.cpp b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_snd/src/proto_dyn_snd.cpp index 3604a8d0a8..6b9c243319 100644 --- a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_snd/src/proto_dyn_snd.cpp +++ b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_snd/src/proto_dyn_snd.cpp @@ -24,10 +24,10 @@ #include "person.pb.h" -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "person publisher dynamic"); + eCAL::Initialize("person publisher dynamic"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/ecal/samples/cpp/pubsub/string/minimal_rec/src/minimal_rec.cpp b/ecal/samples/cpp/pubsub/string/minimal_rec/src/minimal_rec.cpp index 95fbdc4a53..288cc3a215 100644 --- a/ecal/samples/cpp/pubsub/string/minimal_rec/src/minimal_rec.cpp +++ b/ecal/samples/cpp/pubsub/string/minimal_rec/src/minimal_rec.cpp @@ -23,14 +23,14 @@ #include #include -int main(int argc, char **argv) +int main() { std::cout << "-------------------------------" << std::endl; std::cout << " HELLO WORLD RECEIVER" << std::endl; std::cout << "-------------------------------" << std::endl; // initialize eCAL API - eCAL::Initialize(argc, argv, "minimal_rec"); + eCAL::Initialize("minimal_rec"); // subscriber for topic "Hello" eCAL::string::CSubscriber sub("Hello"); diff --git a/ecal/samples/cpp/pubsub/string/minimal_rec_cb/src/minimal_rec_cb.cpp b/ecal/samples/cpp/pubsub/string/minimal_rec_cb/src/minimal_rec_cb.cpp index 55403240d5..678281c611 100644 --- a/ecal/samples/cpp/pubsub/string/minimal_rec_cb/src/minimal_rec_cb.cpp +++ b/ecal/samples/cpp/pubsub/string/minimal_rec_cb/src/minimal_rec_cb.cpp @@ -25,14 +25,14 @@ #include #include -int main(int argc, char** argv) +int main() { std::cout << "-------------------------------" << std::endl; std::cout << " HELLO WORLD RECEIVER" << std::endl; std::cout << "-------------------------------" << std::endl; // initialize eCAL API - eCAL::Initialize(argc, argv, "minimal_rec_cb"); + eCAL::Initialize("minimal_rec_cb"); // subscriber for topic "Hello" eCAL::string::CSubscriber sub("Hello"); diff --git a/ecal/samples/cpp/pubsub/string/minimal_snd/src/minimal_snd.cpp b/ecal/samples/cpp/pubsub/string/minimal_snd/src/minimal_snd.cpp index 85889a61c1..335464e05b 100644 --- a/ecal/samples/cpp/pubsub/string/minimal_snd/src/minimal_snd.cpp +++ b/ecal/samples/cpp/pubsub/string/minimal_snd/src/minimal_snd.cpp @@ -23,14 +23,14 @@ #include #include -int main(int argc, char **argv) +int main() { std::cout << "-------------------------------" << std::endl; std::cout << " HELLO WORLD SENDER" << std::endl; std::cout << "-------------------------------" << std::endl; // initialize eCAL API - eCAL::Initialize(argc, argv, "minimal_snd"); + eCAL::Initialize("minimal_snd"); // publisher for topic "Hello" eCAL::string::CPublisher pub("Hello"); diff --git a/ecal/samples/cpp/services/latency_client/src/latency_client.cpp b/ecal/samples/cpp/services/latency_client/src/latency_client.cpp index a6f1e85c49..6b007d3369 100644 --- a/ecal/samples/cpp/services/latency_client/src/latency_client.cpp +++ b/ecal/samples/cpp/services/latency_client/src/latency_client.cpp @@ -28,10 +28,10 @@ #include // main entry -int main(int argc, char** argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "latency client"); + eCAL::Initialize("latency client"); // create latency client eCAL::v5::CServiceClient latency_client("latency"); diff --git a/ecal/samples/cpp/services/latency_server/src/latency_server.cpp b/ecal/samples/cpp/services/latency_server/src/latency_server.cpp index 12913af568..26c4e4a6ae 100644 --- a/ecal/samples/cpp/services/latency_server/src/latency_server.cpp +++ b/ecal/samples/cpp/services/latency_server/src/latency_server.cpp @@ -28,10 +28,10 @@ int OnHello(const std::string& /*method_*/, const std::string& /*req_type_*/, co } // main entry -int main(int argc, char** argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "latency server"); + eCAL::Initialize("latency server"); // create latency service eCAL::CServiceServer latency_service("latency"); diff --git a/ecal/samples/cpp/services/math_client/src/math_client.cpp b/ecal/samples/cpp/services/math_client/src/math_client.cpp index e54921c4df..7789ce1242 100644 --- a/ecal/samples/cpp/services/math_client/src/math_client.cpp +++ b/ecal/samples/cpp/services/math_client/src/math_client.cpp @@ -84,10 +84,10 @@ void OnMathResponse(const struct eCAL::SServiceResponse& service_response_) } // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "math client"); + eCAL::Initialize("math client"); // create math service client eCAL::protobuf::CServiceClient math_client; diff --git a/ecal/samples/cpp/services/math_server/src/math_server.cpp b/ecal/samples/cpp/services/math_server/src/math_server.cpp index cda95b44d2..758f54f263 100644 --- a/ecal/samples/cpp/services/math_server/src/math_server.cpp +++ b/ecal/samples/cpp/services/math_server/src/math_server.cpp @@ -85,10 +85,10 @@ void OnServerEvent(const eCAL::SServerEventCallbackData* data_) } // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "math server"); + eCAL::Initialize("math server"); // create Math service server std::shared_ptr math_service = std::make_shared(); diff --git a/ecal/samples/cpp/services/minimal_client/src/minimal_client.cpp b/ecal/samples/cpp/services/minimal_client/src/minimal_client.cpp index da52d91d98..7a65d595fe 100644 --- a/ecal/samples/cpp/services/minimal_client/src/minimal_client.cpp +++ b/ecal/samples/cpp/services/minimal_client/src/minimal_client.cpp @@ -24,10 +24,10 @@ #include // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "minimal client"); + eCAL::Initialize("minimal client"); // create minimal service client const eCAL::CServiceClient minimal_client("service1", { {"echo", eCAL::SServiceMethodInformation()} }); diff --git a/ecal/samples/cpp/services/minimal_server/src/minimal_server.cpp b/ecal/samples/cpp/services/minimal_server/src/minimal_server.cpp index 76ea9c5875..31c2f4ee92 100644 --- a/ecal/samples/cpp/services/minimal_server/src/minimal_server.cpp +++ b/ecal/samples/cpp/services/minimal_server/src/minimal_server.cpp @@ -33,10 +33,10 @@ int OnMethodCallback(const std::string& method_, const std::string& /*req_type_* } // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "minimal server"); + eCAL::Initialize("minimal server"); // create minimal service server eCAL::CServiceServer minimal_server("service1"); diff --git a/ecal/samples/cpp/services/ping_client/src/ping_client.cpp b/ecal/samples/cpp/services/ping_client/src/ping_client.cpp index e2022da6cb..5668075c9b 100644 --- a/ecal/samples/cpp/services/ping_client/src/ping_client.cpp +++ b/ecal/samples/cpp/services/ping_client/src/ping_client.cpp @@ -27,10 +27,10 @@ #include "ping.pb.h" // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "ping client"); + eCAL::Initialize("ping client"); // create ping service client eCAL::protobuf::CServiceClient ping_client("ping service"); diff --git a/ecal/samples/cpp/services/ping_client_dyn/src/ping_client_dyn.cpp b/ecal/samples/cpp/services/ping_client_dyn/src/ping_client_dyn.cpp index 622a839bfe..12dbdb0cd8 100644 --- a/ecal/samples/cpp/services/ping_client_dyn/src/ping_client_dyn.cpp +++ b/ecal/samples/cpp/services/ping_client_dyn/src/ping_client_dyn.cpp @@ -30,10 +30,10 @@ #include "proto_json_conv.h" // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "ping client dynamic"); + eCAL::Initialize("ping client dynamic"); // create ping service client const std::string service_name("ping service"); @@ -49,18 +49,28 @@ int main(int argc, char **argv) // get service method type names std::string req_type; + std::string req_desc; std::string resp_type; - if (!eCAL::Registration::GetServiceTypeNames(service_name, method_name, req_type, resp_type)) + std::string resp_desc; + auto service_ids = eCAL::Registration::GetServiceIDs(); + bool service_info_found(false); + for (const auto& service_id : service_ids) { - throw std::runtime_error("Could not get service type names !"); + if ((service_id.service_name == service_name) && (service_id.method_name == method_name)) + { + eCAL::SServiceMethodInformation service_method_info; + eCAL::Registration::GetServiceInfo(service_id, service_method_info); + req_type = service_method_info.request_type.name; + req_desc = service_method_info.request_type.descriptor; + resp_type = service_method_info.response_type.name; + resp_desc = service_method_info.response_type.descriptor; + service_info_found = true; + break; + } } - - // get service method type descriptions - std::string req_desc; - std::string resp_desc; - if (!eCAL::Registration::GetServiceDescription(service_name, method_name, req_desc, resp_desc)) + if (!service_info_found) { - throw std::runtime_error("Could not get service type descriptions !"); + throw std::runtime_error("Could not get service type names and service type descriptions!"); } // create dynamic protobuf message decoder to create request and response message objects diff --git a/ecal/samples/cpp/services/ping_server/src/ping_server.cpp b/ecal/samples/cpp/services/ping_server/src/ping_server.cpp index 1973d57dc2..62b5a24dbb 100644 --- a/ecal/samples/cpp/services/ping_server/src/ping_server.cpp +++ b/ecal/samples/cpp/services/ping_server/src/ping_server.cpp @@ -42,10 +42,10 @@ class PingServiceImpl : public PingService }; // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "ping server"); + eCAL::Initialize("ping server"); // create Ping service server std::shared_ptr ping_service = std::make_shared(); diff --git a/ecal/tests/c/core_test/src/core_test.cpp b/ecal/tests/c/core_test/src/core_test.cpp index 5f04527770..208389d38f 100644 --- a/ecal/tests/c/core_test/src/core_test.cpp +++ b/ecal/tests/c/core_test/src/core_test.cpp @@ -34,40 +34,36 @@ TEST(core_c_core, GetVersion) EXPECT_STREQ(ECAL_DATE, eCAL_GetVersionDateString()); // get eCAL version as separated integer values - int major = -1; - int minor = -1; - int patch = -1; - eCAL_GetVersion(&major, &minor, &patch); - EXPECT_EQ(ECAL_VERSION_MAJOR, major); - EXPECT_EQ(ECAL_VERSION_MINOR, minor); - EXPECT_EQ(ECAL_VERSION_PATCH, patch); + EXPECT_EQ(ECAL_VERSION_MAJOR, eCAL_GetVersion().major); + EXPECT_EQ(ECAL_VERSION_MINOR, eCAL_GetVersion().minor); + EXPECT_EQ(ECAL_VERSION_PATCH, eCAL_GetVersion().patch); } TEST(core_c_core, InitializeFinalize) { // Is eCAL API initialized ? - EXPECT_EQ(0, eCAL_IsInitialized(0)); + EXPECT_EQ(0, eCAL_IsInitialized()); // initialize eCAL API - EXPECT_EQ(0, eCAL_Initialize(0, nullptr, "initialize_test", 0)); + EXPECT_EQ(0, eCAL_Initialize("initialize_test", 0)); // Is eCAL API initialized ? - EXPECT_EQ(1, eCAL_IsInitialized(0)); + EXPECT_EQ(1, eCAL_IsInitialized()); // initialize eCAL API again we expect return value 1 for yet initialized - EXPECT_EQ(1, eCAL_Initialize(0, nullptr, "initialize_test", 0)); + EXPECT_EQ(1, eCAL_Initialize("initialize_test", 0)); // finalize eCAL API we expect return value 0 even it will not be really finalized because it's 2 times initialzed and 1 time finalized EXPECT_EQ(0, eCAL_Finalize()); // Is eCAL API initialized ? yes it' still initialized - EXPECT_EQ(1, eCAL_IsInitialized(0)); + EXPECT_EQ(1, eCAL_IsInitialized()); // finalize eCAL API we expect return value 0 because now it will be finalized EXPECT_EQ(0, eCAL_Finalize()); // Is eCAL API initialized ? no - EXPECT_EQ(0, eCAL_IsInitialized(0)); + EXPECT_EQ(0, eCAL_IsInitialized()); // finalize eCAL API we expect return value 1 because it was finalized before EXPECT_EQ(1, eCAL_Finalize()); @@ -79,7 +75,7 @@ TEST(core_c_core, MultipleInitializeFinalize) for (auto i = 0; i < 4; ++i) { // initialize eCAL API - EXPECT_EQ(0, eCAL_Initialize(0, nullptr, "multiple_initialize_finalize_test", 0)); + EXPECT_EQ(0, eCAL_Initialize("multiple_initialize_finalize_test", 0)); // finalize eCAL API EXPECT_EQ(0, eCAL_Finalize()); @@ -116,10 +112,10 @@ namespace TEST(core_c_core, SetGetUnitName) { // initialize eCAL API with empty unit name (eCAL will use process name as unit name) - EXPECT_EQ(0, eCAL_Initialize(0, nullptr, "", 0)); + EXPECT_EQ(0, eCAL_Initialize("", 0)); // Is eCAL API initialized ? - EXPECT_EQ(1, eCAL_IsInitialized(0)); + EXPECT_EQ(1, eCAL_IsInitialized()); // if we call eCAL_Initialize with empty unit name, eCAL will use the process name as unit name char process_name[1024] = { 0 }; @@ -157,7 +153,7 @@ TEST(core_c_core, eCAL_Ok) EXPECT_EQ(0, eCAL_Ok()); // initialize eCAL API - EXPECT_EQ(0, eCAL_Initialize(0, nullptr, "okay_test", 0)); + EXPECT_EQ(0, eCAL_Initialize("okay_test", 0)); // check initialized eCAL, should be okay EXPECT_EQ(1, eCAL_Ok()); diff --git a/ecal/tests/cpp/clientserver_proto_test/src/clientserver_test_proto.cpp b/ecal/tests/cpp/clientserver_proto_test/src/clientserver_test_proto.cpp index d6c702419f..8deab5419a 100644 --- a/ecal/tests/cpp/clientserver_proto_test/src/clientserver_test_proto.cpp +++ b/ecal/tests/cpp/clientserver_proto_test/src/clientserver_test_proto.cpp @@ -25,6 +25,8 @@ #include #include +#include +#include #include "math.pb.h" #include "ping.pb.h" @@ -69,10 +71,7 @@ class MathServiceImpl : public MathService TEST(core_cpp_clientserver_proto, ProtoCallback) { // initialize eCAL API - eCAL::Initialize(0, nullptr, "clientserver proto callback test"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("clientserver proto callback test"); // create MathService server std::shared_ptr math_service_impl = std::make_shared(); @@ -161,10 +160,7 @@ class PingServiceImpl : public PingService TEST(core_cpp_clientserver_proto, ProtoBlocking) { // initialize eCAL API - eCAL::Initialize(0, nullptr, "clientserver proto blocking test"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("clientserver proto blocking test"); // create PingService server std::shared_ptr ping_service_impl = std::make_shared(); diff --git a/ecal/tests/cpp/clientserver_test/src/atomic_signalable.h b/ecal/tests/cpp/clientserver_test/src/atomic_signalable.h index 4ce17e6bd6..faa1b76e0d 100644 --- a/ecal/tests/cpp/clientserver_test/src/atomic_signalable.h +++ b/ecal/tests/cpp/clientserver_test/src/atomic_signalable.h @@ -17,7 +17,6 @@ * ========================= eCAL LICENSE ================================= */ -#include #include #include #include diff --git a/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp b/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp index 7f240ee4da..544ea3ee18 100644 --- a/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp +++ b/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp @@ -17,12 +17,17 @@ * ========================= eCAL LICENSE ================================= */ +#include +#include #include -#include +#include #include #include +#include +#include +#include #include "atomic_signalable.h" @@ -105,10 +110,7 @@ namespace TEST(core_cpp_clientserver, ClientConnectEvent) { // initialize eCAL API - eCAL::Initialize(0, nullptr, "clientserver base connect event callback"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("clientserver base connect event callback"); // client event callback for connect events atomic_signalable event_connected_fired (0); @@ -173,10 +175,7 @@ TEST(core_cpp_clientserver, ClientConnectEvent) TEST(core_cpp_clientserver, ServerConnectEvent) { // initialize eCAL API - eCAL::Initialize(0, nullptr, "clientserver base connect event callback"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("clientserver base connect event callback"); // create server eCAL::CServiceServer server("service"); @@ -258,10 +257,7 @@ TEST(core_cpp_clientserver, ClientServerBaseCallback) const int calls(5); // initialize eCAL API - eCAL::Initialize(0, nullptr, "clientserver base callback test"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("clientserver base callback test"); // create service servers ServiceVecT service_vec; @@ -364,10 +360,7 @@ TEST(core_cpp_clientserver, ClientServerBaseCallbackTimeout) const int calls(1); // initialize eCAL API - eCAL::Initialize(0, nullptr, "clientserver base callback test with timeout"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("clientserver base callback test with timeout"); // create service servers ServiceVecT service_vec; @@ -526,10 +519,7 @@ TEST(core_cpp_clientserver, ClientServerBaseAsyncCallback) const int sleep(100); // initialize eCAL API - eCAL::Initialize(0, nullptr, "clientserver base async callback test"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("clientserver base async callback test"); // create service server eCAL::CServiceServer server("service"); @@ -599,10 +589,7 @@ TEST(core_cpp_clientserver, ClientServerBaseAsync) const int calls(5); // initialize eCAL API - eCAL::Initialize(0, nullptr, "clientserver base async callback test with timeout"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("clientserver base async callback test with timeout"); // create service server eCAL::CServiceServer server("service"); @@ -708,10 +695,7 @@ TEST(core_cpp_clientserver, ClientServerBaseBlocking) const int calls(1); // initialize eCAL API - eCAL::Initialize(0, nullptr, "clientserver base blocking test"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("clientserver base blocking test"); // create service servers ServiceVecT service_vec; @@ -810,10 +794,7 @@ TEST(core_cpp_clientserver, NestedRPCCall) const int sleep(0); // initialize eCAL API - eCAL::Initialize(0, nullptr, "nested rpc call test"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("nested rpc call test"); // create service server eCAL::CServiceServer server("service"); diff --git a/ecal/tests/cpp/config_test/CMakeLists.txt b/ecal/tests/cpp/config_test/CMakeLists.txt index f6fa9b496d..43b7c155af 100644 --- a/ecal/tests/cpp/config_test/CMakeLists.txt +++ b/ecal/tests/cpp/config_test/CMakeLists.txt @@ -29,7 +29,6 @@ if(ECAL_CORE_CONFIGURATION) endif() set(cmd_parser_src - ${ECAL_CORE_PROJECT_ROOT}/core/src/config/ecal_cmd_parser.cpp ${ECAL_CORE_PROJECT_ROOT}/core/src/util/advanced_tclap_output.cpp ${ECAL_PROJECT_ROOT}/lib/ecal_utils/src/filesystem.cpp ${ECAL_PROJECT_ROOT}/lib/ecal_utils/src/str_convert.cpp diff --git a/ecal/tests/cpp/config_test/src/config_test.cpp b/ecal/tests/cpp/config_test/src/config_test.cpp index a245f564eb..2417811d48 100644 --- a/ecal/tests/cpp/config_test/src/config_test.cpp +++ b/ecal/tests/cpp/config_test/src/config_test.cpp @@ -23,12 +23,13 @@ #include -#include #include +#include +#include +#include #include -#include +#include -#include "ecal_cmd_parser.h" #ifdef ECAL_CORE_CONFIGURATION #include "configuration_reader.h" #endif @@ -59,7 +60,7 @@ TEST(core_cpp_config /*unused*/, user_config_passing /*unused*/) // Publisher options const bool pub_use_shm = false; - eCAL::Configuration custom_config(0, nullptr); + eCAL::Configuration custom_config; try { custom_config.subscriber.drop_out_of_order_messages = drop_out_of_order_messages; @@ -98,7 +99,7 @@ TEST(core_cpp_config /*unused*/, user_config_passing /*unused*/) // Test monitoring console log assignment, default is (log_level_info | log_level_warning | log_level_error | log_level_fatal) EXPECT_EQ(mon_log_filter_con, eCAL::GetConfiguration().logging.sinks.console.filter_log_con); - // Test publisher sendmode assignment, default is eCAL::TLayer::eSendMode::smode_auto + // Test publisher sendmode assignment EXPECT_EQ(pub_use_shm, eCAL::GetConfiguration().publisher.layer.shm.enable); // Test registration option assignment, default timeout is 10000U and default refresh is 1000U @@ -111,7 +112,7 @@ TEST(core_cpp_config /*unused*/, user_config_passing /*unused*/) TEST(core_cpp_config /*unused*/, user_config_death_test /*unused*/) { - eCAL::Configuration custom_config(0, nullptr); + eCAL::Configuration custom_config; // Test the IpAddressV4 class with wrong values ASSERT_THROW( @@ -154,18 +155,6 @@ TEST(core_cpp_config /*unused*/, user_config_death_test /*unused*/) ASSERT_THROW( SetValue(custom_config.transport_layer.udp.network.group, "0.00.000.0"), std::invalid_argument); - - // Test the ConstrainedInteger class with wrong values. Default are MIN = 5242880, STEP = 1024 - // Value below MIN - ASSERT_THROW( - SetValue(custom_config.transport_layer.udp.send_buffer, 42), - std::invalid_argument); - - // Wrong step. Default STEP = 1024 - ASSERT_THROW( - SetValue(custom_config.transport_layer.udp.send_buffer, (5242880 + 512)), - std::invalid_argument); - } TEST(core_cpp_config /*unused*/, config_custom_datatypes_tests /*unused*/) @@ -179,17 +168,9 @@ TEST(core_cpp_config /*unused*/, config_custom_datatypes_tests /*unused*/) ip2 = ip1; EXPECT_EQ(ip1, ip2); - eCAL::Types::ConstrainedInteger<0,1,10> s1; - eCAL::Types::ConstrainedInteger<0,1,10> s2; - EXPECT_EQ(s1, s2); - - s1 = 5; - s2 = s1; - EXPECT_EQ(s1, s2); - // test copy method for config structure - eCAL::Configuration config1(0, nullptr); - eCAL::Configuration config2(0, nullptr); + eCAL::Configuration config1; + eCAL::Configuration config2; std::string testValue = "234.0.3.2"; config2.transport_layer.udp.network.group = testValue; auto& config2ref = config2; @@ -198,28 +179,6 @@ TEST(core_cpp_config /*unused*/, config_custom_datatypes_tests /*unused*/) EXPECT_EQ(config1.transport_layer.udp.network.group, testValue); } -TEST(core_cpp_config /*unused*/, config_cmd_parser_test /*unused*/) -{ - const std::string some_file_name = "someFileName.yml"; - - eCAL::Config::CmdParser parser{}; - - EXPECT_EQ(parser.getUserIni(), ""); - EXPECT_EQ(parser.getDumpConfig(), false); - - std::vector arguments{}; - - arguments.push_back("test_config_cmd_parser_test"); - // set a file name as ini file - arguments.push_back("--ecal-config-file " + some_file_name); - // set the dump config flag - arguments.push_back("--ecal-dump-config"); - - parser.parseArguments(arguments); - - EXPECT_EQ(parser.getUserIni(), some_file_name); - EXPECT_EQ(parser.getDumpConfig(), true); -} #ifdef ECAL_CORE_CONFIGURATION TEST(core_cpp_config /*unused*/, read_write_file_test /*unused*/) @@ -260,9 +219,6 @@ TEST(core_cpp_config /*unused*/, parse_values_test /*unused*/) // Check equality of IpAddressV4 EXPECT_EQ(config.transport_layer.udp.network.group, "239.5.0.1"); - // Check constrained Integer - EXPECT_EQ(config.transport_layer.udp.port, 14010); - // Check boolean EXPECT_EQ(config.transport_layer.udp.npcap_enabled, true); diff --git a/ecal/tests/cpp/core_test/src/core_test.cpp b/ecal/tests/cpp/core_test/src/core_test.cpp index 1de9b1957b..4954b40024 100644 --- a/ecal/tests/cpp/core_test/src/core_test.cpp +++ b/ecal/tests/cpp/core_test/src/core_test.cpp @@ -23,23 +23,20 @@ #include #include +#include TEST(core_cpp_core, GetVersion) { // get eCAL version string - EXPECT_STREQ(ECAL_VERSION, eCAL::GetVersionString()); + EXPECT_STREQ(ECAL_VERSION, eCAL::GetVersionString().c_str()); // get eCAL version date - EXPECT_STREQ(ECAL_DATE, eCAL::GetVersionDateString()); + EXPECT_STREQ(ECAL_DATE, eCAL::GetVersionDateString().c_str()); // get eCAL version as separated integer values - int major = -1; - int minor = -1; - int patch = -1; - eCAL::GetVersion(&major, &minor, &patch); - EXPECT_EQ(ECAL_VERSION_MAJOR, major); - EXPECT_EQ(ECAL_VERSION_MINOR, minor); - EXPECT_EQ(ECAL_VERSION_PATCH, patch); + EXPECT_EQ(ECAL_VERSION_MAJOR, eCAL::GetVersion().major); + EXPECT_EQ(ECAL_VERSION_MINOR, eCAL::GetVersion().minor); + EXPECT_EQ(ECAL_VERSION_PATCH, eCAL::GetVersion().patch); } TEST(core_cpp_core, InitializeFinalize) @@ -48,13 +45,13 @@ TEST(core_cpp_core, InitializeFinalize) EXPECT_EQ(0, eCAL::IsInitialized()); // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "initialize_test")); + EXPECT_EQ(0, eCAL::Initialize("initialize_test")); // Is eCAL API initialized ? EXPECT_EQ(1, eCAL::IsInitialized()); // initialize eCAL API again we expect return value 1 for yet initialized - EXPECT_EQ(1, eCAL::Initialize(0, nullptr, "initialize_test")); + EXPECT_EQ(1, eCAL::Initialize("initialize_test")); // finalize eCAL API we expect return value 0 even it will not be really finalized because it's 2 times initialzed and 1 time finalized EXPECT_EQ(0, eCAL::Finalize()); @@ -78,7 +75,7 @@ TEST(core_cpp_core, MultipleInitializeFinalize) for (auto i = 0; i < 4; ++i) { // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "multiple_initialize_finalize_test")); + EXPECT_EQ(0, eCAL::Initialize("multiple_initialize_finalize_test")); // finalize eCAL API EXPECT_EQ(0, eCAL::Finalize()); @@ -115,7 +112,7 @@ namespace TEST(core_cpp_core, SetGetUnitName) { // initialize eCAL API with empty unit name (eCAL will use process name as unit name) - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "")); + EXPECT_EQ(0, eCAL::Initialize("")); // Is eCAL API initialized ? EXPECT_EQ(1, eCAL::IsInitialized()); @@ -128,10 +125,6 @@ TEST(core_cpp_core, SetGetUnitName) EXPECT_EQ(0, eCAL::SetUnitName("unit name")); EXPECT_STREQ("unit name", eCAL::Process::GetUnitName().c_str()); - // set nullptr unit name (should not change the unit name) - EXPECT_EQ(-1, eCAL::SetUnitName(nullptr)); - EXPECT_STREQ("unit name", eCAL::Process::GetUnitName().c_str()); - // set empty unit name (should not change the unit name) EXPECT_EQ(-1, eCAL::SetUnitName("")); EXPECT_STREQ("unit name", eCAL::Process::GetUnitName().c_str()); @@ -146,7 +139,7 @@ TEST(core_cpp_core, eCAL_Ok) EXPECT_EQ(0, eCAL::Ok()); // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "okay_test")); + EXPECT_EQ(0, eCAL::Initialize("okay_test")); // check initialized eCAL, should be okay EXPECT_EQ(1, eCAL::Ok()); @@ -175,7 +168,7 @@ namespace TEST(Core, TimerCallback) { // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "timer callback")); + EXPECT_EQ(0, eCAL::Initialize("timer callback")); // Is eCAL API initialized ? EXPECT_EQ(1, eCAL::IsInitialized()); diff --git a/ecal/tests/cpp/descgate_test/src/descgate_getentities.cpp b/ecal/tests/cpp/descgate_test/src/descgate_getentities.cpp index c17bf5ec4f..c72b33cbe4 100644 --- a/ecal/tests/cpp/descgate_test/src/descgate_getentities.cpp +++ b/ecal/tests/cpp/descgate_test/src/descgate_getentities.cpp @@ -19,9 +19,11 @@ #include "ecal_descgate.h" +#include #include #include +#include #include #define DESCGATE_EXPIRATION_MS 500 @@ -144,15 +146,15 @@ TEST(core_cpp_descgate, PublisherQualities) { for (const auto& id : id_set) { - eCAL::Registration::SQualityTopicInfo quality_info; - bool found = desc_gate.GetPublisherInfo(id, quality_info); + eCAL::SDataTypeInformation topic_info; + bool found = desc_gate.GetPublisherInfo(id, topic_info); EXPECT_TRUE(found); if (found) { std::string tname = id.topic_name; - EXPECT_EQ(tname + "-tdatatype.name", quality_info.info.name); - EXPECT_EQ(tname + "-tdatatype.encoding", quality_info.info.encoding); - EXPECT_EQ(tname + "-tdatatype.descriptor", quality_info.info.descriptor); + EXPECT_EQ(tname + "-tdatatype.name", topic_info.name); + EXPECT_EQ(tname + "-tdatatype.encoding", topic_info.encoding); + EXPECT_EQ(tname + "-tdatatype.descriptor", topic_info.descriptor); } } } @@ -227,15 +229,15 @@ TEST(core_cpp_descgate, SubscriberQualities) { for (const auto& id : id_set) { - eCAL::Registration::SQualityTopicInfo quality_info; - bool found = desc_gate.GetSubscriberInfo(id, quality_info); + eCAL::SDataTypeInformation topic_info; + bool found = desc_gate.GetSubscriberInfo(id, topic_info); EXPECT_TRUE(found); if (found) { std::string tname = id.topic_name; - EXPECT_EQ(tname + "-tdatatype.name", quality_info.info.name); - EXPECT_EQ(tname + "-tdatatype.encoding", quality_info.info.encoding); - EXPECT_EQ(tname + "-tdatatype.descriptor", quality_info.info.descriptor); + EXPECT_EQ(tname + "-tdatatype.name", topic_info.name); + EXPECT_EQ(tname + "-tdatatype.encoding", topic_info.encoding); + EXPECT_EQ(tname + "-tdatatype.descriptor", topic_info.descriptor); } } } diff --git a/ecal/tests/cpp/event_test/src/event_test.cpp b/ecal/tests/cpp/event_test/src/event_test.cpp index b58d14c621..fcb89e6cfb 100644 --- a/ecal/tests/cpp/event_test/src/event_test.cpp +++ b/ecal/tests/cpp/event_test/src/event_test.cpp @@ -20,6 +20,7 @@ #include "ecal_event.h" #include +#include TEST(core_cpp_core, Event_EventSetGet) { diff --git a/ecal/tests/cpp/expmap_test/src/expmap_test.cpp b/ecal/tests/cpp/expmap_test/src/expmap_test.cpp index 4d6a6b3292..b22ee8d4cd 100644 --- a/ecal/tests/cpp/expmap_test/src/expmap_test.cpp +++ b/ecal/tests/cpp/expmap_test/src/expmap_test.cpp @@ -20,9 +20,8 @@ #include #include "util/ecal_expmap.h" -#include #include -#include +#include #include #include diff --git a/ecal/tests/cpp/io_memfile_test/src/memfile_naming_test.cpp b/ecal/tests/cpp/io_memfile_test/src/memfile_naming_test.cpp index 07e68789e3..bdc542b1df 100644 --- a/ecal/tests/cpp/io_memfile_test/src/memfile_naming_test.cpp +++ b/ecal/tests/cpp/io_memfile_test/src/memfile_naming_test.cpp @@ -19,11 +19,10 @@ #include "io/shm/ecal_memfile_naming.h" -#include #include #include - +#include TEST(core_cpp_core, MemFile_MemfileNaming) { diff --git a/ecal/tests/cpp/io_memfile_test/src/memfile_test.cpp b/ecal/tests/cpp/io_memfile_test/src/memfile_test.cpp index b2b229ee79..b9cfd26407 100644 --- a/ecal/tests/cpp/io_memfile_test/src/memfile_test.cpp +++ b/ecal/tests/cpp/io_memfile_test/src/memfile_test.cpp @@ -17,17 +17,19 @@ * ========================= eCAL LICENSE ================================= */ -#include #include "io/shm/ecal_memfile.h" #include "io/shm/ecal_memfile_db.h" +#include +#include -#include #include -#include #include +#include +#include #include #include +#include namespace eCAL { diff --git a/ecal/tests/cpp/logging_test/src/logging_test.cpp b/ecal/tests/cpp/logging_test/src/logging_test.cpp index db9009e79f..86a8e96913 100644 --- a/ecal/tests/cpp/logging_test/src/logging_test.cpp +++ b/ecal/tests/cpp/logging_test/src/logging_test.cpp @@ -17,17 +17,22 @@ * ========================= eCAL LICENSE ================================= */ -#include +#include #include +#include #include #include #include #include +#include #include #include -#include +#include +#include +#include +#include #include constexpr std::chrono::milliseconds UDP_WAIT_TIME(1); @@ -84,7 +89,7 @@ TEST(logging_to /*unused*/, file /*unused*/) const std::string log_message = "Logging to file test."; auto ecal_config = GetFileConfiguration(logging_path); - eCAL::Initialize(ecal_config, unit_name.c_str(), eCAL::Init::Logging); + eCAL::Initialize(ecal_config, unit_name, eCAL::Init::Logging); eCAL::Logging::Log(log_level_info, log_message); @@ -124,7 +129,7 @@ TEST(logging_to /*unused*/, udp /*unused*/) const std::string log_message = "Logging to udp test."; auto ecal_config = GetUDPConfiguration(); - eCAL::Initialize(ecal_config, unit_name.c_str(), eCAL::Init::Logging); + eCAL::Initialize(ecal_config, unit_name, eCAL::Init::Logging); eCAL::Logging::Log(log_level_info, log_message); @@ -155,7 +160,7 @@ TEST(logging_to /*unused*/, console /*unused*/) const std::string log_message = "Logging to console test."; auto ecal_config = GetConsoleConfiguration(); - eCAL::Initialize(ecal_config, unit_name.c_str(), eCAL::Init::Logging); + eCAL::Initialize(ecal_config, unit_name, eCAL::Init::Logging); { // Redirect the output stream to a stringstream in order to find log messages @@ -182,7 +187,7 @@ TEST(logging_levels /*unused*/, all /*unused*/) const std::string log_message = "Logging level all test for udp."; auto ecal_config = GetUDPConfiguration(); - eCAL::Initialize(ecal_config, unit_name.c_str(), eCAL::Init::Logging); + eCAL::Initialize(ecal_config, unit_name, eCAL::Init::Logging); eCAL::Logging::SLogging log; @@ -221,7 +226,7 @@ TEST(logging_levels /*unused*/, various /*unused*/) ecal_config.logging.sinks.udp.filter_log_udp = log_level_warning; - eCAL::Initialize(ecal_config, unit_name.c_str(), eCAL::Init::Logging); + eCAL::Initialize(ecal_config, unit_name, eCAL::Init::Logging); eCAL::Logging::SLogging log; @@ -258,7 +263,7 @@ TEST(logging_levels /*unused*/, none /*unused*/) ecal_config.logging.sinks.udp.filter_log_udp = log_level_none; - eCAL::Initialize(ecal_config, unit_name.c_str(), eCAL::Init::Logging); + eCAL::Initialize(ecal_config, unit_name, eCAL::Init::Logging); eCAL::Logging::SLogging log; @@ -297,7 +302,7 @@ TEST(logging_disable /*unused*/, file /*unused*/) auto ecal_config = GetFileConfiguration(logging_path); ecal_config.logging.sinks.file.enable = false; - eCAL::Initialize(ecal_config, unit_name.c_str(), eCAL::Init::Logging); + eCAL::Initialize(ecal_config, unit_name, eCAL::Init::Logging); eCAL::Logging::Log(log_level_info, log_message); @@ -325,7 +330,7 @@ TEST(logging_disable /*unused*/, udp /*unused*/) auto ecal_config = GetUDPConfiguration(); ecal_config.logging.sinks.udp.enable = false; - eCAL::Initialize(ecal_config, unit_name.c_str(), eCAL::Init::Logging); + eCAL::Initialize(ecal_config, unit_name, eCAL::Init::Logging); eCAL::Logging::Log(log_level_info, log_message); @@ -346,7 +351,7 @@ TEST(logging_disable /*unused*/, console /*unused*/) auto ecal_config = GetConsoleConfiguration(); ecal_config.logging.sinks.console.enable = false; - eCAL::Initialize(ecal_config, unit_name.c_str(), eCAL::Init::Logging); + eCAL::Initialize(ecal_config, unit_name, eCAL::Init::Logging); { // Redirect the output stream to a stringstream in order to find log messages diff --git a/ecal/tests/cpp/monitoring_test/src/monitoring_filter_test.cpp b/ecal/tests/cpp/monitoring_test/src/monitoring_filter_test.cpp index 1b08acf0af..8ec85f80b1 100644 --- a/ecal/tests/cpp/monitoring_test/src/monitoring_filter_test.cpp +++ b/ecal/tests/cpp/monitoring_test/src/monitoring_filter_test.cpp @@ -17,6 +17,7 @@ * ========================= eCAL LICENSE ================================= */ +#include #include #include diff --git a/ecal/tests/cpp/pubsub_proto_test/src/proto_dyn_subscriber_test.cpp b/ecal/tests/cpp/pubsub_proto_test/src/proto_dyn_subscriber_test.cpp index e44071b29f..3dbef84820 100644 --- a/ecal/tests/cpp/pubsub_proto_test/src/proto_dyn_subscriber_test.cpp +++ b/ecal/tests/cpp/pubsub_proto_test/src/proto_dyn_subscriber_test.cpp @@ -20,6 +20,8 @@ // std headers #include #include +#include +#include #include // used libraries @@ -41,8 +43,6 @@ class ProtoDynSubscriberTest : public ::testing::Test { { // Initialize eCAL eCAL::Initialize(); - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); } ~ProtoDynSubscriberTest() override { @@ -58,7 +58,7 @@ class ProtoDynSubscriberTest : public ::testing::Test { pub.Send(p); } - void OnPerson(const char* /*topic_name*/, const std::shared_ptr& /*message*/, long long /*time*/) + void OnPerson(const std::shared_ptr& /*message*/, long long /*time*/) { received_callbacks++; } @@ -95,7 +95,7 @@ TEST_F(core_cpp_pubsub_proto_dyn, ProtoDynSubscriberTest_SendReceiveCB) { // Assert that the Subscriber can be move constructed. eCAL::protobuf::CDynamicSubscriber person_dyn_rec("ProtoSubscriberTest"); - auto person_callback = std::bind(&ProtoDynSubscriberTest::OnPerson, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); + auto person_callback = std::bind(&ProtoDynSubscriberTest::OnPerson, this, std::placeholders::_2, std::placeholders::_3); person_dyn_rec.AddReceiveCallback(person_callback); ASSERT_TRUE(person_dyn_rec.IsCreated()); @@ -108,23 +108,3 @@ TEST_F(core_cpp_pubsub_proto_dyn, ProtoDynSubscriberTest_SendReceiveCB) // assert that the OnPerson callback has been called once. ASSERT_EQ(1, received_callbacks); } - -TEST_F(core_cpp_pubsub_proto_dyn, ProtoDynSubscriberTest_SendReceive) -{ - // Assert that the Subscriber can be move constructed. - eCAL::protobuf::CDynamicSubscriber person_dyn_rec("ProtoSubscriberTest"); - ASSERT_TRUE(person_dyn_rec.IsCreated()); - - eCAL::protobuf::CPublisher person_pub("ProtoSubscriberTest"); - - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - - SendPerson(person_pub); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - - auto received_message = person_dyn_rec.Receive(nullptr, 500); - // assert that the OnPerson callback has been called once. - ASSERT_TRUE(received_message.has_value()) << "we should have received data that was sent"; - auto id = extract_id(*received_message.value()); - ASSERT_EQ(id, 1) << "Extracted ID needs to be 1"; -} diff --git a/ecal/tests/cpp/pubsub_proto_test/src/proto_publisher_test.cpp b/ecal/tests/cpp/pubsub_proto_test/src/proto_publisher_test.cpp index c61b453559..fe351029db 100644 --- a/ecal/tests/cpp/pubsub_proto_test/src/proto_publisher_test.cpp +++ b/ecal/tests/cpp/pubsub_proto_test/src/proto_publisher_test.cpp @@ -18,7 +18,6 @@ */ // std headers -#include // used libraries #include // own project @@ -26,6 +25,7 @@ #include #include +#include class ProtoPublisherTest : public ::testing::Test { public: diff --git a/ecal/tests/cpp/pubsub_proto_test/src/proto_subscriber_test.cpp b/ecal/tests/cpp/pubsub_proto_test/src/proto_subscriber_test.cpp index 6d198b1e6a..50032dc0ae 100644 --- a/ecal/tests/cpp/pubsub_proto_test/src/proto_subscriber_test.cpp +++ b/ecal/tests/cpp/pubsub_proto_test/src/proto_subscriber_test.cpp @@ -20,6 +20,8 @@ // std headers #include #include +#include +#include #include // used libraries #include @@ -29,6 +31,7 @@ #include #include +#include class ProtoSubscriberTest : public ::testing::Test { public: @@ -37,8 +40,6 @@ class ProtoSubscriberTest : public ::testing::Test { { // Initialize eCAL eCAL::Initialize(); - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); } ~ProtoSubscriberTest() override { diff --git a/ecal/tests/cpp/pubsub_test/src/pubsub_acknowledge.cpp b/ecal/tests/cpp/pubsub_test/src/pubsub_acknowledge.cpp index e564457dd7..b32d6a1dbd 100644 --- a/ecal/tests/cpp/pubsub_test/src/pubsub_acknowledge.cpp +++ b/ecal/tests/cpp/pubsub_test/src/pubsub_acknowledge.cpp @@ -17,10 +17,14 @@ * ========================= eCAL LICENSE ================================= */ +#include #include #include #include +#include +#include +#include #include #include @@ -48,10 +52,7 @@ namespace TEST(core_cpp_pubsub, TimeoutAcknowledgment) { // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "TimeoutAcknowledgment", eCAL::Init::All)); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + EXPECT_EQ(0, eCAL::Initialize("TimeoutAcknowledgment", eCAL::Init::All)); // create publisher config eCAL::Publisher::Configuration pub_config; diff --git a/ecal/tests/cpp/pubsub_test/src/pubsub_callback_topicid.cpp b/ecal/tests/cpp/pubsub_test/src/pubsub_callback_topicid.cpp index cd3c99c852..94d8ec26b3 100644 --- a/ecal/tests/cpp/pubsub_test/src/pubsub_callback_topicid.cpp +++ b/ecal/tests/cpp/pubsub_test/src/pubsub_callback_topicid.cpp @@ -17,13 +17,16 @@ * ========================= eCAL LICENSE ================================= */ +#include #include #include #include -#include -#include #include +#include +#include +#include +#include namespace eCAL { diff --git a/ecal/tests/cpp/pubsub_test/src/pubsub_connection_test.cpp b/ecal/tests/cpp/pubsub_test/src/pubsub_connection_test.cpp index 9c29c1a408..357639ab06 100644 --- a/ecal/tests/cpp/pubsub_test/src/pubsub_connection_test.cpp +++ b/ecal/tests/cpp/pubsub_test/src/pubsub_connection_test.cpp @@ -31,10 +31,7 @@ TEST(core_cpp_pubsub, TestSubscriberIsPublishedTiming) { // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "subscriber_is_published")); - - // enable data loopback - eCAL::Util::EnableLoopback(true); + EXPECT_EQ(0, eCAL::Initialize("subscriber_is_published")); std::atomic do_start_publication(false); std::atomic publication_finished(false); @@ -74,7 +71,6 @@ TEST(core_cpp_pubsub, TestSubscriberIsPublishedTiming) std::string first_received_sample; auto subscriber_function = [&do_start_publication, &publication_finished, &publisher_seen_at_subscription_start, &first_received_sample]() { eCAL::CSubscriber sub("blob"); - bool received(false); const auto max_sub_count(10); auto sub_count(0); auto receive_lambda = [&max_sub_count, &sub_count, &publisher_seen_at_subscription_start, &first_received_sample, &sub](const char* /*topic_name_*/, const struct eCAL::SReceiveCallbackData* data_) { @@ -135,10 +131,7 @@ TEST(core_cpp_pubsub, TestSubscriberIsPublishedTiming) TEST(core_cpp_pubsub, TestPublisherIsSubscribedTiming) { // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "publisher_is_subscribed")); - - // enable data loopback - eCAL::Util::EnableLoopback(true); + EXPECT_EQ(0, eCAL::Initialize("publisher_is_subscribed")); std::atomic do_start_publication(false); std::atomic publication_finished(false); @@ -177,7 +170,6 @@ TEST(core_cpp_pubsub, TestPublisherIsSubscribedTiming) std::string first_received_sample; auto subscriber_function = [&publication_finished, &publisher_seen_at_subscription_start, &first_received_sample]() { eCAL::CSubscriber sub("blob"); - bool received(false); const auto max_sub_count(10); auto sub_count(0); auto receive_lambda = [&max_sub_count, &sub_count, &publisher_seen_at_subscription_start, &first_received_sample, &sub](const char* /*topic_name_*/, const struct eCAL::SReceiveCallbackData* data_) { @@ -234,10 +226,7 @@ TEST(core_cpp_pubsub, TestPublisherIsSubscribedTiming) TEST(core_cpp_pubsub, TestChainedPublisherSubscriberCallback) { // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "chained_publisher_subscriber")); - - // enable data loopback - eCAL::Util::EnableLoopback(true); + EXPECT_EQ(0, eCAL::Initialize("chained_publisher_subscriber")); // Set up counters for sent and received messages const int message_count = 10; diff --git a/ecal/tests/cpp/pubsub_test/src/pubsub_multibuffer.cpp b/ecal/tests/cpp/pubsub_test/src/pubsub_multibuffer.cpp index 569736efb3..826de1c97e 100644 --- a/ecal/tests/cpp/pubsub_test/src/pubsub_multibuffer.cpp +++ b/ecal/tests/cpp/pubsub_test/src/pubsub_multibuffer.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,18 @@ * ========================= eCAL LICENSE ================================= */ +#include +#include #include #include #include +#include #include #include #include +#include enum { CMN_REGISTRATION_REFRESH_MS = 1000, @@ -123,10 +127,7 @@ std::vector multibuffer_pub_sub_test(int buffer_count, bool zero_copy, int TEST(core_cpp_pubsub, MultibufferPubSub) { // initialize eCAL API - eCAL::Initialize(0, nullptr, "pubsub_test"); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("pubsub_test"); // number of iterations const int publications(11); diff --git a/ecal/tests/cpp/pubsub_test/src/pubsub_receive_test.cpp b/ecal/tests/cpp/pubsub_test/src/pubsub_receive_test.cpp index 2b7a9fc3f3..b7052a5b37 100644 --- a/ecal/tests/cpp/pubsub_test/src/pubsub_receive_test.cpp +++ b/ecal/tests/cpp/pubsub_test/src/pubsub_receive_test.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -68,10 +69,7 @@ void measure_execution_within_range(const std::string& description, std::functio TEST(core_cpp_pubsub, TimingSubscriberReceive) { // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "subscriber_receive_timing")); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + EXPECT_EQ(0, eCAL::Initialize("subscriber_receive_timing")); // create simple string publisher eCAL::string::CPublisher pub("CLOCK"); @@ -165,10 +163,7 @@ TEST(core_cpp_pubsub, TimingSubscriberReceive) TEST(core_cpp_pubsub, SporadicEmptyReceives) { // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "sporadic_empty_receives")); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + EXPECT_EQ(0, eCAL::Initialize("sporadic_empty_receives")); // create simple string publisher eCAL::string::CPublisher pub("CLOCK"); diff --git a/ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp b/ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp index ba050bb784..44f7b9474d 100644 --- a/ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp +++ b/ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp @@ -17,11 +17,17 @@ * ========================= eCAL LICENSE ================================= */ +#include +#include #include #include #include #include +#include +#include +#include +#include #include #include @@ -58,10 +64,7 @@ namespace TEST(core_cpp_pubsub, LeakedPubSub) { // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "leaked pub/sub")); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + EXPECT_EQ(0, eCAL::Initialize("leaked pub/sub")); // create subscriber and register a callback eCAL::CSubscriber sub("foo"); @@ -106,10 +109,7 @@ TEST(core_cpp_pubsub, LeakedPubSub) TEST(core_cpp_pubsub, CallbackDestruction) { // initialize eCAL API - EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "callback destruction")); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + EXPECT_EQ(0, eCAL::Initialize("callback destruction")); // create subscriber and register a callback std::shared_ptr sub; @@ -164,7 +164,7 @@ TEST(core_cpp_pubsub, CallbackDestruction) TEST(core_cpp_pubsub, CreateDestroy) { // initialize eCAL API - eCAL::Initialize(0, nullptr, "pubsub_test"); + eCAL::Initialize("pubsub_test"); // create publisher for topic "foo" eCAL::CPublisher pub; @@ -207,10 +207,7 @@ TEST(core_cpp_pubsub, SimpleMessage1) std::string recv_s; // initialize eCAL API - eCAL::Initialize(0, nullptr, "pubsub_test"); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("pubsub_test"); // create publisher for topic "foo" eCAL::CPublisher pub("foo"); @@ -252,10 +249,7 @@ TEST(core_cpp_pubsub, SimpleMessage2) std::string recv_s; // initialize eCAL API - eCAL::Initialize(0, nullptr, "pubsub_test"); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("pubsub_test"); // create subscriber for topic "foo" eCAL::CSubscriber sub("foo"); @@ -290,10 +284,7 @@ TEST(core_cpp_pubsub, SimpleMessageCB) const std::string send_s = CreatePayLoad(PAYLOAD_SIZE_BYTE); // initialize eCAL API - eCAL::Initialize(0, nullptr, "pubsub_test"); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("pubsub_test"); // create subscriber for topic "foo" eCAL::CSubscriber sub("foo"); @@ -369,10 +360,7 @@ TEST(core_cpp_pubsub, DynamicSizeCB) std::string send_s = CreatePayLoad(PAYLOAD_SIZE_BYTE); // initialize eCAL API - eCAL::Initialize(0, nullptr, "pubsub_test"); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("pubsub_test"); // create subscriber for topic "foo" eCAL::CSubscriber sub("foo"); @@ -425,10 +413,7 @@ TEST(core_cpp_pubsub, DynamicCreate) const std::string send_s = CreatePayLoad(PAYLOAD_SIZE_BYTE); // initialize eCAL API - eCAL::Initialize(0, nullptr, "pubsub_test"); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("pubsub_test"); // create subscriber for topic "foo" eCAL::CSubscriber* sub; @@ -521,10 +506,7 @@ TEST(core_cpp_pubsub, DestroyInCallback) */ // initialize eCAL API - eCAL::Initialize(0, nullptr, "New Publisher in Callback"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("New Publisher in Callback"); // start publishing thread eCAL::string::CPublisher pub_foo("foo"); @@ -587,10 +569,7 @@ TEST(core_cpp_pubsub, SubscriberReconnection) */ // initialize eCAL API - eCAL::Initialize(0, nullptr, "SubscriberReconnection"); - - // enable loop back communication in the same thread - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("SubscriberReconnection"); // start publishing thread std::atomic stop_publishing(false); @@ -609,7 +588,7 @@ TEST(core_cpp_pubsub, SubscriberReconnection) size_t callback_received_count(0); eCAL::string::CSubscriber sub_foo("foo"); - auto receive_lambda = [&sub_foo, &callback_received_count](const char* /*topic_*/, const std::string& /*msg*/, long long /*time_*/, long long /*clock_*/, long long /*id_*/) { + auto receive_lambda = [&callback_received_count](const char* /*topic_*/, const std::string& /*msg*/, long long /*time_*/, long long /*clock_*/, long long /*id_*/) { std::cout << "Receiving in scope 1" << std::endl; callback_received_count++; }; @@ -626,7 +605,7 @@ TEST(core_cpp_pubsub, SubscriberReconnection) size_t callback_received_count(0); eCAL::string::CSubscriber sub_foo("foo"); - auto receive_lambda = [&sub_foo, &callback_received_count](const char* /*topic_*/, const std::string& /*msg*/, long long /*time_*/, long long /*clock_*/, long long /*id_*/) { + auto receive_lambda = [&callback_received_count](const char* /*topic_*/, const std::string& /*msg*/, long long /*time_*/, long long /*clock_*/, long long /*id_*/) { std::cout << "Receiving in scope 2" << std::endl; callback_received_count++; }; diff --git a/ecal/tests/cpp/pubsub_test/src/pubsub_test_shm.cpp b/ecal/tests/cpp/pubsub_test/src/pubsub_test_shm.cpp index d326c1817f..6e573ad8f2 100644 --- a/ecal/tests/cpp/pubsub_test/src/pubsub_test_shm.cpp +++ b/ecal/tests/cpp/pubsub_test/src/pubsub_test_shm.cpp @@ -17,14 +17,17 @@ * ========================= eCAL LICENSE ================================= */ +#include #include #include #include #include -#include +#include +#include #include +#include enum { CMN_REGISTRATION_REFRESH_MS = 1000, @@ -49,10 +52,7 @@ TEST(core_cpp_pubsub, ZeroPayloadMessageSHM) const std::string send_s; // initialize eCAL API - eCAL::Initialize(0, nullptr, "pubsub_test"); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("pubsub_test"); // create subscriber for topic "A" eCAL::CSubscriber sub("A"); @@ -118,10 +118,7 @@ TEST(core_cpp_pubsub, MultipleSendsSHM) long long last_received_timestamp(0); // initialize eCAL API - eCAL::Initialize(0, nullptr, "pubsub_test"); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("pubsub_test"); // create subscriber for topic "A" eCAL::string::CSubscriber sub("A"); diff --git a/ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp b/ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp index cfdf27b5ac..ea4b4d7d2e 100644 --- a/ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp +++ b/ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,17 @@ * ========================= eCAL LICENSE ================================= */ +#include #include #include #include #include -#include +#include +#include #include +#include enum { CMN_REGISTRATION_REFRESH_MS = 1000, @@ -49,10 +52,7 @@ TEST(core_cpp_pubsub, ZeroPayloadMessageUDP) const std::string send_s; // initialize eCAL API - eCAL::Initialize(0, nullptr, "pubsub_test"); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("pubsub_test"); // create subscriber for topic "A" eCAL::CSubscriber sub("A"); @@ -104,10 +104,7 @@ TEST(core_cpp_pubsub, MultipleSendsUDP) long long last_received_timestamp(0); // initialize eCAL API - eCAL::Initialize(0, nullptr, "pubsub_test"); - - // publish / subscribe match in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("pubsub_test"); // create subscriber for topic "A" eCAL::string::CSubscriber sub("A"); diff --git a/ecal/tests/cpp/registration_test_public/src/registration_getclients.cpp b/ecal/tests/cpp/registration_test_public/src/registration_getclients.cpp index 26219189fd..83e0174efb 100644 --- a/ecal/tests/cpp/registration_test_public/src/registration_getclients.cpp +++ b/ecal/tests/cpp/registration_test_public/src/registration_getclients.cpp @@ -21,6 +21,9 @@ #include #include +#include +#include +#include enum { CMN_MONITORING_TIMEOUT_MS = (5000 + 100), @@ -42,7 +45,6 @@ class ClientsTestFixture : public ::testing::TestWithParam // set configuration from the test parameters auto params = GetParam(); eCAL::Initialize(params.configuration, "core_cpp_registration_public", eCAL::Init::All); - eCAL::Util::EnableLoopback(true); } void TearDown() override @@ -53,7 +55,7 @@ class ClientsTestFixture : public ::testing::TestWithParam }; TEST_P(ClientsTestFixture, ClientExpiration) { - std::map client_info_map; + std::set id_set; // create simple client and let it expire { @@ -69,10 +71,10 @@ TEST_P(ClientsTestFixture, ClientExpiration) eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); // get all clients - eCAL::Registration::GetClients(client_info_map); + id_set = eCAL::Registration::GetClientIDs(); // check size - EXPECT_EQ(client_info_map.size(), 1); + EXPECT_EQ(id_set.size(), 1); // check client/method names std::set client_method_names; @@ -88,10 +90,10 @@ TEST_P(ClientsTestFixture, ClientExpiration) eCAL::Process::SleepMS(CMN_MONITORING_TIMEOUT_MS); // get all clients again, client should not be expired - eCAL::Registration::GetClients(client_info_map); + id_set = eCAL::Registration::GetClientIDs(); // check size - EXPECT_EQ(client_info_map.size(), 1); + EXPECT_EQ(id_set.size(), 1); } // let's unregister @@ -99,167 +101,10 @@ TEST_P(ClientsTestFixture, ClientExpiration) // get all clients again, all clients // should be removed from the map - eCAL::Registration::GetClients(client_info_map); + id_set = eCAL::Registration::GetClientIDs(); // check size - EXPECT_EQ(client_info_map.size(), 0); -} - -TEST_P(ClientsTestFixture, ClientEqualQualities) -{ - std::map client_info_map; - - // create 2 clients with the same quality of data type information - { - // create client 1 - eCAL::SServiceMethodInformation service_method_info1; - service_method_info1.request_type.name = "foo::req_type1"; - service_method_info1.request_type.descriptor = "foo::req_desc1"; - service_method_info1.response_type.name = "foo::resp_type1"; - service_method_info1.response_type.descriptor = "foo::resp_desc1"; - eCAL::v5::CServiceClient client1("foo::service", { {"foo::method", service_method_info1} }); - - // let's register - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // get all clients - eCAL::Registration::GetClients(client_info_map); - - // check size - EXPECT_EQ(client_info_map.size(), 1); - - // check attributes - std::string req_type, resp_type; - std::string req_desc, resp_desc; - - eCAL::Registration::GetClientTypeNames("foo::service", "foo::method", req_type, resp_type); - EXPECT_EQ(req_type, "foo::req_type1"); - EXPECT_EQ(resp_type, "foo::resp_type1"); - eCAL::Registration::GetClientDescription("foo::service", "foo::method", req_desc, resp_desc); - EXPECT_EQ(req_desc, "foo::req_desc1"); - EXPECT_EQ(resp_desc, "foo::resp_desc1"); - - // create client 2 - // this will not overwrite the attributes from client 1, because the quality is not higher - eCAL::SServiceMethodInformation service_method_info2; - service_method_info2.request_type.name = "foo::req_type2"; - service_method_info2.request_type.descriptor = "foo::req_desc2"; - service_method_info2.response_type.name = "foo::resp_type2"; - service_method_info2.response_type.descriptor = "foo::resp_desc2"; - eCAL::v5::CServiceClient client2("foo::service", { {"foo::method", service_method_info2} }); - - // check attributes - eCAL::Registration::GetClientTypeNames("foo::service", "foo::method", req_type, resp_type); - EXPECT_EQ(req_type, "foo::req_type1"); - EXPECT_EQ(resp_type, "foo::resp_type1"); - eCAL::Registration::GetClientDescription("foo::service", "foo::method", req_desc, resp_desc); - EXPECT_EQ(req_desc, "foo::req_desc1"); - EXPECT_EQ(resp_desc, "foo::resp_desc1"); - - // check size it's client 1 only - EXPECT_EQ(client_info_map.size(), 1); - - // let's wait a monitoring timeout long - eCAL::Process::SleepMS(CMN_MONITORING_TIMEOUT_MS); - - // get all clients again, clients should not be expired - eCAL::Registration::GetClients(client_info_map); - - // check size - EXPECT_EQ(client_info_map.size(), 1); - - // destroy client 1 - client1.Destroy(); - - // let's register - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // check attributes, client 1 attributes should be replaced by client 2 attributes now - eCAL::Registration::GetClientTypeNames("foo::service", "foo::method", req_type, resp_type); - EXPECT_EQ(req_type, "foo::req_type2"); - EXPECT_EQ(resp_type, "foo::resp_type2"); - eCAL::Registration::GetClientDescription("foo::service", "foo::method", req_desc, resp_desc); - EXPECT_EQ(req_desc, "foo::req_desc2"); - EXPECT_EQ(resp_desc, "foo::resp_desc2"); - } - - // let's unregister - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // get all clients again, all clients - // should be removed from the map - eCAL::Registration::GetClients(client_info_map); - - // check size - EXPECT_EQ(client_info_map.size(), 0); -} - -TEST_P(ClientsTestFixture, ClientDifferentQualities) -{ - std::map client_info_map; - - // create 2 clients with different qualities of data type information - { - // create client 1, response type name and reponse description are missing - eCAL::SServiceMethodInformation service_method_info1; - service_method_info1.request_type.name = "foo::req_type1"; - service_method_info1.request_type.descriptor = "foo::req_desc1"; - service_method_info1.response_type.name = ""; - service_method_info1.response_type.descriptor = ""; - eCAL::v5::CServiceClient client1("foo::service", { {"foo::method", service_method_info1} }); - - // let's register - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // get all clients - eCAL::Registration::GetClients(client_info_map); - - // check size - EXPECT_EQ(client_info_map.size(), 1); - - // check attributes - std::string req_type, resp_type; - std::string req_desc, resp_desc; - - eCAL::Registration::GetClientTypeNames("foo::service", "foo::method", req_type, resp_type); - EXPECT_EQ(req_type, "foo::req_type1"); - EXPECT_EQ(resp_type, ""); - eCAL::Registration::GetClientDescription("foo::service", "foo::method", req_desc, resp_desc); - EXPECT_EQ(req_desc, "foo::req_desc1"); - EXPECT_EQ(resp_desc, ""); - - // create client 2, with higher quality than client 1 - eCAL::SServiceMethodInformation service_method_info2; - service_method_info2.request_type.name = "foo::req_type2"; - service_method_info2.request_type.descriptor = "foo::req_desc2"; - service_method_info2.response_type.name = "foo::resp_type2"; - service_method_info2.response_type.descriptor = "foo::resp_desc2"; - eCAL::v5::CServiceClient client2("foo::service", { {"foo::method", service_method_info2} }); - - // let's register - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // check attributes, we expect attributes from client 2 here - eCAL::Registration::GetClientTypeNames("foo::service", "foo::method", req_type, resp_type); - EXPECT_EQ(req_type, "foo::req_type2"); - EXPECT_EQ(resp_type, "foo::resp_type2"); - eCAL::Registration::GetClientDescription("foo::service", "foo::method", req_desc, resp_desc); - EXPECT_EQ(req_desc, "foo::req_desc2"); - EXPECT_EQ(resp_desc, "foo::resp_desc2"); - - // check size it's client 2 only - EXPECT_EQ(client_info_map.size(), 1); - } - - // let's unregister - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // get all clients again, all clients - // should be removed from the map - eCAL::Registration::GetClients(client_info_map); - - // check size - EXPECT_EQ(client_info_map.size(), 0); + EXPECT_EQ(id_set.size(), 0); } TEST_P(ClientsTestFixture, GetClientIDs) @@ -282,11 +127,11 @@ TEST_P(ClientsTestFixture, GetClientIDs) EXPECT_EQ(1, id_set.size()); if (id_set.size() > 0) { - eCAL::Registration::SQualityServiceInfo info; + eCAL::SServiceMethodInformation info; EXPECT_TRUE(eCAL::Registration::GetClientInfo(*id_set.begin(), info)); // check service/method names - EXPECT_EQ(service_method_info, info.info); + EXPECT_EQ(service_method_info, info); } } } @@ -318,4 +163,4 @@ INSTANTIATE_TEST_SUITE_P( return config; }() } ) -); \ No newline at end of file +); diff --git a/ecal/tests/cpp/registration_test_public/src/registration_getpublisherids.cpp b/ecal/tests/cpp/registration_test_public/src/registration_getpublisherids.cpp index 3243d01dd7..a46da4f16d 100644 --- a/ecal/tests/cpp/registration_test_public/src/registration_getpublisherids.cpp +++ b/ecal/tests/cpp/registration_test_public/src/registration_getpublisherids.cpp @@ -17,11 +17,14 @@ * ========================= eCAL LICENSE ================================= */ +#include #include #include #include +#include +#include #include #include diff --git a/ecal/tests/cpp/registration_test_public/src/registration_getservices.cpp b/ecal/tests/cpp/registration_test_public/src/registration_getservices.cpp index 2dbb9b4f3d..f66b4447ca 100644 --- a/ecal/tests/cpp/registration_test_public/src/registration_getservices.cpp +++ b/ecal/tests/cpp/registration_test_public/src/registration_getservices.cpp @@ -20,6 +20,9 @@ #include #include +#include +#include +#include enum { CMN_MONITORING_TIMEOUT_MS = (5000 + 100), @@ -41,7 +44,6 @@ class ServicesTestFixture : public ::testing::TestWithParam // set configuration from the test parameters auto params = GetParam(); eCAL::Initialize(params.configuration, "core_cpp_registration_public", eCAL::Init::All); - eCAL::Util::EnableLoopback(true); } void TearDown() override @@ -53,7 +55,7 @@ class ServicesTestFixture : public ::testing::TestWithParam TEST_P(ServicesTestFixture, ServiceExpiration) { - std::map service_info_map; + std::set id_set; // create simple service and let it expire { @@ -65,10 +67,10 @@ TEST_P(ServicesTestFixture, ServiceExpiration) eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); // get all services - eCAL::Registration::GetServices(service_info_map); + id_set = eCAL::Registration::GetServiceIDs(); // check size - EXPECT_EQ(service_info_map.size(), 1); + EXPECT_EQ(id_set.size(), 1); // check service/method names std::set service_method_names; @@ -84,10 +86,10 @@ TEST_P(ServicesTestFixture, ServiceExpiration) eCAL::Process::SleepMS(CMN_MONITORING_TIMEOUT_MS); // get all services again, service should not be expired - eCAL::Registration::GetServices(service_info_map); + id_set = eCAL::Registration::GetServiceIDs(); // check size - EXPECT_EQ(service_info_map.size(), 1); + EXPECT_EQ(id_set.size(), 1); } // let's unregister @@ -95,151 +97,10 @@ TEST_P(ServicesTestFixture, ServiceExpiration) // get all services again, all services // should be removed from the map - eCAL::Registration::GetServices(service_info_map); + id_set = eCAL::Registration::GetServiceIDs(); // check size - EXPECT_EQ(service_info_map.size(), 0); -} - -TEST_P(ServicesTestFixture, ServiceEqualQualities) -{ - std::map service_info_map; - - // create 2 services with the same quality of data type information - { - // create service 1 - eCAL::CServiceServer service1("foo::service"); - service1.AddDescription("foo::method", "foo::req_type1", "foo::req_desc1", "foo::resp_type1", "foo::resp_desc1"); - - // let's register - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // get all services - eCAL::Registration::GetServices(service_info_map); - - // check size - EXPECT_EQ(service_info_map.size(), 1); - - // check attributes - std::string req_type, resp_type; - std::string req_desc, resp_desc; - - eCAL::Registration::GetServiceTypeNames("foo::service", "foo::method", req_type, resp_type); - EXPECT_EQ(req_type, "foo::req_type1"); - EXPECT_EQ(resp_type, "foo::resp_type1"); - eCAL::Registration::GetServiceDescription("foo::service", "foo::method", req_desc, resp_desc); - EXPECT_EQ(req_desc, "foo::req_desc1"); - EXPECT_EQ(resp_desc, "foo::resp_desc1"); - - // create service 2 - // this will not overwrite the attributes from service 1, because the quality is not higher - eCAL::CServiceServer service2("foo::service"); - service2.AddDescription("foo::method", "foo::req_type2", "foo::req_desc2", "foo::resp_type2", "foo::resp_desc2"); - - // check attributes - eCAL::Registration::GetServiceTypeNames("foo::service", "foo::method", req_type, resp_type); - EXPECT_EQ(req_type, "foo::req_type1"); - EXPECT_EQ(resp_type, "foo::resp_type1"); - eCAL::Registration::GetServiceDescription("foo::service", "foo::method", req_desc, resp_desc); - EXPECT_EQ(req_desc, "foo::req_desc1"); - EXPECT_EQ(resp_desc, "foo::resp_desc1"); - - // check size it's service 1 only - EXPECT_EQ(service_info_map.size(), 1); - - // let's wait a monitoring timeout long - eCAL::Process::SleepMS(CMN_MONITORING_TIMEOUT_MS); - - // get all services again, services should not be expired - eCAL::Registration::GetServices(service_info_map); - - // check size - EXPECT_EQ(service_info_map.size(), 1); - - // destroy service 1 - service1.Destroy(); - - // let's register - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // check attributes, service 1 attributes should be replaced by service 2 attributes now - eCAL::Registration::GetServiceTypeNames("foo::service", "foo::method", req_type, resp_type); - EXPECT_EQ(req_type, "foo::req_type2"); - EXPECT_EQ(resp_type, "foo::resp_type2"); - eCAL::Registration::GetServiceDescription("foo::service", "foo::method", req_desc, resp_desc); - EXPECT_EQ(req_desc, "foo::req_desc2"); - EXPECT_EQ(resp_desc, "foo::resp_desc2"); - } - - // let's unregister - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // get all services again, all services - // should be removed from the map - eCAL::Registration::GetServices(service_info_map); - - // check size - EXPECT_EQ(service_info_map.size(), 0); -} - -TEST_P(ServicesTestFixture, ServiceDifferentQualities) -{ - std::map service_info_map; - - // create 2 services with different qualities of data type information - { - // create service 1, response type name and response description are missing - eCAL::CServiceServer service1("foo::service"); - service1.AddDescription("foo::method", "foo::req_type1", "foo::req_desc1", "", ""); - - // let's register - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // get all services - eCAL::Registration::GetServices(service_info_map); - - // check size - EXPECT_EQ(service_info_map.size(), 1); - - // check attributes - std::string req_type, resp_type; - std::string req_desc, resp_desc; - - eCAL::Registration::GetServiceTypeNames("foo::service", "foo::method", req_type, resp_type); - EXPECT_EQ(req_type, "foo::req_type1"); - EXPECT_EQ(resp_type, ""); - eCAL::Registration::GetServiceDescription("foo::service", "foo::method", req_desc, resp_desc); - EXPECT_EQ(req_desc, "foo::req_desc1"); - EXPECT_EQ(resp_desc, ""); - - // create service 2, with higher quality than service 1 - eCAL::CServiceServer service2("foo::service"); - service2.AddDescription("foo::method", "foo::req_type2", "foo::req_desc2", "foo::resp_type2", "foo::resp_desc2"); - - // let's register - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // check attributes, we expect attributes from service 2 here - eCAL::Registration::GetServiceTypeNames("foo::service", "foo::method", req_type, resp_type); - EXPECT_EQ(req_type, "foo::req_type2"); - EXPECT_EQ(resp_type, "foo::resp_type2"); - eCAL::Registration::GetServiceDescription("foo::service", "foo::method", req_desc, resp_desc); - EXPECT_EQ(req_desc, "foo::req_desc2"); - EXPECT_EQ(resp_desc, "foo::resp_desc2"); - - // check size it's service 2 only - EXPECT_EQ(service_info_map.size(), 1); - } - - // let's unregister - eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - - // get all services again, all services - // should be removed from the map - eCAL::Registration::GetServices(service_info_map); - - // check size - EXPECT_EQ(service_info_map.size(), 0); + EXPECT_EQ(id_set.size(), 0); } TEST_P(ServicesTestFixture, GetServiceIDs) @@ -270,16 +131,15 @@ TEST_P(ServicesTestFixture, GetServiceIDs) EXPECT_EQ(1, id_set.size()); if (id_set.size() > 0) { - eCAL::Registration::SQualityServiceInfo info; + eCAL::SServiceMethodInformation info; EXPECT_TRUE(eCAL::Registration::GetServiceInfo(*id_set.begin(), info)); // check service/method names - EXPECT_EQ(service_method_info, info.info); + EXPECT_EQ(service_method_info, info); } } } - INSTANTIATE_TEST_SUITE_P( core_cpp_registration_public_services, ServicesTestFixture, @@ -307,4 +167,4 @@ INSTANTIATE_TEST_SUITE_P( return config; }() } ) -); \ No newline at end of file +); diff --git a/ecal/tests/cpp/registration_test_public/src/registration_getsubscriberids.cpp b/ecal/tests/cpp/registration_test_public/src/registration_getsubscriberids.cpp index ef73cc481b..7a40082afe 100644 --- a/ecal/tests/cpp/registration_test_public/src/registration_getsubscriberids.cpp +++ b/ecal/tests/cpp/registration_test_public/src/registration_getsubscriberids.cpp @@ -17,11 +17,14 @@ * ========================= eCAL LICENSE ================================= */ +#include #include #include #include +#include +#include #include #include diff --git a/ecal/tests/cpp/registration_test_public/src/registration_gettopics.cpp b/ecal/tests/cpp/registration_test_public/src/registration_gettopics.cpp index f88db3801e..bb4d4869e7 100644 --- a/ecal/tests/cpp/registration_test_public/src/registration_gettopics.cpp +++ b/ecal/tests/cpp/registration_test_public/src/registration_gettopics.cpp @@ -17,13 +17,16 @@ * ========================= eCAL LICENSE ================================= */ +#include #include #include #include #include +#include #include +#include #include enum { @@ -34,22 +37,18 @@ enum { TEST(core_cpp_registration_public, GetTopics) { // initialize eCAL API - eCAL::Initialize(0, nullptr, "core_cpp_registration_public"); + eCAL::Initialize("core_cpp_registration_public"); - // enable loop back communication in the same process - eCAL::Util::EnableLoopback(true); - - std::map topic_info_map; + std::set topic_id_pub_set; + std::set topic_id_sub_set; // create and check a few pub/sub entities { eCAL::SDataTypeInformation info_A1 { "typeA1" ,"", "descA1" }; - eCAL::SDataTypeInformation info_A1_2{ "typeA1.2","", "descA1.2" }; eCAL::SDataTypeInformation info_A2 { "typeA2" ,"", "descA2" }; eCAL::SDataTypeInformation info_A3 { "typeA3" ,"", "descA3" }; eCAL::SDataTypeInformation info_B1 { "typeB1" ,"", "descB1" }; - eCAL::SDataTypeInformation info_B1_2{ "typeB1.2","", "descB1.2" }; eCAL::SDataTypeInformation info_B2 { "typeB2" ,"", "descB2" }; // create 3 publisher @@ -57,44 +56,49 @@ TEST(core_cpp_registration_public, GetTopics) eCAL::CPublisher pub2("A2", info_A2); eCAL::CPublisher pub3("A3", info_A3); - // create a missmatching publisher - // this should trigger a warning but not increase map size - eCAL::CPublisher pub12("A1", info_A1_2); - // create 2 subscriber eCAL::CSubscriber sub1("B1", info_B1); eCAL::CSubscriber sub2("B2", info_B2); - // create a missmatching subscriber - // this should trigger a warning but not increase map size - eCAL::CSubscriber sub12("B1", info_B1_2); - // let's register eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - // get all topics - eCAL::Registration::GetTopics(topic_info_map); + // get all publisher topics and check size + topic_id_pub_set = eCAL::Registration::GetPublisherIDs(); + EXPECT_EQ(topic_id_pub_set.size(), 3); + + // check publisher types and descriptions + for (auto& topic_id_pub : topic_id_pub_set) + { + eCAL::SDataTypeInformation registration_topic_info; + eCAL::Registration::GetPublisherInfo(topic_id_pub, registration_topic_info); + eCAL::SDataTypeInformation expected_topic_info{ "type" + topic_id_pub.topic_name, "", "desc" + topic_id_pub.topic_name }; + EXPECT_EQ(registration_topic_info, expected_topic_info); + } - // check size - EXPECT_EQ(topic_info_map.size(), 5); + // get all subscriber topics and check size + topic_id_sub_set = eCAL::Registration::GetSubscriberIDs(); + EXPECT_EQ(topic_id_sub_set.size(), 2); - // check types and descriptions - for (auto& topic_info : topic_info_map) + // check subscriber types and descriptions + for (auto& topic_id_sub : topic_id_sub_set) { eCAL::SDataTypeInformation registration_topic_info; - eCAL::Registration::GetTopicDataTypeInformation(topic_info.first, registration_topic_info); - eCAL::SDataTypeInformation expected_topic_info{ "type" + topic_info.first, "", "desc" + topic_info.first }; + eCAL::Registration::GetSubscriberInfo(topic_id_sub, registration_topic_info); + eCAL::SDataTypeInformation expected_topic_info{ "type" + topic_id_sub.topic_name, "", "desc" + topic_id_sub.topic_name }; EXPECT_EQ(registration_topic_info, expected_topic_info); } // wait a monitoring timeout long, eCAL::Process::SleepMS(CMN_MONITORING_TIMEOUT_MS); - // the topics should not be expired - eCAL::Registration::GetTopics(topic_info_map); + // get all publisher topics and check size (should not be expired) + topic_id_pub_set = eCAL::Registration::GetPublisherIDs(); + EXPECT_EQ(topic_id_pub_set.size(), 3); - // check size - EXPECT_EQ(topic_info_map.size(), 5); + // get all subscriber topics and check size (should not be expired) + topic_id_sub_set = eCAL::Registration::GetSubscriberIDs(); + EXPECT_EQ(topic_id_sub_set.size(), 2); // now destroy publisher pub1 and subscriber sub1 // the entities pub12 and sub12 should replace them @@ -105,31 +109,25 @@ TEST(core_cpp_registration_public, GetTopics) // let's register eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - // size should be 5 again (because of pub12 and sub12 should have replaced pub1 and sub1 attributes now) - EXPECT_EQ(topic_info_map.size(), 5); + // get all publisher topics and check size (pub1 should be expired) + topic_id_pub_set = eCAL::Registration::GetPublisherIDs(); + EXPECT_EQ(topic_id_pub_set.size(), 2); - // check overwritten attributes - { - eCAL::SDataTypeInformation registration_topic_info; - EXPECT_EQ(true, eCAL::Registration::GetTopicDataTypeInformation("A1", registration_topic_info)); - EXPECT_EQ(registration_topic_info, info_A1_2); - } - { - eCAL::SDataTypeInformation registration_topic_info; - EXPECT_EQ(true, eCAL::Registration::GetTopicDataTypeInformation("B1", registration_topic_info)); - EXPECT_EQ(registration_topic_info, info_B1_2); - } + // get all subscriber topics and check size (sub1 should be expired) + topic_id_sub_set = eCAL::Registration::GetSubscriberIDs(); + EXPECT_EQ(topic_id_sub_set.size(), 1); } // let's unregister eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); - // get all topics again, now all topics - // should be removed from the map - eCAL::Registration::GetTopics(topic_info_map); + // get all publisher topics and check size (all publisher should be expired) + topic_id_pub_set = eCAL::Registration::GetPublisherIDs(); + EXPECT_EQ(topic_id_pub_set.size(), 0); - // check size - EXPECT_EQ(topic_info_map.size(), 0); + // get all subscriber topics and check size (all subscriber should be expired) + topic_id_sub_set = eCAL::Registration::GetSubscriberIDs(); + EXPECT_EQ(topic_id_sub_set.size(), 0); // finalize eCAL API eCAL::Finalize(); @@ -147,10 +145,7 @@ TEST(core_cpp_registration_public, GetTopicsParallel) std::atomic testing_completed{ false }; // initialize eCAL API - eCAL::Initialize(0, nullptr, "core_cpp_registration_public"); - - // enable loop back communication in the same process - eCAL::Util::EnableLoopback(true); + eCAL::Initialize("core_cpp_registration_public"); auto create_publishers = [&]() { std::string topic_name = "Test.ParallelUtilFunctions"; @@ -172,11 +167,11 @@ TEST(core_cpp_registration_public, GetTopicsParallel) size_t max_number_publishers_seen = 0; std::set tmp_topic_names; - std::map topics; + std::set tmp_topic_ids; do { eCAL::Registration::GetTopicNames(tmp_topic_names); - eCAL::Registration::GetTopics(topics); + tmp_topic_ids = eCAL::Registration::GetPublisherIDs(); number_publishers_seen = tmp_topic_names.size(); max_number_publishers_seen = std::max(max_number_publishers_seen, number_publishers_seen); diff --git a/ecal/tests/cpp/serialization_test/src/common_generate.cpp b/ecal/tests/cpp/serialization_test/src/common_generate.cpp index e81fdfd610..74daa23da7 100644 --- a/ecal/tests/cpp/serialization_test/src/common_generate.cpp +++ b/ecal/tests/cpp/serialization_test/src/common_generate.cpp @@ -20,6 +20,8 @@ #include "common_generate.h" #include +#include +#include namespace eCAL { diff --git a/ecal/tests/cpp/serialization_test/src/logging_serialization_test.cpp b/ecal/tests/cpp/serialization_test/src/logging_serialization_test.cpp index c9587b0d52..0bbe501dac 100644 --- a/ecal/tests/cpp/serialization_test/src/logging_serialization_test.cpp +++ b/ecal/tests/cpp/serialization_test/src/logging_serialization_test.cpp @@ -17,12 +17,15 @@ * ========================= eCAL LICENSE ================================= */ +#include #include #include "logging_generate.h" #include "logging_compare.h" #include +#include +#include namespace eCAL { diff --git a/ecal/tests/cpp/serialization_test/src/monitoring_compare.cpp b/ecal/tests/cpp/serialization_test/src/monitoring_compare.cpp index 74f5c61021..a0f3a0c846 100644 --- a/ecal/tests/cpp/serialization_test/src/monitoring_compare.cpp +++ b/ecal/tests/cpp/serialization_test/src/monitoring_compare.cpp @@ -19,6 +19,7 @@ #include "monitoring_compare.h" +#include #include namespace eCAL diff --git a/ecal/tests/cpp/serialization_test/src/monitoring_generate.cpp b/ecal/tests/cpp/serialization_test/src/monitoring_generate.cpp index e2c4aff2d8..34970abac0 100644 --- a/ecal/tests/cpp/serialization_test/src/monitoring_generate.cpp +++ b/ecal/tests/cpp/serialization_test/src/monitoring_generate.cpp @@ -21,6 +21,7 @@ #include "common_generate.h" #include +#include namespace eCAL { diff --git a/ecal/tests/cpp/serialization_test/src/monitoring_serialization_test.cpp b/ecal/tests/cpp/serialization_test/src/monitoring_serialization_test.cpp index eb6f071fb2..346df841cb 100644 --- a/ecal/tests/cpp/serialization_test/src/monitoring_serialization_test.cpp +++ b/ecal/tests/cpp/serialization_test/src/monitoring_serialization_test.cpp @@ -22,6 +22,7 @@ #include "monitoring_compare.h" #include +#include namespace eCAL { diff --git a/ecal/tests/cpp/serialization_test/src/parallel_serialization_test.cpp b/ecal/tests/cpp/serialization_test/src/parallel_serialization_test.cpp index ccfd289f89..8647e7899d 100644 --- a/ecal/tests/cpp/serialization_test/src/parallel_serialization_test.cpp +++ b/ecal/tests/cpp/serialization_test/src/parallel_serialization_test.cpp @@ -24,6 +24,7 @@ #include "logging_generate.h" #include +#include #include diff --git a/ecal/tests/cpp/serialization_test/src/payload_compare.cpp b/ecal/tests/cpp/serialization_test/src/payload_compare.cpp index 50266d51e3..d886ee1a74 100644 --- a/ecal/tests/cpp/serialization_test/src/payload_compare.cpp +++ b/ecal/tests/cpp/serialization_test/src/payload_compare.cpp @@ -20,6 +20,7 @@ #include "payload_compare.h" #include +#include namespace eCAL { diff --git a/ecal/tests/cpp/serialization_test/src/payload_generate.cpp b/ecal/tests/cpp/serialization_test/src/payload_generate.cpp index 45ed68970b..3930bdfb91 100644 --- a/ecal/tests/cpp/serialization_test/src/payload_generate.cpp +++ b/ecal/tests/cpp/serialization_test/src/payload_generate.cpp @@ -22,6 +22,7 @@ #include #include +#include namespace eCAL { diff --git a/ecal/tests/cpp/serialization_test/src/payload_serialization_test.cpp b/ecal/tests/cpp/serialization_test/src/payload_serialization_test.cpp index dc9d4519ef..338daa6fab 100644 --- a/ecal/tests/cpp/serialization_test/src/payload_serialization_test.cpp +++ b/ecal/tests/cpp/serialization_test/src/payload_serialization_test.cpp @@ -17,6 +17,7 @@ * ========================= eCAL LICENSE ================================= */ +#include #include #include "payload_generate.h" @@ -24,6 +25,8 @@ #include #include +#include +#include namespace { diff --git a/ecal/tests/cpp/serialization_test/src/registration_serialization_test.cpp b/ecal/tests/cpp/serialization_test/src/registration_serialization_test.cpp index f184dc08e4..60f886fb30 100644 --- a/ecal/tests/cpp/serialization_test/src/registration_serialization_test.cpp +++ b/ecal/tests/cpp/serialization_test/src/registration_serialization_test.cpp @@ -21,6 +21,8 @@ #include "registration_generate.h" #include +#include +#include namespace eCAL { diff --git a/ecal/tests/cpp/serialization_test/src/service_serialization_test.cpp b/ecal/tests/cpp/serialization_test/src/service_serialization_test.cpp index f44896b6c8..a7b26cf3ac 100644 --- a/ecal/tests/cpp/serialization_test/src/service_serialization_test.cpp +++ b/ecal/tests/cpp/serialization_test/src/service_serialization_test.cpp @@ -22,6 +22,7 @@ #include "service_generate.h" #include +#include namespace eCAL { diff --git a/ecal/tests/cpp/topic2mcast_test/src/topic2mcast_test.cpp b/ecal/tests/cpp/topic2mcast_test/src/topic2mcast_test.cpp index 87d4530e98..1521972f5e 100644 --- a/ecal/tests/cpp/topic2mcast_test/src/topic2mcast_test.cpp +++ b/ecal/tests/cpp/topic2mcast_test/src/topic2mcast_test.cpp @@ -17,13 +17,16 @@ * ========================= eCAL LICENSE ================================= */ -#include #include "io/udp/ecal_udp_topic2mcast.h" +#include +#include +#include #include -#include #include +#include +#include struct IP { diff --git a/ecal/tests/cpp/util_test/src/expanding_vector_test.cpp b/ecal/tests/cpp/util_test/src/expanding_vector_test.cpp index 4e47541729..19c926f798 100644 --- a/ecal/tests/cpp/util_test/src/expanding_vector_test.cpp +++ b/ecal/tests/cpp/util_test/src/expanding_vector_test.cpp @@ -1,5 +1,8 @@ -#include #include "util/expanding_vector.h" // Assuming the class is defined in this header file +#include +#include +#include +#include using namespace eCAL::Util; diff --git a/ecal/tests/cpp/util_test/src/util_test.cpp b/ecal/tests/cpp/util_test/src/util_test.cpp index 5936dbf459..af4a14cd66 100644 --- a/ecal/tests/cpp/util_test/src/util_test.cpp +++ b/ecal/tests/cpp/util_test/src/util_test.cpp @@ -17,7 +17,9 @@ * ========================= eCAL LICENSE ================================= */ +#include #include +#include #include #include diff --git a/lang/csharp/Continental.eCAL.Core.Test/test.cs b/lang/csharp/Continental.eCAL.Core.Test/test.cs index 43ba740675..24d79698b2 100644 --- a/lang/csharp/Continental.eCAL.Core.Test/test.cs +++ b/lang/csharp/Continental.eCAL.Core.Test/test.cs @@ -30,7 +30,6 @@ public class eCALBinaryTest public void Initialize() { Continental.eCAL.Core.Util.Initialize("Binary Test C#"); - Continental.eCAL.Core.Util.EnableLoopback(true); } [TestCleanup] diff --git a/lang/csharp/Continental.eCAL.Core/ecal_clr.cpp b/lang/csharp/Continental.eCAL.Core/ecal_clr.cpp index 8c65821002..80aeece79a 100644 --- a/lang/csharp/Continental.eCAL.Core/ecal_clr.cpp +++ b/lang/csharp/Continental.eCAL.Core/ecal_clr.cpp @@ -68,7 +68,7 @@ array^ StlStringToByteArray(const std::string& string_) ///////////////////////////////////////////////////////////////////////////// void Util::Initialize(System::String^ task_name_) { - ::eCAL::Initialize(0, nullptr, StringToStlString(task_name_).c_str()); + ::eCAL::Initialize(StringToStlString(task_name_)); } void Util::Terminate() @@ -100,17 +100,6 @@ void Util::ShutdownProcesses() ::eCAL::Util::ShutdownProcesses(); } -void Util::ShutdownCore() -{ - ::eCAL::Util::ShutdownCore(); -} - -void Util::EnableLoopback(bool state_) -{ - ::eCAL::Util::EnableLoopback(state_); -} - - ///////////////////////////////////////////////////////////////////////////// // Logger ///////////////////////////////////////////////////////////////////////////// @@ -524,7 +513,7 @@ List^ ServiceClient::Call(System::Str ///////////////////////////////////////////////////////////////////////////// void Monitoring::Initialize() { - ::eCAL::Initialize(0, nullptr, "", ::eCAL::Init::Monitoring); + ::eCAL::Initialize("", ::eCAL::Init::Monitoring); } void Monitoring::Terminate() diff --git a/lang/csharp/Continental.eCAL.Core/ecal_clr.h b/lang/csharp/Continental.eCAL.Core/ecal_clr.h index e1801f0fe0..a272b65238 100644 --- a/lang/csharp/Continental.eCAL.Core/ecal_clr.h +++ b/lang/csharp/Continental.eCAL.Core/ecal_clr.h @@ -79,21 +79,6 @@ namespace Continental * @brief Send shutdown event to all user processes. **/ static void ShutdownProcesses(); - - /** - * @brief Send shutdown event to all core components. - * - **/ - static void ShutdownCore(); - - /** - * @brief Enable eCAL message loop back, - * that means subscriber will receive messages from - * publishers of the same process (default == false). - * - * @param state_ Switch on message loop back. - **/ - static void EnableLoopback(bool state_); }; diff --git a/lang/csharp/Continental.eCAL.Protobuf.Test/test.cs b/lang/csharp/Continental.eCAL.Protobuf.Test/test.cs index 04ebc9ae4b..3432b26697 100644 --- a/lang/csharp/Continental.eCAL.Protobuf.Test/test.cs +++ b/lang/csharp/Continental.eCAL.Protobuf.Test/test.cs @@ -31,7 +31,6 @@ public class ProtobufTest public void Initialize() { Util.Initialize("Person Test C#"); - Util.EnableLoopback(true); } [TestCleanup] diff --git a/lang/python/core/ecal/core/core.py b/lang/python/core/ecal/core/core.py index 2731044aa0..990e7f37c9 100644 --- a/lang/python/core/ecal/core/core.py +++ b/lang/python/core/ecal/core/core.py @@ -1,6 +1,6 @@ # ========================= eCAL LICENSE ================================= # -# Copyright (C) 2016 - 2019 Continental Corporation +# Copyright (C) 2016 - 2024 Continental Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -33,7 +33,17 @@ def initialize(args, unit_name): :type unit_name: string """ - return _ecal.initialize(args, unit_name) + print("[WARNING] 'initialize(args, unit_name)' is deprecated. Please use 'initialize(argv, unit_name)' instead.") + return initialize(unit_name) + +def initialize(unit_name): + """ initialize eCAL API + + :param unit_name: instance unit name + :type unit_name: string + + """ + return _ecal.initialize(unit_name) def finalize(): @@ -126,19 +136,9 @@ def shutdown_processes(): def shutdown_core(): - """ shutdown ecal core components + """ shutdown ecal core components (deprecated) """ - return _ecal.shutdown_core() - - -def enable_loopback(state): - """ enable ecal message loopback - - :param state: switch on ecal message loop back (default 0) - :type state: int - - """ - return _ecal.enable_loopback(state) + return _ecal.shutdown_processes() def log_setlevel(level): diff --git a/lang/python/core/src/ecal_clang.cpp b/lang/python/core/src/ecal_clang.cpp index c195307b86..a1e73e3a02 100644 --- a/lang/python/core/src/ecal_clang.cpp +++ b/lang/python/core/src/ecal_clang.cpp @@ -31,14 +31,39 @@ #include #include -static char* str_malloc(const std::string& buf_s_) +namespace { - void* cbuf = malloc(buf_s_.size()); - if(cbuf != nullptr) + char* str_malloc(const std::string& buf_s_) { - memcpy(cbuf, buf_s_.data(), buf_s_.size()); + void* cbuf = malloc(buf_s_.size()); + if (cbuf != nullptr) + { + memcpy(cbuf, buf_s_.data(), buf_s_.size()); + } + return(static_cast(cbuf)); + } + + bool GetTopicDataTypeInformation(const char* topic_name_, eCAL::SDataTypeInformation& topic_info_) + { + // try to find topic name in publisher set + for (const auto& pub_id : eCAL::Registration::GetPublisherIDs()) + { + if (pub_id.topic_name == topic_name_) + { + return eCAL::Registration::GetPublisherInfo(pub_id, topic_info_); + } + } + // try to find topic name in subscriber set + const auto& sub_ids = eCAL::Registration::GetSubscriberIDs(); + for (const auto& sub_id : sub_ids) + { + if (sub_id.topic_name == topic_name_) + { + return eCAL::Registration::GetSubscriberInfo(sub_id, topic_info_); + } + } + return false; } - return(static_cast(cbuf)); } /****************************************/ @@ -54,7 +79,12 @@ const char* ecal_getversion() /****************************************/ int ecal_getversion_components(int* major_, int* minor_, int* patch_) { - return eCAL::GetVersion(major_, minor_, patch_); + if ((major_ == nullptr) || (minor_ == nullptr) || (patch_ == nullptr) ) + return 0; + *major_ = eCAL::GetVersion().major; + *minor_ = eCAL::GetVersion().minor; + *minor_ = eCAL::GetVersion().patch; + return 1; } /****************************************/ @@ -68,9 +98,10 @@ const char* ecal_getdate() /****************************************/ /* ecal_initialize */ /****************************************/ -int ecal_initialize(int argc_, char **argv_, const char* unit_name_) +int ecal_initialize(const char* unit_name_) { - return(eCAL::Initialize(argc_, argv_, unit_name_)); + std::string unit_name = (unit_name_ != nullptr) ? std::string(unit_name_) : std::string(""); + return(eCAL::Initialize(unit_name)); } /****************************************/ @@ -155,29 +186,14 @@ void ecal_shutdown_processes() eCAL::Util::ShutdownProcesses(); } -/****************************************/ -/* ecal_shutdown_core */ -/****************************************/ -void ecal_shutdown_core() -{ - eCAL::Util::ShutdownCore(); -} - -/****************************************/ -/* ecal_enable_loopback */ -/****************************************/ -void ecal_enable_loopback(const int state_) -{ - eCAL::Util::EnableLoopback(state_ != 0); -} - /****************************************/ /* get_type_name */ /****************************************/ bool ecal_get_type_name(const char* topic_name_, const char** topic_type_, int* topic_type_len_) { eCAL::SDataTypeInformation topic_info; - bool ret = eCAL::Registration::GetTopicDataTypeInformation(topic_name_, topic_info); + // get the first matching topic type information for the given topic name found in either the publisher or subscriber id set ! + bool ret = GetTopicDataTypeInformation(topic_name_, topic_info); if(ret) { std::string topic_type_s = topic_info.name; @@ -205,7 +221,8 @@ bool ecal_get_type_name(const char* topic_name_, const char** topic_type_, int* bool ecal_get_type_encoding(const char* topic_name_, const char** topic_encoding_, int* topic_encoding_len_) { eCAL::SDataTypeInformation topic_info; - bool ret = eCAL::Registration::GetTopicDataTypeInformation(topic_name_, topic_info); + // get the first matching topic type information for the given topic name found in either the publisher or subscriber id set ! + bool ret = GetTopicDataTypeInformation(topic_name_, topic_info); if (ret) { std::string topic_encoding_s = topic_info.encoding; @@ -233,7 +250,8 @@ bool ecal_get_type_encoding(const char* topic_name_, const char** topic_encoding bool ecal_get_description(const char* topic_name_, const char** topic_desc_, int* topic_desc_len_) { eCAL::SDataTypeInformation topic_info; - bool ret = eCAL::Registration::GetTopicDataTypeInformation(topic_name_, topic_info); + // get the first matching topic type information for the given topic name found in either the publisher or subscriber id set ! + bool ret = GetTopicDataTypeInformation(topic_name_, topic_info); if(ret) { std::string topic_desc_s = topic_info.descriptor; @@ -711,7 +729,7 @@ bool client_call_method_async(ECAL_HANDLE handle_, const char* method_name_, con /****************************************/ int mon_initialize() { - return(eCAL::Initialize(0, nullptr, "", eCAL::Init::Monitoring)); + return(eCAL::Initialize("", eCAL::Init::Monitoring)); } /****************************************/ diff --git a/lang/python/core/src/ecal_clang.h b/lang/python/core/src/ecal_clang.h index 10b8f6734e..a42fd52f05 100644 --- a/lang/python/core/src/ecal_clang.h +++ b/lang/python/core/src/ecal_clang.h @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ const char* ecal_getdate(); * * @return Zero if succeeded, 1 if already initialized, -1 if failed. **/ -int ecal_initialize(int argc_, char **argv_, const char* unit_name_); +int ecal_initialize(const char* unit_name_); /** * @brief Finalize eCAL API. @@ -157,20 +157,6 @@ void ecal_shutdown_process_id(int process_id_); **/ void ecal_shutdown_processes(); -/** - * @brief Send shutdown event to all local core components. -**/ -void ecal_shutdown_core(); - -/** - * @brief Enable eCAL message loop back, - * that means subscriber will receive messages from - * publishers of the same process (default == false). - * - * @param state_ Switch on message loop back.. -**/ -void ecal_enable_loopback(int state_); - /** * @brief Gets type name of the specified topic. * diff --git a/lang/python/core/src/ecal_wrap.cxx b/lang/python/core/src/ecal_wrap.cxx index 21a1a0ead1..56e00d5698 100644 --- a/lang/python/core/src/ecal_wrap.cxx +++ b/lang/python/core/src/ecal_wrap.cxx @@ -79,41 +79,17 @@ PyObject* PyAnswerHandle(ECAL_HANDLE handle_) /****************************************/ PyObject* initialize(PyObject* /*self*/, PyObject* args) { - PyObject* unit_args; /* python list of command line arguments */ - char* unit_name = nullptr; /* unit name */ - if (!PyArg_ParseTuple(args, "O!s", &PyList_Type, &unit_args, &unit_name)) + char* unit_name = nullptr; + if (!PyArg_ParseTuple(args, "s", &unit_name)) return nullptr; - std::vector arg_vec_p; - int arg_num = (int)(PyList_Size(unit_args)); - for (int i = 0; i < arg_num; ++i) - { - /* grab the string object from the next element of the list */ - PyObject* arg_str = PyList_GetItem(unit_args, i); - - /* make it a string */ - PyObject* arg_ustr = PyUnicode_AsUTF8String(arg_str); - std::string arg = PyBytes_AsString(arg_ustr); - - /* and put it into the argument vector */ -#ifdef _WIN32 - arg_vec_p.push_back(_strdup(arg.c_str())); -#else - arg_vec_p.push_back(strdup(arg.c_str())); -#endif // _WIN32 - } - - /* pass arguments to the initialize function */ + /* pass argument to the initialize function */ int init{ 0 }; Py_BEGIN_ALLOW_THREADS - init = ecal_initialize(int(arg_vec_p.size()), arg_vec_p.data(), unit_name); + init = ecal_initialize(unit_name); Py_END_ALLOW_THREADS - PyObject* ret_obj = Py_BuildValue("i", init); - - /* free argument vector */ - for(auto arg : arg_vec_p) free(arg); - return(ret_obj); + return(Py_BuildValue("i", init)); } /****************************************/ @@ -251,32 +227,6 @@ PyObject* shutdown_processes(PyObject* /*self*/, PyObject* /*args*/) Py_RETURN_NONE; } -/****************************************/ -/* shutdown_core */ -/****************************************/ -PyObject* shutdown_core(PyObject* /*self*/, PyObject* /*args*/) -{ - ecal_shutdown_core(); - - Py_RETURN_NONE; -} - -/****************************************/ -/* enable_loopback */ -/****************************************/ -PyObject* enable_loopback(PyObject* /*self*/, PyObject* args) -{ - int state = 0; - - if (!PyArg_ParseTuple(args, "i", &state)) - return nullptr; - - ecal_enable_loopback(state); - - Py_RETURN_NONE; -} - - /****************************************/ /* log_setlevel */ /****************************************/ @@ -1357,7 +1307,7 @@ PyObject* mon_logging(PyObject* /*self*/, PyObject* /*args*/) /****************************************/ static PyMethodDef _ecal_methods[] = { - {"initialize", initialize, METH_VARARGS, "initialize(argv, unit_name)"}, + {"initialize", initialize, METH_VARARGS, "initialize(unit_name)"}, {"finalize", finalize, METH_NOARGS, "finalize()"}, {"is_initialized", is_initialized, METH_NOARGS, "is_initialized()"}, {"set_unit_name", set_unit_name, METH_VARARGS, "set_unit_name(unit_name)"}, @@ -1371,8 +1321,6 @@ static PyMethodDef _ecal_methods[] = {"ok", ok, METH_NOARGS, "ok()"}, {"shutdown_process_uname", shutdown_process_uname, METH_VARARGS, "shutdown_process_uname(unit_name)"}, {"shutdown_processes", shutdown_processes, METH_NOARGS, "shutdown_processes()"}, - {"shutdown_core", shutdown_core, METH_NOARGS, "shutdown_core()"}, - {"enable_loopback", enable_loopback, METH_VARARGS, "enable_loopback(state)"}, {"log_setlevel", log_setlevel, METH_VARARGS, "log_setlevel(level)"}, {"log_message", log_message, METH_VARARGS, "log_message(message)"}, diff --git a/lang/python/ecalhdf5/src/ecalhdf5_wrap.cxx b/lang/python/ecalhdf5/src/ecalhdf5_wrap.cxx index 17da3f73d7..14901be703 100644 --- a/lang/python/ecalhdf5/src/ecalhdf5_wrap.cxx +++ b/lang/python/ecalhdf5/src/ecalhdf5_wrap.cxx @@ -39,7 +39,7 @@ typedef struct { PyObject_HEAD - eCAL::eh5::HDF5Meas *hdf5_meas; + eCAL::eh5::v2::HDF5Meas *hdf5_meas; } Meas; /****************************************/ @@ -52,7 +52,7 @@ static PyObject* Meas_New(PyTypeObject *type, PyObject* /*args*/, PyObject* /*kw self = (Meas *)type->tp_alloc(type, 0); if (self != NULL) { - self->hdf5_meas = new eCAL::eh5::HDF5Meas(); + self->hdf5_meas = new eCAL::eh5::v2::HDF5Meas(); } return (PyObject *)self; @@ -107,11 +107,11 @@ static PyObject* Meas_Open(Meas *self, PyObject *args) switch (access) { case 0: - open_meas = self->hdf5_meas->Open(path, eCAL::experimental::measurement::base::AccessType::RDONLY); + open_meas = self->hdf5_meas->Open(path, eCAL::eh5::v2::RDONLY); break; case 1: - open_meas = self->hdf5_meas->Open(path, eCAL::experimental::measurement::base::AccessType::CREATE); + open_meas = self->hdf5_meas->Open(path, eCAL::eh5::v2::CREATE); break; default: diff --git a/lang/python/samples/core/benchmark/latency_rec.py b/lang/python/samples/core/benchmark/latency_rec.py index 04abff4973..1058b615ff 100644 --- a/lang/python/samples/core/benchmark/latency_rec.py +++ b/lang/python/samples/core/benchmark/latency_rec.py @@ -24,7 +24,7 @@ def do_run(): # initialize eCAL API - ecal_core.initialize(sys.argv, "py_latency_rec") + ecal_core.initialize("py_latency_rec") # create publisher/subscriber pub = ecal_core.publisher('pkg_reply') diff --git a/lang/python/samples/core/benchmark/latency_rec_cb.py b/lang/python/samples/core/benchmark/latency_rec_cb.py index c7916c1135..3e074fb654 100644 --- a/lang/python/samples/core/benchmark/latency_rec_cb.py +++ b/lang/python/samples/core/benchmark/latency_rec_cb.py @@ -25,7 +25,7 @@ def do_run(): # initialize eCAL API - ecal_core.initialize(sys.argv, "py_latency_rec_cb") + ecal_core.initialize("py_latency_rec_cb") # create publisher/subscriber pub = ecal_core.publisher('pkg_reply') diff --git a/lang/python/samples/core/benchmark/latency_snd.py b/lang/python/samples/core/benchmark/latency_snd.py index c024f0810c..66abd32981 100644 --- a/lang/python/samples/core/benchmark/latency_snd.py +++ b/lang/python/samples/core/benchmark/latency_snd.py @@ -80,7 +80,7 @@ def do_run(msg_num, msg_size): if __name__ == "__main__": # initialize eCAL API - ecal_core.initialize([], "py_latency_snd") + ecal_core.initialize("py_latency_snd") args = parse_args(sys.argv[1:]) do_run(msg_num=args.runs, msg_size=args.size) diff --git a/lang/python/samples/core/monitoring/monitoring.py b/lang/python/samples/core/monitoring/monitoring.py index 93021b5b1c..a4b3259e9a 100644 --- a/lang/python/samples/core/monitoring/monitoring.py +++ b/lang/python/samples/core/monitoring/monitoring.py @@ -27,7 +27,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(), ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "monitoring") + ecal_core.initialize("monitoring") # initialize eCAL monitoring API ecal_core.mon_initialize() diff --git a/lang/python/samples/core/monitoring/monitoring_json.py b/lang/python/samples/core/monitoring/monitoring_json.py index 6143e9c167..9e55221da0 100644 --- a/lang/python/samples/core/monitoring/monitoring_json.py +++ b/lang/python/samples/core/monitoring/monitoring_json.py @@ -77,7 +77,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(), ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "monitoring") + ecal_core.initialize("monitoring") # initialize eCAL monitoring API ecal_core.mon_initialize() diff --git a/lang/python/samples/core/pubsub/binary_rec.py b/lang/python/samples/core/pubsub/binary_rec.py index 8e2041b0b9..3f4830781e 100644 --- a/lang/python/samples/core/pubsub/binary_rec.py +++ b/lang/python/samples/core/pubsub/binary_rec.py @@ -26,7 +26,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(), ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "py_binary_rec") + ecal_core.initialize("py_binary_rec") # set process state ecal_core.set_process_state(1, 1, "I feel good") diff --git a/lang/python/samples/core/pubsub/binary_rec_cb.py b/lang/python/samples/core/pubsub/binary_rec_cb.py index 546c8cc1c2..53b6c9869c 100644 --- a/lang/python/samples/core/pubsub/binary_rec_cb.py +++ b/lang/python/samples/core/pubsub/binary_rec_cb.py @@ -31,7 +31,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(), ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "py_binary_rec_cb") + ecal_core.initialize("py_binary_rec_cb") # set process state ecal_core.set_process_state(1, 1, "I feel good") diff --git a/lang/python/samples/core/pubsub/binary_snd.py b/lang/python/samples/core/pubsub/binary_snd.py index 914765d488..a26ec735d1 100644 --- a/lang/python/samples/core/pubsub/binary_snd.py +++ b/lang/python/samples/core/pubsub/binary_snd.py @@ -28,7 +28,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(), ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "py_binary_snd") + ecal_core.initialize("py_binary_snd") # set process state ecal_core.set_process_state(1, 1, "I feel good") diff --git a/lang/python/samples/core/pubsub/protobuf_rec.py b/lang/python/samples/core/pubsub/protobuf_rec.py index 146b05760e..c5d10f0902 100644 --- a/lang/python/samples/core/pubsub/protobuf_rec.py +++ b/lang/python/samples/core/pubsub/protobuf_rec.py @@ -31,7 +31,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(),ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "py_person_rec") + ecal_core.initialize("py_person_rec") # set process state ecal_core.set_process_state(1, 1, "I feel good") diff --git a/lang/python/samples/core/pubsub/protobuf_rec_cb.py b/lang/python/samples/core/pubsub/protobuf_rec_cb.py index ca88c90f76..37f70dda4a 100644 --- a/lang/python/samples/core/pubsub/protobuf_rec_cb.py +++ b/lang/python/samples/core/pubsub/protobuf_rec_cb.py @@ -41,7 +41,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(),ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "py_person_rec_cb") + ecal_core.initialize("py_person_rec_cb") # set process state ecal_core.set_process_state(1, 1, "I feel good") diff --git a/lang/python/samples/core/pubsub/protobuf_snd.py b/lang/python/samples/core/pubsub/protobuf_snd.py index e8acbb726a..e7cf2a6133 100644 --- a/lang/python/samples/core/pubsub/protobuf_snd.py +++ b/lang/python/samples/core/pubsub/protobuf_snd.py @@ -31,7 +31,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(), ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "py_person_snd") + ecal_core.initialize("py_person_snd") # set process state ecal_core.set_process_state(1, 1, "I feel good") diff --git a/lang/python/samples/core/pubsub/string_rec.py b/lang/python/samples/core/pubsub/string_rec.py index 575113d3e1..844d1efc80 100644 --- a/lang/python/samples/core/pubsub/string_rec.py +++ b/lang/python/samples/core/pubsub/string_rec.py @@ -26,7 +26,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(), ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "py_minimal_rec") + ecal_core.initialize("py_minimal_rec") # set process state ecal_core.set_process_state(1, 1, "I feel good") diff --git a/lang/python/samples/core/pubsub/string_rec_cb.py b/lang/python/samples/core/pubsub/string_rec_cb.py index aca7e226d5..f78e0c29d2 100644 --- a/lang/python/samples/core/pubsub/string_rec_cb.py +++ b/lang/python/samples/core/pubsub/string_rec_cb.py @@ -31,7 +31,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(), ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "py_minimal_rec_cb") + ecal_core.initialize("py_minimal_rec_cb") # set process state ecal_core.set_process_state(1, 1, "I feel good") diff --git a/lang/python/samples/core/pubsub/string_snd.py b/lang/python/samples/core/pubsub/string_snd.py index b785c6d3c7..73725e2e9b 100644 --- a/lang/python/samples/core/pubsub/string_snd.py +++ b/lang/python/samples/core/pubsub/string_snd.py @@ -27,7 +27,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(), ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "py_minimal_snd") + ecal_core.initialize("py_minimal_snd") # set process state ecal_core.set_process_state(1, 1, "I feel good") diff --git a/lang/python/samples/core/service/minimal_service_client.py b/lang/python/samples/core/service/minimal_service_client.py index f4c06ea332..1f62d7fa99 100644 --- a/lang/python/samples/core/service/minimal_service_client.py +++ b/lang/python/samples/core/service/minimal_service_client.py @@ -27,7 +27,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(), ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "py_minimal_service_client") + ecal_core.initialize("py_minimal_service_client") # set process state ecal_core.set_process_state(1, 1, "I feel good") diff --git a/lang/python/samples/core/service/minimal_service_server.py b/lang/python/samples/core/service/minimal_service_server.py index 93c93260dd..5b8a95f5b0 100644 --- a/lang/python/samples/core/service/minimal_service_server.py +++ b/lang/python/samples/core/service/minimal_service_server.py @@ -27,7 +27,7 @@ def main(): print("eCAL {} ({})\n".format(ecal_core.getversion(), ecal_core.getdate())) # initialize eCAL API - ecal_core.initialize(sys.argv, "py_minimal_service_server") + ecal_core.initialize("py_minimal_service_server") # set process state ecal_core.set_process_state(1, 1, "I feel good") diff --git a/samples/cpp/measurement/benchmark/src/main.cpp b/samples/cpp/measurement/benchmark/src/main.cpp index d589e9a663..6606e8bfca 100644 --- a/samples/cpp/measurement/benchmark/src/main.cpp +++ b/samples/cpp/measurement/benchmark/src/main.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,7 +111,7 @@ void MeasPerf(const std::string& file_name, const size_t pkg_size, const size_t // start time auto start = std::chrono::high_resolution_clock::now(); - eCAL::eh5::HDF5Meas writer(output_dir, eCAL::eh5::CREATE); + eCAL::eh5::v2::HDF5Meas writer(output_dir, eCAL::eh5::v2::CREATE); writer.SetFileBaseName(file_name + "_hdf5"); writer.SetMaxSizePerFile(max_size_per_file); for (size_t loop = 0; loop < write_loops; ++loop) diff --git a/samples/cpp/measurement/measurement_read/src/measurement_read.cpp b/samples/cpp/measurement/measurement_read/src/measurement_read.cpp index 92fab83361..1b776752f5 100644 --- a/samples/cpp/measurement/measurement_read/src/measurement_read.cpp +++ b/samples/cpp/measurement/measurement_read/src/measurement_read.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,14 +41,17 @@ int main(int /*argc*/, char** /*argv*/) eCAL::measurement::IMeasurement meas(MEASUREMENT_PATH); // create a channel (topic name "person") - eCAL::measurement::IChannel person_channel = meas.Get("person"); - - // iterate over the messages - for (const auto& person_entry : person_channel) + auto person_channels = meas.Channels("person"); + if (person_channels.size() > 0) { - std::cout << "Person object at timestamp " << person_entry.send_timestamp << std::endl; - print_person(person_entry.message); + eCAL::measurement::IChannel person_channel = meas.Get(*person_channels.begin()); + + // iterate over the messages + for (const auto& person_entry : person_channel) + { + std::cout << "Person object at timestamp " << person_entry.send_timestamp << std::endl; + print_person(person_entry.message); + } } - return 0; } diff --git a/samples/cpp/pubsub/capnp/addressbook_rec/src/addressbook_rec.cpp b/samples/cpp/pubsub/capnp/addressbook_rec/src/addressbook_rec.cpp index d35e448099..ccca11db18 100644 --- a/samples/cpp/pubsub/capnp/addressbook_rec/src/addressbook_rec.cpp +++ b/samples/cpp/pubsub/capnp/addressbook_rec/src/addressbook_rec.cpp @@ -77,7 +77,7 @@ void printAddressBook(const AddressBook::Reader& addressBook) int main(int argc, char **argv) { // initialize eCAL API - eCAL::Initialize(argc, argv, "addressbook subscriber"); + eCAL::Initialize("addressbook subscriber"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/samples/cpp/pubsub/capnp/addressbook_rec_cb/src/addressbook_rec_cb.cpp b/samples/cpp/pubsub/capnp/addressbook_rec_cb/src/addressbook_rec_cb.cpp index cd28202f77..d62461b019 100644 --- a/samples/cpp/pubsub/capnp/addressbook_rec_cb/src/addressbook_rec_cb.cpp +++ b/samples/cpp/pubsub/capnp/addressbook_rec_cb/src/addressbook_rec_cb.cpp @@ -85,7 +85,7 @@ void OnAddressbook(const char* topic_name_, AddressBook::Reader msg_, const long int main(int argc, char **argv) { // initialize eCAL API - eCAL::Initialize(argc, argv, "addressbook subscriber"); + eCAL::Initialize("addressbook subscriber"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/samples/cpp/pubsub/capnp/addressbook_rec_dynamic/src/addressbook_rec_dynamic.cpp b/samples/cpp/pubsub/capnp/addressbook_rec_dynamic/src/addressbook_rec_dynamic.cpp index d5562fd031..8546f2a130 100644 --- a/samples/cpp/pubsub/capnp/addressbook_rec_dynamic/src/addressbook_rec_dynamic.cpp +++ b/samples/cpp/pubsub/capnp/addressbook_rec_dynamic/src/addressbook_rec_dynamic.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -108,14 +108,14 @@ void dynamicPrintValue(const capnp::DynamicValue::Reader& value) int main(int argc, char** argv) { // initialize eCAL API - eCAL::Initialize(argc, argv, "addressbook subscriber"); + eCAL::Initialize("addressbook subscriber"); eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); // create a subscriber (topic name "addressbook") eCAL::capnproto::CDynamicSubscriber sub("addressbook"); - auto lambda = [](const char* /*topic_name_*/, const capnp::DynamicValue::Reader& msg_, long long /*time_*/, long long /*clock_*/, long long /*id_*/) -> void { + auto lambda = [](const eCAL::Registration::STopicId& /*topic_id_*/, const capnp::DynamicValue::Reader& msg_, long long /*time_*/, long long /*clock_*/, long long /*id_*/) -> void { dynamicPrintValue(msg_); }; sub.AddReceiveCallback(lambda); diff --git a/samples/cpp/pubsub/capnp/addressbook_snd/src/addressbook_snd.cpp b/samples/cpp/pubsub/capnp/addressbook_snd/src/addressbook_snd.cpp index 48cdb68a04..830d253988 100644 --- a/samples/cpp/pubsub/capnp/addressbook_snd/src/addressbook_snd.cpp +++ b/samples/cpp/pubsub/capnp/addressbook_snd/src/addressbook_snd.cpp @@ -44,7 +44,7 @@ void printAddressBook(AddressBook::Builder addressBook) int main(int argc, char **argv) { // initialize eCAL API - eCAL::Initialize(argc, argv, "addressbook publisher"); + eCAL::Initialize("addressbook publisher"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/samples/cpp/pubsub/flatbuffer/monster_rec/monster_rec.cpp b/samples/cpp/pubsub/flatbuffer/monster_rec/monster_rec.cpp index 004a7f1a1e..9c5f972aa5 100644 --- a/samples/cpp/pubsub/flatbuffer/monster_rec/monster_rec.cpp +++ b/samples/cpp/pubsub/flatbuffer/monster_rec/monster_rec.cpp @@ -76,7 +76,7 @@ void OnMonster(const char* topic_name_, const flatbuffers::FlatBufferBuilder& ms int main(int argc, char **argv) { // initialize eCAL API - eCAL::Initialize(argc, argv, "monster subscriber"); + eCAL::Initialize("monster subscriber"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/samples/cpp/pubsub/flatbuffer/monster_snd/monster_snd.cpp b/samples/cpp/pubsub/flatbuffer/monster_snd/monster_snd.cpp index 356075882a..04bb9a16e9 100644 --- a/samples/cpp/pubsub/flatbuffer/monster_snd/monster_snd.cpp +++ b/samples/cpp/pubsub/flatbuffer/monster_snd/monster_snd.cpp @@ -34,7 +34,7 @@ int main(int argc, char **argv) { // initialize eCAL API - eCAL::Initialize(argc, argv, "monster publisher"); + eCAL::Initialize("monster publisher"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/samples/cpp/pubsub/msgpack/address_rec/src/address_rec.cpp b/samples/cpp/pubsub/msgpack/address_rec/src/address_rec.cpp index 0cff8b28c2..d9a95237b6 100644 --- a/samples/cpp/pubsub/msgpack/address_rec/src/address_rec.cpp +++ b/samples/cpp/pubsub/msgpack/address_rec/src/address_rec.cpp @@ -57,7 +57,7 @@ void OnAddress(const char* topic_name_, const CAddress& msg_, const long long ti int main(int argc, char **argv) { // initialize eCAL API - eCAL::Initialize(argc, argv, "address subscriber"); + eCAL::Initialize("address subscriber"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/samples/cpp/pubsub/msgpack/address_snd/src/address_snd.cpp b/samples/cpp/pubsub/msgpack/address_snd/src/address_snd.cpp index 810adb247a..de55f1214e 100644 --- a/samples/cpp/pubsub/msgpack/address_snd/src/address_snd.cpp +++ b/samples/cpp/pubsub/msgpack/address_snd/src/address_snd.cpp @@ -44,7 +44,7 @@ class CAddress int main(int argc, char **argv) { // initialize eCAL API - eCAL::Initialize(argc, argv, "address publisher"); + eCAL::Initialize("address publisher"); // set process state eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); diff --git a/samples/cpp/services/ecalplayer_client/src/ecalplayer_client.cpp b/samples/cpp/services/ecalplayer_client/src/ecalplayer_client.cpp index 033dd2f4c5..7d5913149a 100644 --- a/samples/cpp/services/ecalplayer_client/src/ecalplayer_client.cpp +++ b/samples/cpp/services/ecalplayer_client/src/ecalplayer_client.cpp @@ -83,10 +83,10 @@ void OnPlayerResponse(const struct eCAL::SServiceResponse& service_response_) } // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "ecalplayer client"); + eCAL::Initialize("ecalplayer client"); // create player service client eCAL::protobuf::CServiceClient player_service; diff --git a/samples/cpp/services/ecalplayer_gui_client/src/ecalplayer_gui_client.cpp b/samples/cpp/services/ecalplayer_gui_client/src/ecalplayer_gui_client.cpp index da45267f6b..8e00a3a0cb 100644 --- a/samples/cpp/services/ecalplayer_gui_client/src/ecalplayer_gui_client.cpp +++ b/samples/cpp/services/ecalplayer_gui_client/src/ecalplayer_gui_client.cpp @@ -28,7 +28,7 @@ EcalplayGuiClient::EcalplayGuiClient(QWidget *parent) ui_.setupUi(this); // initialize eCAL API - eCAL::Initialize(0, nullptr, "ecalplayer gui client"); + eCAL::Initialize("ecalplayer gui client"); // create player service client player_service_.AddResponseCallback([this](const struct eCAL::SServiceResponse& service_response) {this->onPlayerResponse(service_response); }); diff --git a/samples/cpp/services/ecalplayer_gui_client/src/main.cpp b/samples/cpp/services/ecalplayer_gui_client/src/main.cpp index 8e9411d76c..8613decbce 100644 --- a/samples/cpp/services/ecalplayer_gui_client/src/main.cpp +++ b/samples/cpp/services/ecalplayer_gui_client/src/main.cpp @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) { // Just make sure that eCAL is initialized - eCAL::Initialize(0, nullptr, "EcalPlayGuiClient", eCAL::Init::Default); + eCAL::Initialize("EcalPlayGuiClient", eCAL::Init::Default); QApplication a(argc, argv); diff --git a/samples/cpp/services/ecalsys_client/src/ecalsys_client.cpp b/samples/cpp/services/ecalsys_client/src/ecalsys_client.cpp index 986f5bb5fc..55dac2f1f4 100644 --- a/samples/cpp/services/ecalsys_client/src/ecalsys_client.cpp +++ b/samples/cpp/services/ecalsys_client/src/ecalsys_client.cpp @@ -60,10 +60,10 @@ void OnSysResponse(const struct eCAL::SServiceResponse& service_response_) } // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "ecalsys client"); + eCAL::Initialize("ecalsys client"); // create player service client eCAL::protobuf::CServiceClient sys_service; diff --git a/samples/cpp/services/player_stepper/src/ecal_stepper.cpp b/samples/cpp/services/player_stepper/src/ecal_stepper.cpp index d73cc789a5..7e2f4ba132 100644 --- a/samples/cpp/services/player_stepper/src/ecal_stepper.cpp +++ b/samples/cpp/services/player_stepper/src/ecal_stepper.cpp @@ -99,7 +99,7 @@ int main(int argc, char** argv) } // initialize eCAL API - eCAL::Initialize(argc, argv, "ecal stepper", eCAL::Init::Default); + eCAL::Initialize("ecal stepper", eCAL::Init::Default); // create player service client eCAL::protobuf::CServiceClient player_service; diff --git a/samples/cpp/services/rec_client_service_cli/src/ecalrecorder_client.cpp b/samples/cpp/services/rec_client_service_cli/src/ecalrecorder_client.cpp index 4f42bb07e2..924d5f85e3 100644 --- a/samples/cpp/services/rec_client_service_cli/src/ecalrecorder_client.cpp +++ b/samples/cpp/services/rec_client_service_cli/src/ecalrecorder_client.cpp @@ -91,10 +91,10 @@ void OnRecorderResponse(const struct eCAL::SServiceResponse& service_response_) } // main entry -int main(int argc, char **argv) +int main() { // initialize eCAL API - eCAL::Initialize(argc, argv, "RecClientServiceCli"); + eCAL::Initialize("RecClientServiceCli"); // create recorder service client eCAL::protobuf::CServiceClient recorder_service; diff --git a/samples/cpp/services/rec_client_service_gui/src/EcalrecGuiClient.cpp b/samples/cpp/services/rec_client_service_gui/src/EcalrecGuiClient.cpp index e16fac7218..5cdc38d143 100644 --- a/samples/cpp/services/rec_client_service_gui/src/EcalrecGuiClient.cpp +++ b/samples/cpp/services/rec_client_service_gui/src/EcalrecGuiClient.cpp @@ -28,7 +28,7 @@ EcalrecGuiClient::EcalrecGuiClient(QWidget *parent) ui_.setupUi(this); // initialize eCAL API - eCAL::Initialize(0, nullptr, "RecClientServiceGui"); + eCAL::Initialize("RecClientServiceGui"); // create player service client recorder_service_.AddResponseCallback([this](const struct eCAL::SServiceResponse& service_response) {this->onRecorderResponse(service_response); }); diff --git a/samples/cpp/services/rec_client_service_gui/src/main.cpp b/samples/cpp/services/rec_client_service_gui/src/main.cpp index 037e0b7c6d..96835e7633 100644 --- a/samples/cpp/services/rec_client_service_gui/src/main.cpp +++ b/samples/cpp/services/rec_client_service_gui/src/main.cpp @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) { // Just make sure that eCAL is initialized - eCAL::Initialize(0, nullptr, "EcalRecGuiClient", eCAL::Init::Default); + eCAL::Initialize("EcalRecGuiClient", eCAL::Init::Default); QApplication a(argc, argv); diff --git a/samples/cpp/services/rec_server_service_gui/src/main.cpp b/samples/cpp/services/rec_server_service_gui/src/main.cpp index c794d6fe98..25e3bf14ea 100644 --- a/samples/cpp/services/rec_server_service_gui/src/main.cpp +++ b/samples/cpp/services/rec_server_service_gui/src/main.cpp @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) { // Just make sure that eCAL is initialized - eCAL::Initialize(0, nullptr, "EcalRecGuiClient", eCAL::Init::Default); + eCAL::Initialize("EcalRecGuiClient", eCAL::Init::Default); QApplication a(argc, argv); diff --git a/samples/cpp/services/rec_server_service_gui/src/rec_server_service_gui.cpp b/samples/cpp/services/rec_server_service_gui/src/rec_server_service_gui.cpp index 6c78a24341..30742e78e1 100644 --- a/samples/cpp/services/rec_server_service_gui/src/rec_server_service_gui.cpp +++ b/samples/cpp/services/rec_server_service_gui/src/rec_server_service_gui.cpp @@ -29,7 +29,7 @@ RecServerServiceGui::RecServerServiceGui(QWidget *parent) ui_.setupUi(this); // initialize eCAL API - eCAL::Initialize(0, nullptr, "RecServerServiceGui"); + eCAL::Initialize("RecServerServiceGui"); // create player service client recorder_service_.AddResponseCallback([this](const struct eCAL::SServiceResponse& service_response) {this->onRecorderResponse(service_response); }); diff --git a/tests/contrib/ecalhdf5/hdf5_test/CMakeLists.txt b/tests/contrib/ecalhdf5/hdf5_test/CMakeLists.txt index a637c7e1c8..2c237272b5 100644 --- a/tests/contrib/ecalhdf5/hdf5_test/CMakeLists.txt +++ b/tests/contrib/ecalhdf5/hdf5_test/CMakeLists.txt @@ -32,7 +32,9 @@ target_link_libraries(${PROJECT_NAME} eCAL::hdf5 Threads::Threads) +target_include_directories(${PROJECT_NAME} PRIVATE $) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +target_compile_definitions(${PROJECT_NAME} PRIVATE ECAL_EH5_NO_DEPRECATION_WARNINGS) ecal_install_gtest(${PROJECT_NAME}) diff --git a/tests/contrib/ecalhdf5/hdf5_test/src/hdf5_test.cpp b/tests/contrib/ecalhdf5/hdf5_test/src/hdf5_test.cpp index e2f19acb39..c8b775fb33 100644 --- a/tests/contrib/ecalhdf5/hdf5_test/src/hdf5_test.cpp +++ b/tests/contrib/ecalhdf5/hdf5_test/src/hdf5_test.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,16 +17,18 @@ * ========================= eCAL LICENSE ================================= */ -#include - +#include #include -#include +#include #include -#include +#include +#include #include -#include // This header file is usually not available as public include! +#include +#include // This header file is usually not available as public include! +#include // This header file is usually not available as public include! using namespace eCAL::experimental::measurement::base; @@ -44,58 +46,126 @@ namespace eCAL } } } + namespace eh5 + { + void PrintTo(const SChannel& channel, std::ostream* os) { + *os << "(" << channel.name << "," << channel.id << ")"; + } + } } +using MeasAPI = eCAL::eh5::v3::HDF5Meas; +using MeasAPIAccess = eCAL::eh5::v3::eAccessType; +using LegacyAPI = eCAL::eh5::v2::HDF5Meas; +using LegacyAPIAccess = eCAL::eh5::v2::eAccessType; +using eCAL::eh5::SChannel; + namespace { struct TestingMeasEntry { - std::string channel_name = "topic"; + SChannel channel{ "topic", 1 }; std::string data = "Hello World"; long long snd_timestamp = 1001LL; long long rcv_timestamp = 2001LL; - long long id = 1LL; + long long snd_id = 0; long long clock = 11LL; }; +std::string print(const TestingMeasEntry& entry) { + std::stringstream s; + s << "(" + << entry.channel.name << ", " + << entry.channel.id << ", " + << entry.data << ", " + << entry.snd_timestamp << ", " + << entry.rcv_timestamp << ", " + << entry.snd_id << ", " + << entry.clock << ")"; + return s.str(); +} + +std::string print(const EntryInfo& info) { + std::stringstream s; + s << "( rcv: " << info.RcvTimestamp + << ", id: " << info.ID + << ", clock: " << info.SndClock + << ", snd: " << info.SndTimestamp + << ", snd_id: " << info.SndID + << ")"; + return s.str(); +} + bool MeasEntryEqualsEntryInfo(const TestingMeasEntry& meas_entry, const EntryInfo entry_info) { - return meas_entry.id == entry_info.SndID + return meas_entry.snd_id == entry_info.SndID && meas_entry.snd_timestamp == entry_info.SndTimestamp && meas_entry.rcv_timestamp == entry_info.RcvTimestamp && meas_entry.clock == entry_info.SndClock; } -bool WriteToHDF(eCAL::eh5::HDF5Meas& writer, const TestingMeasEntry& entry) +eCAL::eh5::SWriteEntry Convert(const TestingMeasEntry& entry) +{ + eCAL::eh5::SWriteEntry write_entry; + write_entry.channel = entry.channel; + write_entry.data = entry.data.data(); + write_entry.size = entry.data.size(); + write_entry.snd_timestamp = entry.snd_timestamp; + write_entry.rcv_timestamp = entry.rcv_timestamp; + write_entry.sender_id = entry.snd_id; + write_entry.clock = entry.clock; + return write_entry; +} + +bool WriteToHDF(MeasAPI& writer, const TestingMeasEntry& entry) +{ + eCAL::eh5::SWriteEntry write_entry = Convert(entry); + return writer.AddEntryToFile(write_entry); +} + +bool WriteToHDF(LegacyAPI& writer, const TestingMeasEntry& entry) { return writer.AddEntryToFile( entry.data.data(), // data entry.data.size(), // data size entry.snd_timestamp, // snd_timestamp entry.rcv_timestamp, // rcv_timestamp - entry.channel_name, // channel name - entry.id, // id + entry.channel.name, // channel_name + entry.snd_id, // channel, id (maybe we shouldn't mix them???) entry.clock // clock ); } +// Validates, that if all entries contained in TestingMeasEntry were added to a measurement, they are later contained in the read measurement. +void ValidateChannelsInMeasurementV6(MeasAPI& hdf5_reader, const std::vector& entries_in_measurement) +{ + std::set expected_channels; + std::transform(entries_in_measurement.begin(), entries_in_measurement.end(), std::inserter(expected_channels, expected_channels.begin()), + [](const TestingMeasEntry& entry) { return entry.channel; }); + + EXPECT_EQ(hdf5_reader.GetChannels(), expected_channels); +} // Validates, that if all entries contained in TestingMeasEntry were added to a measurement, they are later contained in the read measurement. -void ValidateChannelsInMeasurement(eCAL::eh5::HDF5Meas& hdf5_reader, const std::vector& entries_in_measurement) +void ValidateChannelsInMeasurementV5(MeasAPI& hdf5_reader, const std::vector& entries_in_measurement) { - std::set expected_channel_names; - std::transform(entries_in_measurement.begin(), entries_in_measurement.end(), std::inserter(expected_channel_names, expected_channel_names.begin()), - [](const TestingMeasEntry& entry) { return entry.channel_name; }); + std::set expected_channels; + std::transform(entries_in_measurement.begin(), entries_in_measurement.end(), std::inserter(expected_channels, expected_channels.begin()), + [](const TestingMeasEntry& entry) { return eCAL::eh5::SChannel(entry.channel.name, 0); }); - EXPECT_EQ(hdf5_reader.GetChannelNames(), expected_channel_names); + EXPECT_EQ(hdf5_reader.GetChannels(), expected_channels); } // Finds an EntryInfo corresponding to the TestingMeasEntry in the EntryInfoSet // Return default EntryInfo if it cannot be Found EntryInfo FindInSet(const eCAL::eh5::EntryInfoSet& info_set, const TestingMeasEntry& to_find) { - auto it = std::find_if(info_set.begin(), info_set.end(), [&to_find](const EntryInfo& entry) { return entry.SndClock == to_find.clock; }); + auto it = std::find_if(info_set.begin(), info_set.end(), [&to_find](const EntryInfo& entry) { + return entry.SndClock == to_find.clock && + entry.SndID == to_find.snd_id && + entry.SndTimestamp == to_find.snd_timestamp && + entry.RcvTimestamp == to_find.rcv_timestamp; }); if (it != info_set.end()) { return *it; @@ -105,22 +175,23 @@ EntryInfo FindInSet(const eCAL::eh5::EntryInfoSet& info_set, const TestingMeasEn } } -// Validate, that the TestingMeasEntry can be read from the measurement -void ValidateDataInMeasurement(eCAL::eh5::HDF5Meas& hdf5_reader, const TestingMeasEntry& entry) +template +void ValidateDataInMeasurementGeneric(Reader& hdf5_reader, const TestingMeasEntry& entry, std::function entry_info_function) { eCAL::eh5::EntryInfoSet entries_info_set; - EXPECT_TRUE(hdf5_reader.GetEntriesInfo(entry.channel_name, entries_info_set)); - // Get Entry info from measurement and see that it checks out + EXPECT_TRUE(entry_info_function(entries_info_set)); + + // Get Entry info1 from measurement and see that it checks out EntryInfo info = FindInSet(entries_info_set, entry); - // entry was not in the dataset + // entry1 was not in the dataset if (info == EntryInfo{}) { - FAIL() << "Entry info not found in set / measurement"; + FAIL() << "Entry info for not found in set / measurement\n" << print(entry); return; } - EXPECT_TRUE(MeasEntryEqualsEntryInfo(entry, info)); + EXPECT_TRUE(MeasEntryEqualsEntryInfo(entry, info)) << print(entry) << " != " << print(info); size_t data_size; EXPECT_TRUE(hdf5_reader.GetEntryDataSize(info.ID, data_size)); @@ -131,50 +202,76 @@ void ValidateDataInMeasurement(eCAL::eh5::HDF5Meas& hdf5_reader, const TestingMe EXPECT_EQ(data_read, entry.data); } + +// Validate, that the TestingMeasEntry can be read from the measurement +void ValidateDataInMeasurement(MeasAPI& hdf5_reader, const TestingMeasEntry& entry) +{ + auto get_entries_info = [&hdf5_reader, &entry](eCAL::eh5::EntryInfoSet& entries) -> bool + { + return hdf5_reader.GetEntriesInfo(entry.channel, entries); + }; + + ValidateDataInMeasurementGeneric(hdf5_reader, entry, get_entries_info); +} + +void ValidateDataInMeasurement(LegacyAPI& hdf5_reader, const TestingMeasEntry& entry) +{ + auto get_entries_info = [&hdf5_reader, &entry](eCAL::eh5::EntryInfoSet& entries) -> bool + { + return hdf5_reader.GetEntriesInfo(entry.channel.name, entries); + }; + + ValidateDataInMeasurementGeneric(hdf5_reader, entry, get_entries_info); +} + + TestingMeasEntry m1{ - "topic / with / slash", + {"topic / with / slash", 1}, + //{"t1", 1}, "Hello World", 1001LL, 2001LL, - 1LL, + 0, 11LL, }; TestingMeasEntry m2{ - "another,topic", + {"another,topic", 2}, + //{"t2", 2}, "", 1002LL, 2002LL, - 2LL, + 0, 12LL }; TestingMeasEntry m3{ - " ASCII and beyond!\a\b\t\n\v\f\r\"#$%&\'()*+,-./0123456789:,<=>\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~üöäÜÖÄâÂôÔûÛáàÁÀúÙ", + {" ASCII and beyond!\a\b\t\n\v\f\r\"#$%&\'()*+,-./0123456789:,<=>\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~üöäÜÖÄâÂôÔûÛáàÁÀúÙ", 3}, + //{"t3", 3}, "o.O", 1003LL, 2003LL, - 3LL, + 0, 13LL }; TestingMeasEntry topic_1 { - "topic_1", + {"topic_1", 1}, "topic1: test data", 1001LL, 2001LL, - 1LL, + 0, 11LL }; TestingMeasEntry topic_2 { - "topic_2", + {"topic_2", 2}, "topic2: test data", 1002LL, 2002LL, - 2LL, + 1000, 12LL, }; @@ -185,6 +282,20 @@ TestingMeasEntry topic_2 std::vector data; } +template +void CreateMeasurement(Meas& hdf5_writer, std::string root_dir, std::string base_name, AccessType access_type = AccessType::CREATE) +{ + if (hdf5_writer.Open(root_dir, access_type)) + { + hdf5_writer.SetFileBaseName(base_name); + hdf5_writer.SetMaxSizePerFile(max_size_per_file); + } + else + { + FAIL() << "Failed to open HDF5 Writer"; + } +} + TEST(contrib, HDF5_EscapeUnescape) { std::string test_string = "This string contains commata,slashes/ spaces, a percent sign (%), a bell\a, nasty line endings\r\n and a german letter oe from the Latin-1 codepage: \xF8"; @@ -213,17 +324,8 @@ TEST(contrib, HDF5_WriteReadIntegrity) // Write HDF5 file { - eCAL::eh5::HDF5Meas hdf5_writer; - - if (hdf5_writer.Open(meas_root_dir, eCAL::eh5::eAccessType::CREATE)) - { - hdf5_writer.SetFileBaseName(base_name); - hdf5_writer.SetMaxSizePerFile(max_size_per_file); - } - else - { - FAIL() << "Failed to open HDF5 Writer"; - } + MeasAPI hdf5_writer; + CreateMeasurement(hdf5_writer, meas_root_dir, base_name); for (const auto& entry : meas_entries) { @@ -233,12 +335,17 @@ TEST(contrib, HDF5_WriteReadIntegrity) EXPECT_TRUE(hdf5_writer.Close()); } + std::set expected_channels{ m1.channel, m2.channel, m3.channel }; + // Read HDF5 file { - eCAL::eh5::HDF5Meas hdf5_reader; + MeasAPI hdf5_reader; EXPECT_TRUE(hdf5_reader.Open(meas_root_dir + "/" + base_name + ".hdf5")); - ValidateChannelsInMeasurement(hdf5_reader, meas_entries); + auto actual_channels = hdf5_reader.GetChannels(); + EXPECT_EQ(actual_channels, expected_channels); + + ValidateChannelsInMeasurementV6(hdf5_reader, meas_entries); for (const auto& entry : meas_entries) { ValidateDataInMeasurement(hdf5_reader, entry); @@ -247,10 +354,13 @@ TEST(contrib, HDF5_WriteReadIntegrity) // Read entries with HDF5 dir API { - eCAL::eh5::HDF5Meas hdf5_reader; + MeasAPI hdf5_reader; EXPECT_TRUE(hdf5_reader.Open(meas_root_dir)); - ValidateChannelsInMeasurement(hdf5_reader, meas_entries); + auto actual_channels = hdf5_reader.GetChannels(); + EXPECT_EQ(actual_channels, expected_channels); + + ValidateChannelsInMeasurementV6(hdf5_reader, meas_entries); for (const auto& entry : meas_entries) { ValidateDataInMeasurement(hdf5_reader, entry); @@ -263,12 +373,16 @@ TEST(contrib, HDF5_ReadWrite) std::string file_name = "meas_readwrite"; // Create writer instance - eCAL::eh5::HDF5Meas writer(output_dir, eCAL::eh5::CREATE); + MeasAPI writer(output_dir, MeasAPIAccess::CREATE); writer.SetFileBaseName(file_name); writer.SetMaxSizePerFile(max_size_per_file); data.resize(1024); - EXPECT_TRUE(writer.AddEntryToFile(static_cast(data.data()), data.size(), 0, 0, "myChannel", 0, 0)); + eCAL::eh5::SWriteEntry entry; + entry.channel = CreateChannel("myChannel"); + entry.data = static_cast(data.data()); + entry.size = data.size(); + EXPECT_TRUE(writer.AddEntryToFile(entry)); EXPECT_TRUE(writer.Close()); } @@ -276,10 +390,10 @@ TEST(contrib, HDF5_ReadWrite) TEST(contrib, HDF5_IsOneFilePerChannelEnabled) { - eCAL::eh5::HDF5Meas hdf5_writer; + MeasAPI hdf5_writer; std::string base_name = "output"; - if (hdf5_writer.Open(output_dir, eCAL::eh5::eAccessType::CREATE)) + if (hdf5_writer.Open(output_dir, MeasAPIAccess::CREATE)) { hdf5_writer.SetFileBaseName(base_name); hdf5_writer.SetMaxSizePerFile(max_size_per_file); @@ -302,9 +416,9 @@ TEST(contrib, HDF5_SetOneFilePerChannelEnabled) // Write HDF5 file { - eCAL::eh5::HDF5Meas hdf5_writer; + MeasAPI hdf5_writer; - if (hdf5_writer.Open(output_dir, eCAL::eh5::eAccessType::CREATE)) + if (hdf5_writer.Open(output_dir, MeasAPIAccess::CREATE)) { hdf5_writer.SetFileBaseName(base_name); hdf5_writer.SetMaxSizePerFile(max_size_per_file); @@ -325,20 +439,20 @@ TEST(contrib, HDF5_SetOneFilePerChannelEnabled) // Read HDF5 topic 1 file { - eCAL::eh5::HDF5Meas hdf5_reader; + MeasAPI hdf5_reader; - EXPECT_TRUE(hdf5_reader.Open(output_dir + "/" + base_name + "_" + topic_1.channel_name + ".hdf5")); - ValidateChannelsInMeasurement(hdf5_reader, { topic_1 }); + EXPECT_TRUE(hdf5_reader.Open(output_dir + "/" + base_name + "_" + topic_1.channel.name + ".hdf5")); + ValidateChannelsInMeasurementV6(hdf5_reader, { topic_1 }); ValidateDataInMeasurement(hdf5_reader, topic_1); } // Read HDF5 topic 2 file { - eCAL::eh5::HDF5Meas hdf5_reader; + MeasAPI hdf5_reader; - EXPECT_TRUE(hdf5_reader.Open(output_dir + "/" + base_name + "_" + topic_2.channel_name + ".hdf5")); + EXPECT_TRUE(hdf5_reader.Open(output_dir + "/" + base_name + "_" + topic_2.channel.name + ".hdf5")); - ValidateChannelsInMeasurement(hdf5_reader, { topic_2 }); + ValidateChannelsInMeasurementV6(hdf5_reader, { topic_2 }); ValidateDataInMeasurement(hdf5_reader, topic_2); } @@ -348,15 +462,15 @@ TEST(contrib, HDF5_EscapeFilenamesForOneFilePerChannel) { // Define data that will be written to the file TestingMeasEntry normal_ascii = topic_1; - normal_ascii.channel_name = "NormalAscii"; + normal_ascii.channel.name = "NormalAscii"; const std::string normal_ascii_escaped_filename = "NormalAscii"; TestingMeasEntry escape_ascii = topic_1; - escape_ascii.channel_name = "Escape these: \\/*\"<>|%"; + escape_ascii.channel.name = "Escape these: \\/*\"<>|%"; const std::string escape_ascii_escaped_filename = "Escape these%3A %5C%2F%2A%22%3C%3E%7C%25"; TestingMeasEntry escape_ascii_2 = topic_1; - escape_ascii_2.channel_name = "Don't escape these +~#,;.²³🍺"; + escape_ascii_2.channel.name = "Don't escape these +~#,;.²³🍺"; const std::string escape_ascii_2_escaped_filename = "Don't escape these +~#,;.²³\xF0\x9F\x8D\xBA"; std::string base_name = "escape_filename_meas"; @@ -364,9 +478,9 @@ TEST(contrib, HDF5_EscapeFilenamesForOneFilePerChannel) // Write HDF5 file { - eCAL::eh5::HDF5Meas hdf5_writer; + MeasAPI hdf5_writer; - if (hdf5_writer.Open(meas_root_dir, eCAL::eh5::eAccessType::CREATE)) + if (hdf5_writer.Open(meas_root_dir, MeasAPIAccess::CREATE)) { hdf5_writer.SetFileBaseName(base_name); hdf5_writer.SetMaxSizePerFile(max_size_per_file); @@ -386,7 +500,7 @@ TEST(contrib, HDF5_EscapeFilenamesForOneFilePerChannel) // Read File 1 { - eCAL::eh5::HDF5Meas hdf5_reader; + MeasAPI hdf5_reader; EXPECT_TRUE(hdf5_reader.Open(meas_root_dir + "/" + base_name + "_" + normal_ascii_escaped_filename + ".hdf5")); ValidateDataInMeasurement(hdf5_reader, normal_ascii); @@ -394,7 +508,7 @@ TEST(contrib, HDF5_EscapeFilenamesForOneFilePerChannel) // Read File 2 { - eCAL::eh5::HDF5Meas hdf5_reader; + MeasAPI hdf5_reader; EXPECT_TRUE(hdf5_reader.Open(meas_root_dir + "/" + base_name + "_" + escape_ascii_escaped_filename + ".hdf5")); ValidateDataInMeasurement(hdf5_reader, escape_ascii); @@ -402,7 +516,7 @@ TEST(contrib, HDF5_EscapeFilenamesForOneFilePerChannel) // Read File 3 { - eCAL::eh5::HDF5Meas hdf5_reader; + MeasAPI hdf5_reader; EXPECT_TRUE(hdf5_reader.Open(meas_root_dir + "/" + base_name + "_" + escape_ascii_2_escaped_filename + ".hdf5")); ValidateDataInMeasurement(hdf5_reader, escape_ascii_2); @@ -410,7 +524,7 @@ TEST(contrib, HDF5_EscapeFilenamesForOneFilePerChannel) // Read entries with HDF5 dir API { - eCAL::eh5::HDF5Meas hdf5_reader; + MeasAPI hdf5_reader; EXPECT_TRUE(hdf5_reader.Open(meas_root_dir)); ValidateDataInMeasurement(hdf5_reader, normal_ascii); @@ -424,6 +538,7 @@ TEST(contrib, HDF5_WriteReadTopicTypeInformation) { // Define data that will be written to the file TestingMeasEntry entry; + const auto& channel = entry.channel; DataTypeInformation info{ "mytype", "myencoding", "mydescriptor" }; std::string base_name = "datatypeinformation_meas"; @@ -431,19 +546,10 @@ TEST(contrib, HDF5_WriteReadTopicTypeInformation) // Write HDF5 file { - eCAL::eh5::HDF5Meas hdf5_writer; - - if (hdf5_writer.Open(meas_root_dir, eCAL::eh5::eAccessType::CREATE)) - { - hdf5_writer.SetFileBaseName(base_name); - hdf5_writer.SetMaxSizePerFile(max_size_per_file); - } - else - { - FAIL() << "Failed to open HDF5 Writer"; - } + MeasAPI hdf5_writer; + CreateMeasurement(hdf5_writer, meas_root_dir, base_name); - hdf5_writer.SetChannelDataTypeInformation(entry.channel_name, info); + hdf5_writer.SetChannelDataTypeInformation(channel, info); EXPECT_TRUE(WriteToHDF(hdf5_writer, entry)); EXPECT_TRUE(hdf5_writer.Close()); @@ -451,16 +557,77 @@ TEST(contrib, HDF5_WriteReadTopicTypeInformation) // Read entries with HDF5 dir API { - eCAL::eh5::HDF5Meas hdf5_reader; + MeasAPI hdf5_reader; + EXPECT_TRUE(hdf5_reader.Open(meas_root_dir)); + EXPECT_EQ(hdf5_reader.GetChannelDataTypeInformation(channel), info); + } +} + +/* +* This test verifies that you save different descriptors for the same channel +* And later read them from the measurement +*/ +TEST(HDF5, WriteReadMultipleTopicTypeInformation) +{ + TestingMeasEntry entry1; + entry1.channel.id = 1; + TestingMeasEntry entry2; + entry2.channel.id = 2; + TestingMeasEntry entry3; + entry3.channel.id = 3; + + const auto& channel1 = entry1.channel; + const auto& channel2 = entry2.channel; + const auto& channel3 = entry3.channel; + + DataTypeInformation info1{ "mytype", "myencoding", "mydescriptor" }; + DataTypeInformation info2{ "mytype2", "myencoding2", "mydescriptor2" }; + // take one info whith \0 character, as protobuf descriptors may contain those + DataTypeInformation info3{ "mytype3", "myencoding3", std::string("my\0\ndescriptor3", 15)}; + EXPECT_EQ(info3.descriptor.size(), 15); + + std::string base_name = "datatypeinformation_multiple"; + std::string meas_root_dir = output_dir + "/" + base_name; + + // Write HDF5 file + { + MeasAPI hdf5_writer; + CreateMeasurement(hdf5_writer, meas_root_dir, base_name); + + hdf5_writer.SetChannelDataTypeInformation(channel1, info1); + EXPECT_TRUE(WriteToHDF(hdf5_writer, entry1)); + + hdf5_writer.SetChannelDataTypeInformation(channel2, info2); + EXPECT_TRUE(WriteToHDF(hdf5_writer, entry2)); + + hdf5_writer.SetChannelDataTypeInformation(channel3, info3); + EXPECT_TRUE(WriteToHDF(hdf5_writer, entry3)); + + EXPECT_TRUE(hdf5_writer.Close()); + } + + // Read entries with HDF5 dir API + { + MeasAPI hdf5_reader; EXPECT_TRUE(hdf5_reader.Open(meas_root_dir)); - EXPECT_EQ(hdf5_reader.GetChannelDataTypeInformation(entry.channel_name), info); + EXPECT_EQ(hdf5_reader.GetChannelDataTypeInformation(channel1), info1); + EXPECT_EQ(hdf5_reader.GetChannelDataTypeInformation(channel2), info2); + EXPECT_EQ(hdf5_reader.GetChannelDataTypeInformation(channel3), info3); + ValidateDataInMeasurement(hdf5_reader, entry1); + ValidateDataInMeasurement(hdf5_reader, entry2); + ValidateDataInMeasurement(hdf5_reader, entry3); } } +// This test checks two cases for the old API. +// We write values with ID 0, and with ID != 0 +// Both descriptors should be read from the measurement successfully TEST(contrib, HDF5_WriteReadTopicTypeInformationDeprecated) { // Define data that will be written to the file - TestingMeasEntry entry; + TestingMeasEntry entry_zero{ {"topic_zero",0}, "topic2: test data", 1001, 1002, 1000, 0 }; + TestingMeasEntry entry_nonzero{ {"topic_nonzerozero",0xAAAA}, "topic2: test data", 1001, 1002, 2000, 0 }; + std::string type = "myencoding:mytype"; std::string descriptor = "mydescriptor"; DataTypeInformation info{ "mytype", "myencoding", "mydescriptor" }; @@ -470,32 +637,414 @@ TEST(contrib, HDF5_WriteReadTopicTypeInformationDeprecated) // Write HDF5 file { - eCAL::eh5::HDF5Meas hdf5_writer; + LegacyAPI hdf5_writer; + CreateMeasurement(hdf5_writer, meas_root_dir, base_name); + + hdf5_writer.SetChannelType(entry_zero.channel.name, type); + hdf5_writer.SetChannelDescription(entry_zero.channel.name, descriptor); + + hdf5_writer.SetChannelType(entry_nonzero.channel.name, type); + hdf5_writer.SetChannelDescription(entry_nonzero.channel.name, descriptor); + + EXPECT_TRUE(WriteToHDF(hdf5_writer, entry_zero)); + EXPECT_TRUE(WriteToHDF(hdf5_writer, entry_nonzero)); + + EXPECT_TRUE(hdf5_writer.Close()); + } + + // Read entries with HDF5 dir API + { + LegacyAPI hdf5_reader; + EXPECT_TRUE(hdf5_reader.Open(meas_root_dir)); + EXPECT_EQ(hdf5_reader.GetChannelType(entry_zero.channel.name), type); + EXPECT_EQ(hdf5_reader.GetChannelDescription(entry_zero.channel.name), descriptor); + EXPECT_EQ(hdf5_reader.GetChannelType(entry_nonzero.channel.name), type); + EXPECT_EQ(hdf5_reader.GetChannelDescription(entry_nonzero.channel.name), descriptor); - if (hdf5_writer.Open(meas_root_dir, eCAL::eh5::eAccessType::CREATE)) + EXPECT_EQ(hdf5_reader.GetChannelDataTypeInformation({ entry_zero.channel.name, 0 }), info); + EXPECT_EQ(hdf5_reader.GetChannelDataTypeInformation({ entry_nonzero.channel.name, 0 }), info); + } +} + +// This tests confirms if you write with the new API, you can read the information with the old API +TEST(HDF5, WriteReadTopicTypeInformationDeprecated2) +{ + // Define data that will be written to the file + TestingMeasEntry entry_topic_1{ {"topic_1", 1}, "topic2: test data", 1001, 1002, 0xAAAA, 0 }; + const auto& channel_topic_1 = entry_topic_1.channel; + + TestingMeasEntry entry_topic_2{ {"topic_2", 2}, "topic2: test data", 1001, 1002, 0xAAAA, 0 }; + const auto& channel_topic_2 = entry_topic_2.channel; + + std::string type_1 = "myencoding:mytype"; + std::string descriptor_1 = "mydescriptor"; + DataTypeInformation info_1{ "mytype", "myencoding", "mydescriptor" }; + + std::string type_2 = "myencoding2:mytype2"; + std::string descriptor_2 = "mydescriptor2"; + DataTypeInformation info_2{ "mytype2", "myencoding2", "mydescriptor2" }; + + std::string base_name = "datatypeinformation_meas_deprecated_2"; + std::string meas_root_dir = output_dir + "/" + base_name; + + // Write HDF5 file + { + MeasAPI hdf5_writer; + CreateMeasurement(hdf5_writer, meas_root_dir, base_name); + + hdf5_writer.SetChannelDataTypeInformation(channel_topic_1, info_1); + EXPECT_TRUE(WriteToHDF(hdf5_writer, entry_topic_1)); + + hdf5_writer.SetChannelDataTypeInformation(channel_topic_2, info_2); + EXPECT_TRUE(WriteToHDF(hdf5_writer, entry_topic_2)); + + + EXPECT_TRUE(hdf5_writer.Close()); + } + + // Read entries with HDF5 dir API + { + LegacyAPI hdf5_reader; + EXPECT_TRUE(hdf5_reader.Open(meas_root_dir)); + EXPECT_EQ(hdf5_reader.GetChannelType(channel_topic_1.name), type_1); + EXPECT_EQ(hdf5_reader.GetChannelDescription(channel_topic_1.name), descriptor_1); + + EXPECT_EQ(hdf5_reader.GetChannelType(channel_topic_2.name), type_2); + EXPECT_EQ(hdf5_reader.GetChannelDescription(channel_topic_2.name), descriptor_2); + } +} + + +// This tests confirms if you write with the new API, you can read the information with the old API +TEST(HDF5, MinMaxTimestamps) +{ + Channel::id_t id_1 = 0xAAAA; + Channel::id_t id_2 = 0x00AA; + std::string topic_name = "topic"; + + eCAL::eh5::SChannel channel_1{ topic_name, id_1 }; + eCAL::eh5::SChannel channel_2{ topic_name, id_2 }; + + // Define data that will be written to the file + std::vector meas_entries = { + TestingMeasEntry{ {topic_name, id_1}, "topic2: test data", 1001, 1002, 0, 0 }, + TestingMeasEntry{ {topic_name, id_1}, "topic2: test data", 2001, 2002, 0, 1 }, + TestingMeasEntry{ {topic_name, id_2}, "topic2: test data", 2051, 2052, 0, 0 }, + TestingMeasEntry{ {topic_name, id_1}, "topic2: test data", 3001, 3002, 0, 2 }, + TestingMeasEntry{ {topic_name, id_2}, "topic2: test data", 3051, 3052, 0, 1 }, + TestingMeasEntry{ {topic_name, id_1}, "topic2: test data", 4001, 4002, 0, 3 }, + TestingMeasEntry{ {topic_name, id_1}, "topic2: test data", 5001, 5002, 0, 4 }, + }; + + std::string base_name = "min_max_timestamps"; + std::string meas_root_dir = output_dir + "/" + base_name; + + // Write HDF5 file + { + MeasAPI hdf5_writer; + CreateMeasurement(hdf5_writer, meas_root_dir, base_name); + + for (const auto& entry : meas_entries) { - hdf5_writer.SetFileBaseName(base_name); - hdf5_writer.SetMaxSizePerFile(max_size_per_file); + EXPECT_TRUE(WriteToHDF(hdf5_writer, entry)); } - else + + EXPECT_TRUE(hdf5_writer.Close()); + } + + // Read entries with HDF5 dir API + { + MeasAPI hdf5_reader; + EXPECT_TRUE(hdf5_reader.Open(meas_root_dir)); + // New API + EXPECT_EQ(hdf5_reader.GetMinTimestamp(channel_1), 1002) << "Min channel 1 should be 1002"; + EXPECT_EQ(hdf5_reader.GetMinTimestamp(channel_2), 2052) << "Min channel 2 should be 2052"; + + // New API + EXPECT_EQ(hdf5_reader.GetMaxTimestamp(channel_1), 5002) << "Max channel 1 should be 5002"; + EXPECT_EQ(hdf5_reader.GetMaxTimestamp(channel_2), 3052) << "Max channel 2 should be 3052"; + + for (const auto& entry : meas_entries) { - FAIL() << "Failed to open HDF5 Writer"; + ValidateDataInMeasurement(hdf5_reader, entry); + } + } + + // Read entries with HDF5 dir API + { + LegacyAPI hdf5_reader; + EXPECT_TRUE(hdf5_reader.Open(meas_root_dir)); + + // Deprecated API + EXPECT_EQ(hdf5_reader.GetMinTimestamp(topic_name), 1002) << "Min topic should be 1002"; + // Deprecated API + EXPECT_EQ(hdf5_reader.GetMaxTimestamp(topic_name), 5002) << "Min topic should be 5002"; + + // TODO This won't work, I guess + for (const auto& entry : meas_entries) + { + ValidateDataInMeasurement(hdf5_reader, entry); } + } - hdf5_writer.SetChannelType(entry.channel_name, type); - hdf5_writer.SetChannelDescription(entry.channel_name, descriptor); +} - EXPECT_TRUE(WriteToHDF(hdf5_writer, entry)); +/* +* This test checks that we can correctly merge multiple measurements +* +*/ +TEST(HDF5, MergedMeasurements) +{ + Channel::id_t id_1 = 0xAAAA; + Channel::id_t id_2 = 0x00AA; + Channel::id_t id_3 = 0x0001; + std::string topic_name_1_2 = "topic"; + std::string topic_name_3 = "topic_3"; + + eCAL::eh5::SChannel channel_1{ topic_name_1_2, id_1 }; + eCAL::eh5::SChannel channel_2{ topic_name_1_2, id_2 }; + eCAL::eh5::SChannel channel_3{ topic_name_3, id_3 }; + + DataTypeInformation info_1{ "mytype1", "myencoding1", "mydescriptor1" }; + DataTypeInformation info_2{ "mytype2", "myencoding2", "mydescriptor2" }; + DataTypeInformation info_3{ "mytype3", "myencoding3", "mydescriptor3" }; + + // Define data that will be written to the file + std::vector entries_meas_1 = { + TestingMeasEntry{ {topic_name_1_2, id_1}, "topic2: test data", 0001, 0002, 0 , 0 }, + TestingMeasEntry{ {topic_name_1_2, id_1}, "topic2: test data", 2001, 2002, 0 , 1 }, + TestingMeasEntry{ {topic_name_1_2, id_1}, "topic2: test data", 3001, 3002, 0 , 2 }, + TestingMeasEntry{ {topic_name_1_2, id_1}, "topic2: test data", 4001, 4002, 0 , 3 }, + TestingMeasEntry{ {topic_name_1_2, id_1}, "topic2: test data", 5001, 5002, 0 , 4 }, + }; + + std::vector entries_meas_2 = { + TestingMeasEntry{ {topic_name_3 , id_3 }, "topic2: test data", 1001, 1002, 0 , 0 }, + TestingMeasEntry{ {topic_name_3 , id_3 }, "topic2: test data", 2001, 2002, 0 , 1 }, + TestingMeasEntry{ {topic_name_1_2, id_2 }, "topic2: test data", 2051, 2052, 0 , 0 }, + TestingMeasEntry{ {topic_name_3 , id_3 }, "topic2: test data", 3001, 3002, 0 , 2 }, + TestingMeasEntry{ {topic_name_1_2, id_2 }, "topic2: test data", 3051, 3052, 0 , 1 }, + TestingMeasEntry{ {topic_name_3 , id_3 }, "topic2: test data", 6001, 6002, 0 , 3 }, + TestingMeasEntry{ {topic_name_3 , id_3 }, "topic2: test data", 7001, 7002, 0 , 4 }, + }; + + std::string base_dir = output_dir + "/merged_measurement"; + std::string meas_dir_1 = base_dir + "/meas1"; + std::string meas_dir_2 = base_dir + "/meas2"; + + // Write first HDF5 file + { + MeasAPI hdf5_writer; + CreateMeasurement(hdf5_writer, meas_dir_1, "meas1"); + + for (const auto& entry : entries_meas_1) + { + EXPECT_TRUE(WriteToHDF(hdf5_writer, entry)); + } + + EXPECT_TRUE(hdf5_writer.Close()); + } + + // Write second HDF5 file + { + MeasAPI hdf5_writer; + CreateMeasurement(hdf5_writer, meas_dir_1, "meas2"); + + for (const auto& entry : entries_meas_2) + { + EXPECT_TRUE(WriteToHDF(hdf5_writer, entry)); + } + + EXPECT_TRUE(hdf5_writer.Close()); + } + + { + MeasAPI hdf5_reader; + EXPECT_TRUE(hdf5_reader.Open(base_dir)); + + std::set expected_channels{ channel_1, channel_2, channel_3 }; + EXPECT_EQ(hdf5_reader.GetChannels(), expected_channels); + + // New API + EXPECT_EQ(hdf5_reader.GetMinTimestamp(channel_1), 0002); + EXPECT_EQ(hdf5_reader.GetMinTimestamp(channel_2), 2052); + EXPECT_EQ(hdf5_reader.GetMinTimestamp(channel_3), 1002); + + // New API + EXPECT_EQ(hdf5_reader.GetMaxTimestamp(channel_1), 5002); + EXPECT_EQ(hdf5_reader.GetMaxTimestamp(channel_2), 3052); + EXPECT_EQ(hdf5_reader.GetMaxTimestamp(channel_3), 7002); + + // Check that all entries are present in the measurement + for (const auto& entry : entries_meas_1) + { + ValidateDataInMeasurement(hdf5_reader, entry); + } + for (const auto& entry : entries_meas_2) + { + ValidateDataInMeasurement(hdf5_reader, entry); + } + } + + { + LegacyAPI hdf5_reader; + EXPECT_TRUE(hdf5_reader.Open(base_dir)); + + std::set expected_channels{ topic_name_1_2, topic_name_3 }; + EXPECT_EQ(hdf5_reader.GetChannelNames(), expected_channels); + + // Deprecated API + EXPECT_EQ(hdf5_reader.GetMinTimestamp(topic_name_1_2), 0002); + EXPECT_EQ(hdf5_reader.GetMinTimestamp(topic_name_3), 1002); + + // Deprecated API + EXPECT_EQ(hdf5_reader.GetMaxTimestamp(topic_name_1_2), 5002); + EXPECT_EQ(hdf5_reader.GetMaxTimestamp(topic_name_3), 7002); + + for (const auto& entry : entries_meas_1) + { + ValidateDataInMeasurement(hdf5_reader, entry); + } + for (const auto& entry : entries_meas_2) + { + ValidateDataInMeasurement(hdf5_reader, entry); + } + } + +} + +// We don't write empty measurements. +// If we change the implementation, we can reactivate this test +TEST(HDF5, DISABLED_WriteReadEmptyMeasurement) +{ + eCAL::eh5::SChannel channel{ "topic", 0}; + DataTypeInformation info{ "mytype", "myencoding", "mydescriptor" }; + + std::string base_name = "empty_measurement"; + std::string meas_root_dir = output_dir + "/" + base_name; + + // Write HDF5 file + { + MeasAPI hdf5_writer; + CreateMeasurement(hdf5_writer, meas_root_dir, base_name); + hdf5_writer.SetChannelDataTypeInformation(channel, info); + + EXPECT_TRUE(hdf5_writer.Close()); + } + + // Read entries with HDF5 dir API + { + MeasAPI hdf5_reader; + EXPECT_TRUE(hdf5_reader.Open(meas_root_dir)); + + EXPECT_EQ(hdf5_reader.GetChannelDataTypeInformation(channel), info); + + std::set channels{ channel }; + EXPECT_EQ(hdf5_reader.GetChannels(), channels); + + EXPECT_EQ(hdf5_reader.GetMinTimestamp(channel), 0); + EXPECT_EQ(hdf5_reader.GetMaxTimestamp(channel), 0); + } +} + +// This tests confirms if you write with the old API, you can read the information both old and new api +TEST(HDF5, TestReaderWriterV5) +{ + Channel::id_t id_1 = 0xAAAA; + Channel::id_t id_2 = 0x00AA; + std::string topic_name = "topic"; + + eCAL::eh5::SChannel channel_1{ topic_name, id_1 }; + eCAL::eh5::SChannel channel_2{ topic_name, id_2 }; + + // Define data that will be written to the file + std::vector meas_entries = { + TestingMeasEntry{ {topic_name, 0}, "topic: test data", 1001, 1002, 0, 0 }, + TestingMeasEntry{ {topic_name, 0}, "topic: test data", 2001, 2002, 0, 1 }, + TestingMeasEntry{ {topic_name, 0}, "topic: test data", 2051, 2052, 0, 0 }, + TestingMeasEntry{ {topic_name, 0}, "topic: test data", 3001, 3002, 0, 2 }, + TestingMeasEntry{ {topic_name, 0}, "topic: test data", 3051, 3052, 0, 1 }, + TestingMeasEntry{ {topic_name, 0}, "topic: test data", 4001, 4002, 0, 3 }, + TestingMeasEntry{ {topic_name, 0}, "topic: test data", 5001, 5002, 0, 4 }, + }; + + std::string base_name = "read_write_v5"; + std::string meas_root_dir = output_dir + "/" + base_name; + + // Write HDF5 file + { + LegacyAPI hdf5_writer; + CreateMeasurement(hdf5_writer, meas_root_dir, base_name); + + for (const auto& entry : meas_entries) + { + EXPECT_TRUE(WriteToHDF(hdf5_writer, entry)); + } EXPECT_TRUE(hdf5_writer.Close()); } // Read entries with HDF5 dir API { - eCAL::eh5::HDF5Meas hdf5_reader; + LegacyAPI hdf5_reader; EXPECT_TRUE(hdf5_reader.Open(meas_root_dir)); - EXPECT_EQ(hdf5_reader.GetChannelType(entry.channel_name), type); - EXPECT_EQ(hdf5_reader.GetChannelDescription(entry.channel_name), descriptor); - EXPECT_EQ(hdf5_reader.GetChannelDataTypeInformation(entry.channel_name), info); + EXPECT_EQ(hdf5_reader.GetFileVersion(), "5.0"); + + // Deprecated API + EXPECT_EQ(hdf5_reader.GetMinTimestamp(topic_name), 1002); + + // Deprecated API + EXPECT_EQ(hdf5_reader.GetMaxTimestamp(topic_name), 5002); + + + for (const auto& entry : meas_entries) + { + ValidateDataInMeasurement(hdf5_reader, entry); + } } -} \ No newline at end of file +} + + + + +TEST(HDF5, ParsePrintHex) +{ + std::vector hex_values = + { + "0000000000000000", + "0000000000000001", + "000000000000000F", + "ABCDEF0123456789", + "EFFFFFFFFFFFFFFF", + "FFFFFFFFFFFFFFFF" + }; + + for (const auto& value : hex_values) + { + auto int_value = parseHexID(value); + auto string_value = printHex(int_value); + EXPECT_EQ(string_value, value); + } +} + +TEST(HDF5, PrintParseHex) +{ + std::vector numeric_values = + { + 0, + -1, + 1, + std::numeric_limits::min(), + std::numeric_limits::max() + }; + + for (const auto& value : numeric_values) + { + auto string_value = printHex(value); + auto int_value = parseHexID(string_value); + + EXPECT_EQ(int_value, value); + } +} + + diff --git a/thirdparty/asio/asio b/thirdparty/asio/asio index 147f7225a9..03ae834edb 160000 --- a/thirdparty/asio/asio +++ b/thirdparty/asio/asio @@ -1 +1 @@ -Subproject commit 147f7225a96d45a2807a64e443177f621844e51c +Subproject commit 03ae834edbace31a96157b89bf50e5ee464e5ef9 diff --git a/thirdparty/ecaludp/ecaludp b/thirdparty/ecaludp/ecaludp index 243474ef74..b39e67ffa1 160000 --- a/thirdparty/ecaludp/ecaludp +++ b/thirdparty/ecaludp/ecaludp @@ -1 +1 @@ -Subproject commit 243474ef7466bc7f5f4f87fd003f23253fe96d83 +Subproject commit b39e67ffa1e43471b64d8db93865db99780a3ad4 diff --git a/thirdparty/fineftp/fineftp-server b/thirdparty/fineftp/fineftp-server index 3668eda2b2..65884209c5 160000 --- a/thirdparty/fineftp/fineftp-server +++ b/thirdparty/fineftp/fineftp-server @@ -1 +1 @@ -Subproject commit 3668eda2b27bbf9e4f66b049f4e22b16e8482489 +Subproject commit 65884209c5af28504069b53ee7bb164417fbb9dd diff --git a/thirdparty/ftxui/ftxui b/thirdparty/ftxui/ftxui index d301fab1f4..cdf28903a7 160000 --- a/thirdparty/ftxui/ftxui +++ b/thirdparty/ftxui/ftxui @@ -1 +1 @@ -Subproject commit d301fab1f4ecdd3544ed99b9c98e647d5804c341 +Subproject commit cdf28903a7781f97ba94d30b79c3a4b0c97ccce7 diff --git a/thirdparty/gtest/googletest b/thirdparty/gtest/googletest index f8d7d77c06..35d0c36560 160000 --- a/thirdparty/gtest/googletest +++ b/thirdparty/gtest/googletest @@ -1 +1 @@ -Subproject commit f8d7d77c06936315286eb55f8de22cd23c188571 +Subproject commit 35d0c365609296fa4730d62057c487e3cfa030ff diff --git a/thirdparty/qwt/qwt b/thirdparty/qwt/qwt index 6dc6c146c0..d11d9f8c72 160000 --- a/thirdparty/qwt/qwt +++ b/thirdparty/qwt/qwt @@ -1 +1 @@ -Subproject commit 6dc6c146c0e9ef2b51f4001e787702bacb729002 +Subproject commit d11d9f8c72ce2e2fccb3af386f7a42dc45381357 diff --git a/thirdparty/recycle/recycle b/thirdparty/recycle/recycle index c5425709b2..3f3d27ecde 160000 --- a/thirdparty/recycle/recycle +++ b/thirdparty/recycle/recycle @@ -1 +1 @@ -Subproject commit c5425709b2273ef6371647247d1a1d86aa75c2e6 +Subproject commit 3f3d27ecdee87af9167adf1d2c2345ca2cbe1c94 diff --git a/thirdparty/spdlog/spdlog b/thirdparty/spdlog/spdlog index 7e635fca68..8e5613379f 160000 --- a/thirdparty/spdlog/spdlog +++ b/thirdparty/spdlog/spdlog @@ -1 +1 @@ -Subproject commit 7e635fca68d014934b4af8a1cf874f63989352b7 +Subproject commit 8e5613379f5140fefb0b60412fbf1f5406e7c7f8 diff --git a/thirdparty/tinyxml2/tinyxml2 b/thirdparty/tinyxml2/tinyxml2 index 1dee28e51f..321ea883b7 160000 --- a/thirdparty/tinyxml2/tinyxml2 +++ b/thirdparty/tinyxml2/tinyxml2 @@ -1 +1 @@ -Subproject commit 1dee28e51f9175a31955b9791c74c430fe13dc82 +Subproject commit 321ea883b7190d4e85cae5512a12e5eaa8f8731f diff --git a/thirdparty/zlib/build-zlib.cmake b/thirdparty/zlib/build-zlib.cmake deleted file mode 100644 index 65022a8745..0000000000 --- a/thirdparty/zlib/build-zlib.cmake +++ /dev/null @@ -1,5 +0,0 @@ -include_guard(GLOBAL) - -add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/zlib thirdparty/zlib EXCLUDE_FROM_ALL SYSTEM) -add_library(ZLIB::zlibstatic ALIAS zlibstatic) -add_library(ZLIB::zlib ALIAS zlib) \ No newline at end of file diff --git a/thirdparty/zlib/zlib b/thirdparty/zlib/zlib deleted file mode 160000 index cacf7f1d4e..0000000000 --- a/thirdparty/zlib/zlib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cacf7f1d4e3d44d871b605da3b647f07d718623f