Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ set(ecal_config_src
src/config/configuration.cpp
src/config/ecal_path_processing.cpp
src/config/ecal_path_processing.h
src/config/shm_mutex.cpp
src/types/ecal_custom_data_types.cpp
)
if (ECAL_CORE_CONFIGURATION)
Expand Down Expand Up @@ -803,8 +804,7 @@ set_target_properties(core
VISIBILITY_INLINES_HIDDEN ON
)

target_compile_features(core INTERFACE cxx_std_14)
target_compile_features(core PRIVATE cxx_std_17)
target_compile_features(core PUBLIC cxx_std_17)

set_property(TARGET core PROPERTY FOLDER core)
endmacro()
Expand Down
12 changes: 1 addition & 11 deletions ecal/core/cfg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ set(ECAL_GENERATED_YAML_PATH ${ECAL_YAML_PATH} CACHE INTERNAL "Path to the gener

add_executable(${PROJECT_NAME}
${ECAL_CORE_PROJECT_ROOT}/core/cfg/generate_configuration_yaml.cpp
${ECAL_CORE_PROJECT_ROOT}/core/src/config/configuration_writer.cpp
${ECAL_CORE_PROJECT_ROOT}/core/src/config/default_configuration.cpp
${ECAL_CORE_PROJECT_ROOT}/core/src/config/ecal_path_processing.cpp
)

# Set the output paths for the generated YAML files
Expand All @@ -57,17 +54,10 @@ add_custom_target(run_${PROJECT_NAME} ALL
# Ensure the executable is built before running the custom target
add_dependencies(run_${PROJECT_NAME} ${PROJECT_NAME})

# Specify include directories for the executable
target_include_directories(${PROJECT_NAME} PRIVATE
${ECAL_CORE_PROJECT_ROOT}/core/src
${ECAL_CORE_PROJECT_ROOT}/core/include
)

target_link_libraries(${PROJECT_NAME}
PRIVATE
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${QNXNTO}>>>:dl>
eCAL::core
eCAL::ecal-utils
ecal_core_private
)

# Select the correct ecal config directory on Linux and Windows
Expand Down
26 changes: 25 additions & 1 deletion ecal/core/include/ecal/config/transport_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include <ecal/types/custom_data_types.h>
#include <ecal/os.h>

#include <optional>
#include <string_view>


namespace eCAL
{
namespace TransportLayer
Expand Down Expand Up @@ -79,10 +83,30 @@ namespace eCAL
};
}

namespace SHM
{
enum class eMutexType : std::uint8_t
{
mutex,
recoverable_mutex
};

ECAL_API eMutexType DefaultMutexType();
ECAL_API std::string_view ToString(eMutexType mutex_type);
ECAL_API std::optional<eMutexType> FromString(std::string_view mutex_type_string);


struct Configuration
{
eMutexType mutex_type { DefaultMutexType() };
};
}

struct Configuration
{
UDP::Configuration udp;
TCP::Configuration tcp;
SHM::Configuration shm;
};
}
}
}
1 change: 1 addition & 0 deletions ecal/core/src/config/configuration_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "configuration_reader.h"
#include "configuration_to_yaml.h"

namespace
{
Expand Down
2 changes: 0 additions & 2 deletions ecal/core/src/config/configuration_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#endif
#include <yaml-cpp/yaml.h>

#include "configuration_to_yaml.h"

#include <fstream>
#include <stack>
#include <utility>
Expand Down
36 changes: 35 additions & 1 deletion ecal/core/src/config/configuration_to_yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
// utility functions for yaml node handling
namespace YAML
{
std::string ShmMutexTypeToString(const eCAL::TransportLayer::SHM::eMutexType type)
{
using namespace eCAL::TransportLayer::SHM;
return ToString(type).data();
}

void ParseShmMutexType(const std::string& text, eCAL::TransportLayer::SHM::eMutexType& out)
{
using namespace eCAL::TransportLayer::SHM;
if (auto mutex_type = FromString(text); mutex_type.has_value())
{
out = mutex_type.value();
}
}

eCAL::Logging::Filter ParseLogLevel(const std::vector<std::string>& filter_)
{
// create excluding filter list
Expand Down Expand Up @@ -281,12 +296,29 @@ namespace YAML
AssignValue<eCAL::TransportLayer::UDP::MulticastConfiguration>(config_.local, node_, "local");
return true;
}

Node convert<eCAL::TransportLayer::SHM::Configuration>::encode(const eCAL::TransportLayer::SHM::Configuration& config_)
{
Node node;
node["mutex_type"] = ShmMutexTypeToString(config_.mutex_type);
return node;
}

bool convert<eCAL::TransportLayer::SHM::Configuration>::decode(const Node& node_, eCAL::TransportLayer::SHM::Configuration& config_)
{
if (node_["mutex_type"])
{
ParseShmMutexType(node_["mutex_type"].as<std::string>(), config_.mutex_type);
}
return true;
}

Node convert<eCAL::TransportLayer::Configuration>::encode(const eCAL::TransportLayer::Configuration& config_)
{
Node node;
node["udp"] = config_.udp;
node["tcp"] = config_.tcp;
node["shm"] = config_.shm;

return node;
}
Expand All @@ -295,6 +327,7 @@ namespace YAML
{
AssignValue<eCAL::TransportLayer::UDP::Configuration>(config_.udp, node_, "udp");
AssignValue<eCAL::TransportLayer::TCP::Configuration>(config_.tcp, node_, "tcp");
AssignValue<eCAL::TransportLayer::SHM::Configuration>(config_.shm, node_, "shm");
return true;
}

Expand Down Expand Up @@ -680,6 +713,7 @@ namespace YAML
Node convert<eCAL::Configuration>::encode(const eCAL::Configuration& config_)
{
Node node;
node["transport_layer"] = config_.transport_layer;
node["publisher"] = config_.publisher;
node["subscriber"] = config_.subscriber;
node["registration"] = config_.registration;
Expand Down Expand Up @@ -707,4 +741,4 @@ namespace YAML

return true;
}
}
}
10 changes: 9 additions & 1 deletion ecal/core/src/config/configuration_to_yaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ namespace YAML
static bool decode(const Node& node_, eCAL::TransportLayer::Configuration& config_);
};

template<>
struct convert<eCAL::TransportLayer::SHM::Configuration>
{
static Node encode(const eCAL::TransportLayer::SHM::Configuration& config_);

static bool decode(const Node& node_, eCAL::TransportLayer::SHM::Configuration& config_);
};


/*
___ __ ___ __
Expand Down Expand Up @@ -359,4 +367,4 @@ namespace YAML
};
}

#endif // CONFIGURATION_TO_YAML_H
#endif // CONFIGURATION_TO_YAML_H
20 changes: 18 additions & 2 deletions ecal/core/src/config/default_configuration.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "default_configuration.h"

#include "ecal/config.h"
#include "config/configuration_to_yaml.h"

#include <string>

Expand Down Expand Up @@ -138,6 +139,12 @@ namespace
{
return std::string("\"") + ip_.Get() + std::string("\"");
}

std::string quoteString(const eCAL::TransportLayer::SHM::eMutexType type_)
{
using namespace eCAL::TransportLayer::SHM;
return std::string("\"") + ToString(type_).data() + std::string("\"");
}
}

namespace eCAL
Expand Down Expand Up @@ -248,6 +255,11 @@ namespace eCAL
ss << R"( # Reconnection attemps the session will try to reconnect in case of an issue)" << "\n";
ss << R"( max_reconnections: )" << config_.transport_layer.tcp.max_reconnections << "\n";
ss << R"()" << "\n";
ss << R"( shm:)" << "\n";
ss << R"( # Named mutex mode for shared-memory synchronization)" << "\n";
ss << R"( # Options: "mutex", "recoverable_mutex")" << "\n";
ss << R"( mutex_type: )" << quoteString(config_.transport_layer.shm.mutex_type) << "\n";
ss << R"()" << "\n";
ss << R"()" << "\n";
ss << R"(# Publisher specific base settings)" << "\n";
ss << R"(publisher:)" << "\n";
Expand All @@ -256,6 +268,8 @@ namespace eCAL
ss << R"( shm:)" << "\n";
ss << R"( # Enable layer)" << "\n";
ss << R"( enable: )" << config_.publisher.layer.shm.enable << "\n";
ss << R"( # Optional override. If omitted, inherits transport_layer.shm.mutex_type)" << "\n";
ss << R"( # mutex_type: "recoverable_mutex")" << "\n";
ss << R"( # Enable zero copy shared memory transport mode)" << "\n";
ss << R"( zero_copy_mode: )" << config_.publisher.layer.shm.zero_copy_mode << "\n";
ss << R"( # Force connected subscribers to send acknowledge event after processing the message.)" << "\n";
Expand All @@ -276,7 +290,7 @@ namespace eCAL
ss << R"( # Base configuration for TCP publisher)" << "\n";
ss << R"( tcp:)" << "\n";
ss << R"( # Enable layer)" << "\n";
ss << R"( enable: )" << config_.publisher.layer.shm.enable << "\n";
ss << R"( enable: )" << config_.publisher.layer.tcp.enable << "\n";
ss << R"()" << "\n";
ss << R"( # Priority list for layer usage in local mode (Default: SHM > UDP > TCP))" << "\n";
ss << R"( priority_local: )" << quoteString(config_.publisher.layer_priority_local) << "\n";
Expand All @@ -291,6 +305,8 @@ namespace eCAL
ss << R"( shm:)" << "\n";
ss << R"( # Enable layer)" << "\n";
ss << R"( enable: )" << config_.subscriber.layer.shm.enable << "\n";
ss << R"( # Optional override. If omitted, inherits transport_layer.shm.mutex_type)" << "\n";
ss << R"( # mutex_type: "recoverable_mutex")" << "\n";
ss << R"()" << "\n";
ss << R"( # Base configuration for UDP subscriber)" << "\n";
ss << R"( udp:)" << "\n";
Expand Down Expand Up @@ -402,4 +418,4 @@ namespace eCAL
return ss;
}
}
}
}
53 changes: 53 additions & 0 deletions ecal/core/src/config/shm_mutex.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2026 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 <ecal/config/transport_layer.h>
#include "io/mtx/shm_mutex_resolution.h"

namespace eCAL::TransportLayer::SHM
{
eMutexType DefaultMutexType()
{
return detail::DefaultSemanticMutexType();
}

std::string_view ToString(eMutexType mutex_type)
{
switch (mutex_type)
{
case eMutexType::mutex:
return "mutex";
case eMutexType::recoverable_mutex:
return "recoverable_mutex";
default:
return "mutex";
}
}

std::optional<eMutexType> FromString(std::string_view mutex_type_string)
{
if (mutex_type_string == "mutex")
return eMutexType::mutex;

if (mutex_type_string == "recoverable_mutex")
return eMutexType::recoverable_mutex;

return std::nullopt;
}
}
Loading
Loading