Skip to content

Commit

Permalink
subscriber configuration introduced
Browse files Browse the repository at this point in the history
global Create/Destroy renamed to Start/Stop
  • Loading branch information
rex-schilasky committed May 17, 2024
1 parent 2bb37a3 commit 2fb0bc2
Show file tree
Hide file tree
Showing 21 changed files with 189 additions and 76 deletions.
4 changes: 3 additions & 1 deletion ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/ecal_publisher_config.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -88,7 +88,7 @@

#pragma once

#include <ecal/ecal_tlayer.h>
#include <ecal/ecal_os.h>

#include <cstddef>

Expand Down
68 changes: 68 additions & 0 deletions ecal/core/include/ecal/ecal_subscriber_config.h
Original file line number Diff line number Diff line change
@@ -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 <ecal/ecal_os.h>

#include <cstddef>

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;
};
}
}
34 changes: 17 additions & 17 deletions ecal/core/src/ecal_globals.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
{
Expand All @@ -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_;
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/io/shm/ecal_memfile_db.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -33,10 +33,10 @@ namespace eCAL
{
CMemFileMap::~CMemFileMap()
{
Destroy();
Stop();
}

void CMemFileMap::Destroy()
void CMemFileMap::Stop()
{
// lock memory map access
const std::lock_guard<std::mutex> lock(m_memfile_map_mtx);
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/io/shm/ecal_memfile_db.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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_);
Expand Down
8 changes: 4 additions & 4 deletions ecal/core/src/io/shm/ecal_memfile_pool.cpp
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -315,10 +315,10 @@ namespace eCAL

CMemFileThreadPool::~CMemFileThreadPool()
{
Destroy();
Stop();
}

void CMemFileThreadPool::Create()
void CMemFileThreadPool::Start()
{
if(m_created) return;

Expand All @@ -329,7 +329,7 @@ namespace eCAL
m_created = true;
}

void CMemFileThreadPool::Destroy()
void CMemFileThreadPool::Stop()
{
if(!m_created) return;

Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/io/shm/ecal_memfile_pool.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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_);

Expand Down
8 changes: 4 additions & 4 deletions ecal/core/src/logging/ecal_log_impl.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -108,10 +108,10 @@ namespace eCAL

CLog::~CLog()
{
Destroy();
Stop();
}

void CLog::Create()
void CLog::Start()
{
m_hname = Process::GetHostName();
m_pid = Process::GetProcessID();
Expand Down Expand Up @@ -165,7 +165,7 @@ namespace eCAL
m_created = true;
}

void CLog::Destroy()
void CLog::Stop()
{
if(!m_created) return;

Expand Down
10 changes: 5 additions & 5 deletions ecal/core/src/logging/ecal_log_impl.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/monitoring/ecal_monitoring_def.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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();
}
Expand Down
Loading

0 comments on commit 2fb0bc2

Please sign in to comment.