From 2fb0bc246831917ec5bf7b01b3cbb57697473bb5 Mon Sep 17 00:00:00 2001 From: rex-schilasky <49162693+rex-schilasky@users.noreply.github.com> Date: Fri, 17 May 2024 11:47:24 +0200 Subject: [PATCH 1/2] subscriber configuration introduced global Create/Destroy renamed to Start/Stop --- ecal/core/CMakeLists.txt | 4 +- .../core/include/ecal/ecal_publisher_config.h | 4 +- .../include/ecal/ecal_subscriber_config.h | 68 +++++++++++++++++++ ecal/core/src/ecal_globals.cpp | 34 +++++----- ecal/core/src/io/shm/ecal_memfile_db.cpp | 6 +- ecal/core/src/io/shm/ecal_memfile_db.h | 4 +- ecal/core/src/io/shm/ecal_memfile_pool.cpp | 8 +-- ecal/core/src/io/shm/ecal_memfile_pool.h | 6 +- ecal/core/src/logging/ecal_log_impl.cpp | 8 +-- ecal/core/src/logging/ecal_log_impl.h | 10 +-- .../src/monitoring/ecal_monitoring_def.cpp | 6 +- .../core/src/monitoring/ecal_monitoring_def.h | 8 +-- ecal/core/src/pubsub/ecal_pubgate.cpp | 8 +-- ecal/core/src/pubsub/ecal_pubgate.h | 6 +- .../src/pubsub/ecal_subscriber_config.cpp | 43 ++++++++++++ .../ecal_registration_provider.cpp | 8 +-- .../registration/ecal_registration_provider.h | 6 +- .../ecal_registration_receiver.cpp | 8 +-- .../registration/ecal_registration_receiver.h | 6 +- ecal/core/src/time/ecal_timegate.cpp | 8 +-- ecal/core/src/time/ecal_timegate.h | 6 +- 21 files changed, 189 insertions(+), 76 deletions(-) create mode 100644 ecal/core/include/ecal/ecal_subscriber_config.h create mode 100644 ecal/core/src/pubsub/ecal_subscriber_config.cpp diff --git a/ecal/core/CMakeLists.txt b/ecal/core/CMakeLists.txt index 3d8a010faa..33caca1dda 100644 --- a/ecal/core/CMakeLists.txt +++ b/ecal/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. @@ -204,6 +204,7 @@ endif() if(ECAL_CORE_SUBSCRIBER) set(ecal_sub_src src/pubsub/ecal_subscriber.cpp + src/pubsub/ecal_subscriber_config.cpp src/pubsub/ecal_subgate.cpp src/pubsub/ecal_subgate.h ) @@ -468,6 +469,7 @@ set(ecal_header_cmn include/ecal/ecal_server.h include/ecal/ecal_service_info.h include/ecal/ecal_subscriber.h + include/ecal/ecal_subscriber_config.h include/ecal/ecal_time.h include/ecal/ecal_timer.h include/ecal/ecal_tlayer.h diff --git a/ecal/core/include/ecal/ecal_publisher_config.h b/ecal/core/include/ecal/ecal_publisher_config.h index 2e1cb099a7..a54cf62a29 100644 --- a/ecal/core/include/ecal/ecal_publisher_config.h +++ b/ecal/core/include/ecal/ecal_publisher_config.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. @@ -88,7 +88,7 @@ #pragma once -#include +#include #include diff --git a/ecal/core/include/ecal/ecal_subscriber_config.h b/ecal/core/include/ecal/ecal_subscriber_config.h new file mode 100644 index 0000000000..5e2221c820 --- /dev/null +++ b/ecal/core/include/ecal/ecal_subscriber_config.h @@ -0,0 +1,68 @@ +/* ========================= 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_subscriber_config.h + * @brief eCAL subscriber configuration +**/ + +#pragma once + +#include + +#include + +namespace eCAL +{ + namespace Subscriber + { + namespace SHM + { + struct ECAL_API Configuration + { + bool enable = false; //!< enable layer + }; + } + + namespace UDP + { + struct ECAL_API Configuration + { + bool enable = false; //!< enable layer + }; + } + + namespace TCP + { + struct ECAL_API Configuration + { + bool enable = false; //!< enable layer + }; + } + + struct ECAL_API Configuration + { + Configuration(); + + SHM::Configuration shm; + UDP::Configuration udp; + TCP::Configuration tcp; + }; + } +} diff --git a/ecal/core/src/ecal_globals.cpp b/ecal/core/src/ecal_globals.cpp index bbcbed89cf..778005b86d 100644 --- a/ecal/core/src/ecal_globals.cpp +++ b/ecal/core/src/ecal_globals.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. @@ -225,13 +225,13 @@ namespace eCAL } ///////////////////// - // CREATE ALL + // START ALL ///////////////////// //if (config_instance) config_instance->Create(); - if (log_instance && ((components_ & Init::Logging) != 0u)) log_instance->Create(); + if (log_instance && ((components_ & Init::Logging) != 0u)) log_instance->Start(); #if ECAL_CORE_REGISTRATION - if (registration_provider_instance) registration_provider_instance->Create(); - if (registration_receiver_instance) registration_receiver_instance->Create(); + if (registration_provider_instance) registration_provider_instance->Start(); + if (registration_receiver_instance) registration_receiver_instance->Start(); #endif if (descgate_instance) { @@ -242,23 +242,23 @@ namespace eCAL #endif } #if defined(ECAL_CORE_REGISTRATION_SHM) || defined(ECAL_CORE_TRANSPORT_SHM) - if (memfile_pool_instance) memfile_pool_instance->Create(); + if (memfile_pool_instance) memfile_pool_instance->Start(); #endif #if ECAL_CORE_SUBSCRIBER if (subgate_instance && ((components_ & Init::Subscriber) != 0u)) subgate_instance->Start(); #endif #if ECAL_CORE_PUBLISHER - if (pubgate_instance && ((components_ & Init::Publisher) != 0u)) pubgate_instance->Create(); + if (pubgate_instance && ((components_ & Init::Publisher) != 0u)) pubgate_instance->Start(); #endif #if ECAL_CORE_SERVICE if (servicegate_instance && ((components_ & Init::Service) != 0u)) servicegate_instance->Start(); if (clientgate_instance && ((components_ & Init::Service) != 0u)) clientgate_instance->Start(); #endif #if ECAL_CORE_TIMEPLUGIN - if (timegate_instance && ((components_ & Init::TimeSync) != 0u)) timegate_instance->Create(CTimeGate::eTimeSyncMode::realtime); + if (timegate_instance && ((components_ & Init::TimeSync) != 0u)) timegate_instance->Start(CTimeGate::eTimeSyncMode::realtime); #endif #if ECAL_CORE_MONITORING - if (monitoring_instance && ((components_ & Init::Monitoring) != 0u)) monitoring_instance->Create(); + if (monitoring_instance && ((components_ & Init::Monitoring) != 0u)) monitoring_instance->Start(); #endif initialized = true; components |= components_; @@ -311,10 +311,10 @@ namespace eCAL // start destruction #if ECAL_CORE_MONITORING - if (monitoring_instance) monitoring_instance->Destroy(); + if (monitoring_instance) monitoring_instance->Stop(); #endif #if ECAL_CORE_TIMEPLUGIN - if (timegate_instance) timegate_instance->Destroy(); + if (timegate_instance) timegate_instance->Stop(); #endif #if ECAL_CORE_SERVICE // The order here is EXTREMELY important! First, the actual service @@ -327,7 +327,7 @@ namespace eCAL if (servicegate_instance) servicegate_instance->Stop(); #endif #if ECAL_CORE_PUBLISHER - if (pubgate_instance) pubgate_instance->Destroy(); + if (pubgate_instance) pubgate_instance->Stop(); #endif #if ECAL_CORE_SUBSCRIBER if (subgate_instance) subgate_instance->Stop(); @@ -341,14 +341,14 @@ namespace eCAL #endif } #if ECAL_CORE_REGISTRATION - if (registration_receiver_instance) registration_receiver_instance->Destroy(); - if (registration_provider_instance) registration_provider_instance->Destroy(); + if (registration_receiver_instance) registration_receiver_instance->Stop(); + if (registration_provider_instance) registration_provider_instance->Stop(); #endif #if defined(ECAL_CORE_REGISTRATION_SHM) || defined(ECAL_CORE_TRANSPORT_SHM) - if (memfile_pool_instance) memfile_pool_instance->Destroy(); - if (memfile_map_instance) memfile_map_instance->Destroy(); + if (memfile_pool_instance) memfile_pool_instance->Stop(); + if (memfile_map_instance) memfile_map_instance->Stop(); #endif - if (log_instance) log_instance->Destroy(); + if (log_instance) log_instance->Stop(); //if (config_instance) config_instance->Destroy(); #if ECAL_CORE_MONITORING diff --git a/ecal/core/src/io/shm/ecal_memfile_db.cpp b/ecal/core/src/io/shm/ecal_memfile_db.cpp index 2533539f82..9c39b132da 100644 --- a/ecal/core/src/io/shm/ecal_memfile_db.cpp +++ b/ecal/core/src/io/shm/ecal_memfile_db.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. @@ -33,10 +33,10 @@ namespace eCAL { CMemFileMap::~CMemFileMap() { - Destroy(); + Stop(); } - void CMemFileMap::Destroy() + void CMemFileMap::Stop() { // lock memory map access const std::lock_guard lock(m_memfile_map_mtx); diff --git a/ecal/core/src/io/shm/ecal_memfile_db.h b/ecal/core/src/io/shm/ecal_memfile_db.h index 98f92aa080..7167a2ac41 100644 --- a/ecal/core/src/io/shm/ecal_memfile_db.h +++ b/ecal/core/src/io/shm/ecal_memfile_db.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,7 +38,7 @@ namespace eCAL CMemFileMap() = default; ~CMemFileMap(); - void Destroy(); + void Stop(); bool AddFile(const std::string& name_, bool create_, size_t len_, SMemFileInfo& mem_file_info_); bool RemoveFile(const std::string& name_, bool remove_); diff --git a/ecal/core/src/io/shm/ecal_memfile_pool.cpp b/ecal/core/src/io/shm/ecal_memfile_pool.cpp index 48e902d076..3e3a778e11 100644 --- a/ecal/core/src/io/shm/ecal_memfile_pool.cpp +++ b/ecal/core/src/io/shm/ecal_memfile_pool.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * Copyright (C) 2022 Eclipse Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -315,10 +315,10 @@ namespace eCAL CMemFileThreadPool::~CMemFileThreadPool() { - Destroy(); + Stop(); } - void CMemFileThreadPool::Create() + void CMemFileThreadPool::Start() { if(m_created) return; @@ -329,7 +329,7 @@ namespace eCAL m_created = true; } - void CMemFileThreadPool::Destroy() + void CMemFileThreadPool::Stop() { if(!m_created) return; diff --git a/ecal/core/src/io/shm/ecal_memfile_pool.h b/ecal/core/src/io/shm/ecal_memfile_pool.h index 3a4785c8a7..7d83e7570a 100644 --- a/ecal/core/src/io/shm/ecal_memfile_pool.h +++ b/ecal/core/src/io/shm/ecal_memfile_pool.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. @@ -94,8 +94,8 @@ namespace eCAL CMemFileThreadPool(); ~CMemFileThreadPool(); - void Create(); - void Destroy(); + void Start(); + void Stop(); bool ObserveFile(const std::string& memfile_name_, const std::string& memfile_event_, const std::string& topic_name_, const std::string& topic_id_, int timeout_observation_ms, const MemFileDataCallbackT& callback_); diff --git a/ecal/core/src/logging/ecal_log_impl.cpp b/ecal/core/src/logging/ecal_log_impl.cpp index a0310e8353..3a8ee3064e 100644 --- a/ecal/core/src/logging/ecal_log_impl.cpp +++ b/ecal/core/src/logging/ecal_log_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. @@ -108,10 +108,10 @@ namespace eCAL CLog::~CLog() { - Destroy(); + Stop(); } - void CLog::Create() + void CLog::Start() { m_hname = Process::GetHostName(); m_pid = Process::GetProcessID(); @@ -165,7 +165,7 @@ namespace eCAL m_created = true; } - void CLog::Destroy() + void CLog::Stop() { if(!m_created) return; diff --git a/ecal/core/src/logging/ecal_log_impl.h b/ecal/core/src/logging/ecal_log_impl.h index f91ea527ad..f0f3e14e40 100644 --- a/ecal/core/src/logging/ecal_log_impl.h +++ b/ecal/core/src/logging/ecal_log_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. @@ -58,14 +58,14 @@ namespace eCAL ~CLog(); /** - * @brief Create log class. + * @brief Start logging. **/ - void Create(); + void Start(); /** - * @brief Destroy log class. + * @brief Stop logging. **/ - void Destroy(); + void Stop(); /** * @brief Sets the log level. diff --git a/ecal/core/src/monitoring/ecal_monitoring_def.cpp b/ecal/core/src/monitoring/ecal_monitoring_def.cpp index 8c7266b3b1..e5f115fa4a 100644 --- a/ecal/core/src/monitoring/ecal_monitoring_def.cpp +++ b/ecal/core/src/monitoring/ecal_monitoring_def.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. @@ -39,12 +39,12 @@ namespace eCAL m_monitoring_impl.reset(); } - void CMonitoring::Create() + void CMonitoring::Start() { m_monitoring_impl->Create(); } - void CMonitoring::Destroy() + void CMonitoring::Stop() { m_monitoring_impl->Destroy(); } diff --git a/ecal/core/src/monitoring/ecal_monitoring_def.h b/ecal/core/src/monitoring/ecal_monitoring_def.h index 725938bfc3..ca567d0c1e 100644 --- a/ecal/core/src/monitoring/ecal_monitoring_def.h +++ b/ecal/core/src/monitoring/ecal_monitoring_def.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. @@ -31,7 +31,7 @@ namespace eCAL { //////////////////////////////////////// - // global database class + // global monitoring class //////////////////////////////////////// class CMonitoringImpl; class CMonitoring @@ -40,8 +40,8 @@ namespace eCAL CMonitoring(); ~CMonitoring(); - void Create(); - void Destroy(); + void Start(); + void Stop(); void SetExclFilter(const std::string& filter_); void SetInclFilter(const std::string& filter_); diff --git a/ecal/core/src/pubsub/ecal_pubgate.cpp b/ecal/core/src/pubsub/ecal_pubgate.cpp index 7a075f7c85..cd624626d6 100644 --- a/ecal/core/src/pubsub/ecal_pubgate.cpp +++ b/ecal/core/src/pubsub/ecal_pubgate.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. @@ -45,16 +45,16 @@ namespace eCAL CPubGate::~CPubGate() { - Destroy(); + Stop(); } - void CPubGate::Create() + void CPubGate::Start() { if(m_created) return; m_created = true; } - void CPubGate::Destroy() + void CPubGate::Stop() { if(!m_created) return; diff --git a/ecal/core/src/pubsub/ecal_pubgate.h b/ecal/core/src/pubsub/ecal_pubgate.h index 770c6c84e2..2714bbeca0 100644 --- a/ecal/core/src/pubsub/ecal_pubgate.h +++ b/ecal/core/src/pubsub/ecal_pubgate.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,8 +41,8 @@ namespace eCAL CPubGate(); ~CPubGate(); - void Create(); - void Destroy(); + void Start(); + void Stop(); void ShareType(bool state_); bool TypeShared() const { return m_share_type; }; diff --git a/ecal/core/src/pubsub/ecal_subscriber_config.cpp b/ecal/core/src/pubsub/ecal_subscriber_config.cpp new file mode 100644 index 0000000000..45a7becd78 --- /dev/null +++ b/ecal/core/src/pubsub/ecal_subscriber_config.cpp @@ -0,0 +1,43 @@ +/* ========================= 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 eCAL subscriber configuration +**/ + +#include +#include + +namespace eCAL +{ + namespace Subscriber + { + Configuration::Configuration() + { + // shm config + shm.enable = eCAL::Config::IsShmRecEnabled(); + + // udp config + udp.enable = eCAL::Config::IsUdpMulticastRecEnabled(); + + // tcp config + tcp.enable = eCAL::Config::IsTcpRecEnabled(); + } + } +} diff --git a/ecal/core/src/registration/ecal_registration_provider.cpp b/ecal/core/src/registration/ecal_registration_provider.cpp index 21f06ab45b..90cf714803 100644 --- a/ecal/core/src/registration/ecal_registration_provider.cpp +++ b/ecal/core/src/registration/ecal_registration_provider.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. @@ -55,10 +55,10 @@ namespace eCAL CRegistrationProvider::~CRegistrationProvider() { - Destroy(); + Stop(); } - void CRegistrationProvider::Create() + void CRegistrationProvider::Start() { if(m_created) return; @@ -97,7 +97,7 @@ namespace eCAL m_created = true; } - void CRegistrationProvider::Destroy() + void CRegistrationProvider::Stop() { if(!m_created) return; diff --git a/ecal/core/src/registration/ecal_registration_provider.h b/ecal/core/src/registration/ecal_registration_provider.h index bfd0d2e3fb..098a9ef2da 100644 --- a/ecal/core/src/registration/ecal_registration_provider.h +++ b/ecal/core/src/registration/ecal_registration_provider.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. @@ -53,8 +53,8 @@ namespace eCAL CRegistrationProvider(); ~CRegistrationProvider(); - void Create(); - void Destroy(); + void Start(); + void Stop(); bool ApplySample(const Registration::Sample& sample_, bool force_); diff --git a/ecal/core/src/registration/ecal_registration_receiver.cpp b/ecal/core/src/registration/ecal_registration_receiver.cpp index 002bd0fed1..1ef8bfbf08 100644 --- a/ecal/core/src/registration/ecal_registration_receiver.cpp +++ b/ecal/core/src/registration/ecal_registration_receiver.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. @@ -62,10 +62,10 @@ namespace eCAL CRegistrationReceiver::~CRegistrationReceiver() { - Destroy(); + Stop(); } - void CRegistrationReceiver::Create() + void CRegistrationReceiver::Start() { if(m_created) return; @@ -101,7 +101,7 @@ namespace eCAL m_created = true; } - void CRegistrationReceiver::Destroy() + void CRegistrationReceiver::Stop() { if(!m_created) return; diff --git a/ecal/core/src/registration/ecal_registration_receiver.h b/ecal/core/src/registration/ecal_registration_receiver.h index 15a4945d20..2c58749cfe 100644 --- a/ecal/core/src/registration/ecal_registration_receiver.h +++ b/ecal/core/src/registration/ecal_registration_receiver.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. @@ -53,8 +53,8 @@ namespace eCAL CRegistrationReceiver(); ~CRegistrationReceiver(); - void Create(); - void Destroy(); + void Start(); + void Stop(); void EnableLoopback(bool state_); diff --git a/ecal/core/src/time/ecal_timegate.cpp b/ecal/core/src/time/ecal_timegate.cpp index 9594734627..1d1495ed1d 100644 --- a/ecal/core/src/time/ecal_timegate.cpp +++ b/ecal/core/src/time/ecal_timegate.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. @@ -67,10 +67,10 @@ namespace eCAL CTimeGate::~CTimeGate() { - Destroy(); + Stop(); } - void CTimeGate::Create(enum eTimeSyncMode sync_mode_) + void CTimeGate::Start(enum eTimeSyncMode sync_mode_) { if(m_created) return; @@ -109,7 +109,7 @@ namespace eCAL m_created = true; } - void CTimeGate::Destroy() + void CTimeGate::Stop() { if(!m_created) return; switch (m_sync_mode) diff --git a/ecal/core/src/time/ecal_timegate.h b/ecal/core/src/time/ecal_timegate.h index ccd9938936..76b5863656 100644 --- a/ecal/core/src/time/ecal_timegate.h +++ b/ecal/core/src/time/ecal_timegate.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. @@ -67,8 +67,8 @@ namespace eCAL CTimeGate(); ~CTimeGate(); - void Create(enum eTimeSyncMode sync_mode_); - void Destroy(); + void Start(enum eTimeSyncMode sync_mode_); + void Stop(); std::string GetName(); From 4123770b00a686551a329ccd9e594f98eabf2cd3 Mon Sep 17 00:00:00 2001 From: rex-schilasky <49162693+rex-schilasky@users.noreply.github.com> Date: Fri, 17 May 2024 11:52:28 +0200 Subject: [PATCH 2/2] eCAL::CSubscriber API configurable --- ecal/core/include/ecal/ecal_subscriber.h | 24 ++++++++++++++---------- ecal/core/src/pubsub/ecal_subscriber.cpp | 24 ++++++++++++------------ 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/ecal/core/include/ecal/ecal_subscriber.h b/ecal/core/include/ecal/ecal_subscriber.h index 17332d1f62..0ed5ea9f80 100644 --- a/ecal/core/include/ecal/ecal_subscriber.h +++ b/ecal/core/include/ecal/ecal_subscriber.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. @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -92,17 +93,19 @@ namespace eCAL /** * @brief Constructor. * - * @param topic_name_ Unique topic name. - * @param topic_info_ Topic information (encoding, type, descriptor) + * @param topic_name_ Unique topic name. + * @param data_type_info_ Topic data type information (encoding, type, descriptor). + * @param config_ Optional configuration parameters. **/ - ECAL_API CSubscriber(const std::string& topic_name_, const SDataTypeInformation& topic_info_); + ECAL_API CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const Subscriber::Configuration& config_ = {}); /** * @brief Constructor. * - * @param topic_name_ Unique topic name. + * @param topic_name_ Unique topic name. + * @param data_type_info_ Topic data type information (encoding, type, descriptor). **/ - ECAL_API explicit CSubscriber(const std::string& topic_name_); + ECAL_API explicit CSubscriber(const std::string& topic_name_, const Subscriber::Configuration& config_ = {}); /** * @brief Destructor. @@ -132,21 +135,22 @@ namespace eCAL /** * @brief Creates this object. * - * @param topic_name_ Unique topic name. + * @param topic_name_ Unique topic name. + * @param data_type_info_ Topic data type information (encoding, type, descriptor). + * @param config_ Optional configuration parameters. * * @return True if it succeeds, false if it fails. **/ - ECAL_API bool Create(const std::string& topic_name_); + ECAL_API bool Create(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const Subscriber::Configuration& config_ = {}); /** * @brief Creates this object. * * @param topic_name_ Unique topic name. - * @param topic_info_ Topic information (encoding, type, descriptor) * * @return True if it succeeds, false if it fails. **/ - ECAL_API bool Create(const std::string& topic_name_, const SDataTypeInformation& topic_info_); + ECAL_API bool Create(const std::string& topic_name_); /** * @brief Destroys this object. diff --git a/ecal/core/src/pubsub/ecal_subscriber.cpp b/ecal/core/src/pubsub/ecal_subscriber.cpp index d1338001fa..0086f32afa 100644 --- a/ecal/core/src/pubsub/ecal_subscriber.cpp +++ b/ecal/core/src/pubsub/ecal_subscriber.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,14 +40,14 @@ namespace eCAL { } - CSubscriber::CSubscriber(const std::string& topic_name_, const SDataTypeInformation& topic_info_) + CSubscriber::CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const Subscriber::Configuration& config_) : CSubscriber() { - CSubscriber::Create(topic_name_, topic_info_); + CSubscriber::Create(topic_name_, data_type_info_, config_); } - CSubscriber::CSubscriber(const std::string& topic_name_) - : CSubscriber(topic_name_, SDataTypeInformation{}) + CSubscriber::CSubscriber(const std::string& topic_name_, const Subscriber::Configuration& config_) + : CSubscriber(topic_name_, SDataTypeInformation{}, config_) {} CSubscriber::~CSubscriber() @@ -75,18 +75,13 @@ namespace eCAL return *this; } - bool CSubscriber::Create(const std::string& topic_name_) - { - return Create(topic_name_, SDataTypeInformation{}); - } - - bool CSubscriber::Create(const std::string& topic_name_, const SDataTypeInformation& topic_info_) + bool CSubscriber::Create(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const Subscriber::Configuration& config_) { if (m_created) return(false); if (topic_name_.empty()) return(false); // create datareader - m_datareader = std::make_shared(topic_name_, topic_info_); + m_datareader = std::make_shared(topic_name_, data_type_info_); // register datareader g_subgate()->Register(topic_name_, m_datareader); @@ -96,6 +91,11 @@ namespace eCAL return(m_created); } + bool CSubscriber::Create(const std::string& topic_name_) + { + return Create(topic_name_, SDataTypeInformation{}); + } + bool CSubscriber::Destroy() { if(!m_created) return(false);