Skip to content

Commit

Permalink
[core] eCAL core v5 compatibility modus (part 1) (#1930)
Browse files Browse the repository at this point in the history
* [core] Create two targets: core & core_v5 compatibility target.
KerstinKeller authored Jan 22, 2025
1 parent c601d1d commit b411864
Showing 59 changed files with 750 additions and 628 deletions.
4 changes: 2 additions & 2 deletions app/play/play_core/src/measurement_container.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
* Copyright (C) 2016 - 2025 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,7 @@
#include <memory>

#include <ecal/ecal.h>
#include <ecal/ecal_publisher_v5.h>
#include <ecal/v5/ecal_publisher.h>
#include <ecalhdf5/eh5_meas.h>

#include "continuity_report.h"
94 changes: 60 additions & 34 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ if(UNIX)
endif()
endif()

macro(add_ecal_core_library TARGET_NAME)
######################################
# config
######################################
@@ -213,9 +214,9 @@ if(ECAL_CORE_PUBLISHER)
src/pubsub/ecal_publisher.cpp
src/pubsub/ecal_publisher_impl.cpp
src/pubsub/ecal_publisher_impl.h
src/pubsub/ecal_publisher_v5.cpp
src/pubsub/ecal_pubgate.cpp
src/pubsub/ecal_pubgate.h
src/v5/pubsub/ecal_publisher.cpp
)
endif()

@@ -224,9 +225,9 @@ if(ECAL_CORE_SUBSCRIBER)
src/pubsub/ecal_subscriber.cpp
src/pubsub/ecal_subscriber_impl.cpp
src/pubsub/ecal_subscriber_impl.h
src/pubsub/ecal_subscriber_v5.cpp
src/pubsub/ecal_subgate.cpp
src/pubsub/ecal_subgate.h
src/v5/pubsub/ecal_subscriber.cpp
)
endif()

@@ -390,17 +391,17 @@ if(ECAL_CORE_SERVICE)
src/service/ecal_service_client_impl.cpp
src/service/ecal_service_client_impl.h
src/service/ecal_service_client_instance.cpp
src/service/ecal_service_client_v5.cpp
src/service/ecal_service_client_v5_impl.cpp
src/service/ecal_service_client_v5_impl.h
src/service/ecal_service_server.cpp
src/service/ecal_service_server_impl.cpp
src/service/ecal_service_server_impl.h
src/service/ecal_service_server_v5.cpp
src/service/ecal_service_server_v5_impl.cpp
src/service/ecal_service_server_v5_impl.h
src/service/ecal_service_singleton_manager.cpp
src/service/ecal_service_singleton_manager.h
src/v5/service/ecal_service_client.cpp
src/v5/service/ecal_service_client_impl.cpp
src/v5/service/ecal_service_client_impl.h
src/v5/service/ecal_service_server.cpp
src/v5/service/ecal_service_server_impl.cpp
src/v5/service/ecal_service_server_impl.h
)
endif()

@@ -533,10 +534,10 @@ set(ecal_header_cmn
include/ecal/types/monitoring.h
include/ecal/ecal.h
include/ecal/ecal_callback.h
include/ecal/ecal_callback_v5.h
include/ecal/v5/ecal_callback.h
include/ecal/ecal_client.h
include/ecal/ecal_client_instance.h
include/ecal/ecal_client_v5.h
include/ecal/v5/ecal_client.h
include/ecal/ecal_config.h
include/ecal/ecal_core.h
include/ecal/ecal_deprecate.h
@@ -546,16 +547,17 @@ set(ecal_header_cmn
include/ecal/ecal_os.h
include/ecal/ecal_payload_writer.h
include/ecal/ecal_monitoring.h
include/ecal/ecal_namespace.h
include/ecal/ecal_process.h
include/ecal/ecal_process_severity.h
include/ecal/ecal_registration.h
include/ecal/ecal_publisher.h
include/ecal/ecal_publisher_v5.h
include/ecal/v5/ecal_publisher.h
include/ecal/ecal_server.h
include/ecal/ecal_server_v5.h
include/ecal/v5/ecal_server.h
include/ecal/ecal_service_info.h
include/ecal/ecal_subscriber.h
include/ecal/ecal_subscriber_v5.h
include/ecal/v5/ecal_subscriber.h
include/ecal/ecal_time.h
include/ecal/ecal_timer.h
include/ecal/ecal_tlayer.h
@@ -597,22 +599,22 @@ set(ecal_sources
${ecal_header_msg}
)

ecal_add_shared_library(${PROJECT_NAME}
ecal_add_shared_library(${TARGET_NAME}
${ecal_sources}
${CMAKE_CURRENT_BINARY_DIR}/include/ecal/ecal_defs.h
)

if (ECAL_CORE_CONFIGURATION)
target_compile_definitions(${PROJECT_NAME} PRIVATE ECAL_CORE_CONFIGURATION)
target_compile_definitions(${TARGET_NAME} PRIVATE ECAL_CORE_CONFIGURATION)
endif()

if(UNIX)
set_source_files_properties(src/util/convert_utf.cpp PROPERTIES COMPILE_FLAGS -Wno-implicit-fallthrough)
endif()

add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
add_library(eCAL::${TARGET_NAME} ALIAS ${TARGET_NAME})

target_compile_definitions(${PROJECT_NAME}
target_compile_definitions(${TARGET_NAME}
PUBLIC
ASIO_STANDALONE
ASIO_DISABLE_VISIBILITY
@@ -626,7 +628,7 @@ target_compile_definitions(${PROJECT_NAME}
ECAL_CORE_IMPORTS
)

set_target_properties(${PROJECT_NAME}
set_target_properties(${TARGET_NAME}
PROPERTIES
CXX_VISIBILITY_PRESET hidden
C_VISIBILITY_PRESET hidden
@@ -651,45 +653,45 @@ set(ECAL_CORE_FEATURES

foreach(CORE_FEATURE ${ECAL_CORE_FEATURES})
if(${CORE_FEATURE})
target_compile_definitions(${PROJECT_NAME}
target_compile_definitions(${TARGET_NAME}
PUBLIC ${CORE_FEATURE})
endif()
endforeach()

if(ECAL_CORE_CONFIGURATION)
target_link_libraries(${PROJECT_NAME}
target_link_libraries(${TARGET_NAME}
PRIVATE
yaml-cpp::yaml-cpp
)
endif()

if(ECAL_CORE_COMMAND_LINE)
target_link_libraries(${PROJECT_NAME}
target_link_libraries(${TARGET_NAME}
PRIVATE
tclap::tclap
)
endif()

if(ECAL_CORE_SERVICE)
target_link_libraries(${PROJECT_NAME}
target_link_libraries(${TARGET_NAME}
PRIVATE
ecal_service
)
endif()

if(ECAL_CORE_TRANSPORT_TCP)
target_link_libraries(${PROJECT_NAME}
target_link_libraries(${TARGET_NAME}
PRIVATE
tcp_pubsub::tcp_pubsub
)
endif()

target_link_libraries(${PROJECT_NAME}
target_link_libraries(${TARGET_NAME}
PRIVATE
ecaludp::ecaludp
)

target_include_directories(${PROJECT_NAME}
target_include_directories(${TARGET_NAME}
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/serialization/>
@@ -700,7 +702,7 @@ target_include_directories(${PROJECT_NAME}
$<INSTALL_INTERFACE:include>
)

target_link_libraries(${PROJECT_NAME}
target_link_libraries(${TARGET_NAME}
PRIVATE
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${QNXNTO}>>>:dl>
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>,$<NOT:$<BOOL:${QNXNTO}>>>:rt>
@@ -717,10 +719,40 @@ target_link_libraries(${PROJECT_NAME}
eCAL::ecal-utils
)

set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER core)
set_property(TARGET ${TARGET_NAME} PROPERTY FOLDER core)

ecal_install_shared_library(${PROJECT_NAME})
ecal_install_shared_library(${TARGET_NAME})

if(NOT ${CMAKE_VERSION} VERSION_LESS "3.8.0")
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES
${ecal_sources}
)
endif()

endmacro()

#######################################
# We now create two libraries
# One of them is a compatibility version that should facilitate easier migration.
# ecal_core, ecal_core_v5.
#######################################

add_ecal_core_library(${PROJECT_NAME})
target_compile_definitions(${PROJECT_NAME}
PUBLIC
ECAL_CORE_V5_FUNCTIONALTIY=1
)

add_ecal_core_library(core_v5)
target_compile_definitions(core_v5
PUBLIC
ECAL_CORE_NAMESPACE_V5_INLINE=1
ECAL_CORE_V5_FUNCTIONALTIY=1
)

###
## Iinstall header files only once...
##
install(DIRECTORY
"include/" DESTINATION "${INSTALL_INCLUDE_DIR}" COMPONENT sdk
FILES_MATCHING PATTERN "*.h")
@@ -730,12 +762,6 @@ install(DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}/include/" DESTINATION "${INSTALL_INCLUDE_DIR}" COMPONENT sdk
FILES_MATCHING PATTERN "*.h")

if(NOT ${CMAKE_VERSION} VERSION_LESS "3.8.0")
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES
${ecal_sources}
)
endif()

# eCAL process stub
if(UNIX)
set(PROJECT_NAME_PROCESS_STUB process_stub)
3 changes: 2 additions & 1 deletion ecal/core/include/ecal/ecal_callback.h
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
#pragma once

#include <ecal/ecal_deprecate.h>
#include <ecal/ecal_namespace.h>
#include <ecal/ecal_types.h>

#include <functional>
@@ -130,7 +131,7 @@ namespace eCAL
**/
using TimerCallbackT = std::function<void()>;

inline namespace v6
ECAL_CORE_NAMESPACE_V6
{
/**
* @brief Receive callback function type with topic id and data struct. The topic id contains the topic name, the process
5 changes: 3 additions & 2 deletions ecal/core/include/ecal/ecal_client.h
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
#pragma once

#include <ecal/ecal_deprecate.h>
#include <ecal/ecal_namespace.h>
#include <ecal/ecal_os.h>

#include <ecal/ecal_callback.h>
@@ -40,7 +41,7 @@ namespace eCAL
{
class CServiceClientImpl;

inline namespace v6
ECAL_CORE_NAMESPACE_V6
{
/**
* @brief Service client wrapper class.
@@ -157,7 +158,7 @@ namespace eCAL
bool IsConnected() const;

private:
std::shared_ptr<eCAL::CServiceClientImpl> m_service_client_impl;
std::shared_ptr<eCAL::v6::CServiceClientImpl> m_service_client_impl;
};
}
}
13 changes: 8 additions & 5 deletions ecal/core/include/ecal/ecal_client_instance.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
* Copyright (C) 2016 - 2025 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,14 +35,17 @@

namespace eCAL
{
class CServiceClientImpl;
ECAL_CORE_NAMESPACE_V6
{
class CServiceClientImpl;
}

class ECAL_API_CLASS CClientInstance final
{
public:
// Constructor
ECAL_API_EXPORTED_MEMBER
CClientInstance(const Registration::SEntityId& entity_id_, const std::shared_ptr<CServiceClientImpl>& service_client_id_impl_);
CClientInstance(const Registration::SEntityId& entity_id_, const std::shared_ptr<v6::CServiceClientImpl>& service_client_id_impl_);

// Defaulted destructor
~CClientInstance() = default;
@@ -109,7 +112,7 @@ namespace eCAL
Registration::SEntityId GetClientID() const;

private:
Registration::SEntityId m_entity_id;
const std::shared_ptr<eCAL::CServiceClientImpl> m_service_client_impl;
Registration::SEntityId m_entity_id;
const std::shared_ptr<eCAL::v6::CServiceClientImpl> m_service_client_impl;
};
}
34 changes: 34 additions & 0 deletions ecal/core/include/ecal/ecal_namespace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2025 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_namespace.h
* @brief eCAL namespace definitions (for switching between v5 / v6 namespaces
**/

#pragma once

#if ECAL_CORE_NAMESPACE_V5_INLINE
#define ECAL_CORE_NAMESPACE_V5 inline namespace v5
#define ECAL_CORE_NAMESPACE_V6 namespace v6
#else
#define ECAL_CORE_NAMESPACE_V5 namespace v5
#define ECAL_CORE_NAMESPACE_V6 inline namespace v6
#endif

3 changes: 2 additions & 1 deletion ecal/core/include/ecal/ecal_publisher.h
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
#pragma once

#include <ecal/ecal_deprecate.h>
#include <ecal/ecal_namespace.h>
#include <ecal/ecal_os.h>

#include <ecal/ecal_callback.h>
@@ -39,7 +40,7 @@ namespace eCAL
{
class CPublisherImpl;

inline namespace v6
ECAL_CORE_NAMESPACE_V6
{
/**
* @brief eCAL publisher class.
Loading

0 comments on commit b411864

Please sign in to comment.