Skip to content
Open
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
1 change: 0 additions & 1 deletion .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ jobs:
- uses: ./.github/actions/build-cmake-preset
with:
preset-name: release
cmake-args: "-DCMAKE_POLICY_VERSION_MINIMUM=3.5"
artifact-label: ${{ github.job }}
2 changes: 1 addition & 1 deletion .github/workflows/build-mingw64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ jobs:
with:
preset-name: release
artifact-label: ${{ github.job }}-${{ matrix.builds.arch }}
cmake-args: -D SILKIT_BUILD_DOCS=OFF -D SILKIT_BUILD_DASHBOARD=OFF
cmake-args: -D SILKIT_BUILD_DOCS=OFF
extra-path: "${{ matrix.builds.bin }}:"
shell: C:\shells\msys2bash.cmd {0}
3 changes: 1 addition & 2 deletions .github/workflows/linux-asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ jobs:
- uses: ./.github/actions/build-cmake-preset
with:
preset-name: relwithdebinfo
cmake-args: "-D SILKIT_BUILD_DASHBOARD=OFF \
-DCMAKE_C_COMPILER=clang-18 \
cmake-args: "-DCMAKE_C_COMPILER=clang-18 \
-DCMAKE_CXX_COMPILER=clang++-18 \
-DCMAKE_CXX_FLAGS='-fsanitize=address -fno-omit-frame-pointer' \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO='-Og -g3'"
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/linux-tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ jobs:
- uses: ./.github/actions/build-cmake-preset
with:
preset-name: relwithdebinfo
cmake-args: "-D SILKIT_BUILD_DASHBOARD=OFF \
-DCMAKE_C_COMPILER=clang-18 \
cmake-args: "-DCMAKE_C_COMPILER=clang-18 \
-DCMAKE_CXX_COMPILER=clang++-18 \
-DCMAKE_CXX_FLAGS='-fsanitize=thread -fno-omit-frame-pointer' \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO='-Og -g3'"
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/linux-ubsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ jobs:
- uses: ./.github/actions/build-cmake-preset
with:
preset-name: relwithdebinfo
cmake-args: "-D SILKIT_BUILD_DASHBOARD=OFF \
-DCMAKE_C_COMPILER=clang-18 \
cmake-args: "-DCMAKE_C_COMPILER=clang-18 \
-DCMAKE_CXX_COMPILER=clang++-18 \
-DCMAKE_CXX_FLAGS='-fsanitize=undefined -fno-omit-frame-pointer' \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO='-Og -g3'"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sil-kit-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
run: |
mkdir _o
export CC=clang && export CXX=clang++
cmake -S . -B build_tidy -GNinja -DSILKIT_BUILD_DASHBOARD=OFF -DSILKIT_BUILD_DEMOS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake -S . -B build_tidy -GNinja -DSILKIT_BUILD_DEMOS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
python3 ./SilKit/ci/silkit_clang_tidy.py build_tidy/ _o/
shell: bash

Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@
[submodule "ThirdParty/googletest"]
path = ThirdParty/googletest
url = https://github.com/google/googletest
[submodule "ThirdParty/oatpp"]
path = ThirdParty/oatpp
url = https://github.com/oatpp/oatpp.git
4 changes: 1 addition & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"SILKIT_BUILD_UTILITIES": "ON",
"SILKIT_INSTALL_SOURCE": "ON",
"SILKIT_PACKAGE_SYMBOLS": "ON",
"SILKIT_WARNINGS_AS_ERRORS": "ON",
"CMAKE_POLICY_VERSION_MINIMUM": "3.5"
"SILKIT_WARNINGS_AS_ERRORS": "ON"
},
"architecture": {
"value": "x64",
Expand All @@ -44,7 +43,6 @@
"SILKIT_WARNINGS_AS_ERRORS": "ON",
"SILKIT_PACKAGE_SYMBOLS": "OFF",
"SILKIT_INSTALL_SOURCE": "OFF",
"CMAKE_POLICY_VERSION_MINIMUM": "3.5",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"

},
Expand Down
6 changes: 3 additions & 3 deletions SilKit/ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def buildConfigs = [
DockerImage: "silkit-ubuntu",
DockerBuildArgs: "--build-arg UBUNTU_VERSION=22.04",
PublishArtifacts: false,
CmakeArgs: "-D SILKIT_ENABLE_THREADSAN=ON -D SILKIT_BUILD_DASHBOARD=OFF",
CmakeArgs: "-D SILKIT_ENABLE_THREADSAN=ON",
CmakePreset: "clang14-release",
TestDebug: true,
]
Expand All @@ -112,7 +112,7 @@ def buildConfigs = [
DockerImage: "silkit-ubuntu",
DockerBuildArgs: "--build-arg UBUNTU_VERSION=22.04",
PublishArtifacts: false,
CmakeArgs: "-D SILKIT_ENABLE_ASAN=ON -D SILKIT_BUILD_DASHBOARD=OFF",
CmakeArgs: "-D SILKIT_ENABLE_ASAN=ON",
CmakePreset: "clang14-release",
TestDebug: true,
]
Expand All @@ -122,7 +122,7 @@ def buildConfigs = [
DockerImage: "silkit-ubuntu",
DockerBuildArgs: "--build-arg UBUNTU_VERSION=22.04",
PublishArtifacts: false,
CmakeArgs: "-D SILKIT_ENABLE_UBSAN=ON -D SILKIT_BUILD_DASHBOARD=OFF",
CmakeArgs: "-D SILKIT_ENABLE_UBSAN=ON",
CmakePreset: "clang14-release",
TestDebug: true,
]
Expand Down
130 changes: 130 additions & 0 deletions SilKit/source/config/BasicYamlWriter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#pragma once
// SPDX-FileCopyrightText: 2025 Vector Informatik GmbH
//
// SPDX-License-Identifier: MIT

// Generic ryml tree-writing machinery, split out of YamlWriter.hpp so that consumers which only
// need the CRTP base (e.g. the dashboard JSON writer) do not have to pull in the whole of
// ParticipantConfiguration.hpp.

#include <optional>
#include <sstream>
#include <string>
#include <vector>

#include "rapidyaml.hpp"

#include "silkit/participant/exception.hpp"

namespace VSilKit {

template <typename Impl>
struct BasicYamlWriter
{
ryml::NodeRef node;

public:
BasicYamlWriter(ryml::NodeRef node_)
: node(node_)
{
}

public:
template <typename T>
void OptionalWrite(const std::optional<T>& val, const std::string& name)
{
if (val.has_value())
{
WriteKeyValue(name, val.value());
}
}

template <typename T>
void OptionalWrite(const std::vector<T>& val, const std::string& name)
{
if (!val.empty())
{
WriteKeyValue(name, val);
}
}

void OptionalWrite(const std::string& val, const std::string& name)
{
if (!val.empty())
{
WriteKeyValue(name, val);
}
}

template <typename T>
void NonDefaultWrite(const T& val, const std::string& name, const T& defaultValue)
{
if (!(val == defaultValue))
{
WriteKeyValue(name, val);
}
}

template <typename T>
void WriteKeyValue(const std::string& name, const T& val)
{
if (!node.is_map())
{
throw SilKit::ConfigurationError("Parse error: trying to access child of something not a map");
}

auto writer = MakeImpl(node.append_child() << ryml::key(name));
writer.Write(val);
}

template <typename T>
void Write(const T& val)
{
node << val;
}

template <typename T>
void Write(const std::vector<T>& val)
{
node |= ryml::SEQ;
for (auto&& el : val)
{
auto writer = MakeImpl(node.append_child());
writer.Write(el);
}
}

protected:
void MakeMap()
{
node |= ryml::MAP;
}

auto MakeConfigurationError(const char* message) const -> SilKit::ConfigurationError
{
std::ostringstream s;

s << "error writing configuration: " << message;

return SilKit::ConfigurationError{s.str()};
}

protected:
auto MakeImpl(ryml::NodeRef node_) const -> Impl
{
return Impl{node_};
}

private:
auto AsImpl() -> Impl&
{
return static_cast<Impl&>(*this);
}

auto AsImpl() const -> const Impl&
{
return static_cast<const Impl&>(*this);
}
};

} // namespace VSilKit
1 change: 1 addition & 0 deletions SilKit/source/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ add_library(O_SilKit_Config OBJECT
YamlParser.cpp
YamlReader.hpp
YamlReader.cpp
BasicYamlWriter.hpp
YamlWriter.hpp
YamlWriter.cpp

Expand Down
110 changes: 1 addition & 109 deletions SilKit/source/config/YamlWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,119 +12,11 @@

#include "rapidyaml.hpp"

#include "config/BasicYamlWriter.hpp"
#include "config/ParticipantConfiguration.hpp"

namespace VSilKit {

template <typename Impl>
struct BasicYamlWriter
{
ryml::NodeRef node;

public:
BasicYamlWriter(ryml::NodeRef node_)
: node(node_)
{
}

public:
template <typename T>
void OptionalWrite(const std::optional<T>& val, const std::string& name)
{
if (val.has_value())
{
WriteKeyValue(name, val.value());
}
}

template <typename T>
void OptionalWrite(const std::vector<T>& val, const std::string& name)
{
if (!val.empty())
{
WriteKeyValue(name, val);
}
}

void OptionalWrite(const std::string& val, const std::string& name)
{
if (!val.empty())
{
WriteKeyValue(name, val);
}
}

template <typename T>
void NonDefaultWrite(const T& val, const std::string& name, const T& defaultValue)
{
if (!(val == defaultValue))
{
WriteKeyValue(name, val);
}
}

template <typename T>
void WriteKeyValue(const std::string& name, const T& val)
{
if (!node.is_map())
{
throw SilKit::ConfigurationError("Parse error: trying to access child of something not a map");
}

auto writer = MakeImpl(node.append_child() << ryml::key(name));
writer.Write(val);
}

template <typename T>
void Write(const T& val)
{
node << val;
}

template <typename T>
void Write(const std::vector<T>& val)
{
node |= ryml::SEQ;
for (auto&& el : val)
{
auto writer = MakeImpl(node.append_child());
writer.Write(el);
}
}

protected:
void MakeMap()
{
node |= ryml::MAP;
}

auto MakeConfigurationError(const char* message) const -> SilKit::ConfigurationError
{
std::ostringstream s;

s << "error writing configuration: " << message;

return SilKit::ConfigurationError{s.str()};
}

protected:
auto MakeImpl(ryml::NodeRef node_) const -> Impl
{
return Impl{node_};
}

private:
auto AsImpl() -> Impl&
{
return static_cast<Impl&>(*this);
}

auto AsImpl() const -> const Impl&
{
return static_cast<const Impl&>(*this);
}
};

struct YamlWriter : BasicYamlWriter<YamlWriter>
{
using BasicYamlWriter::BasicYamlWriter;
Expand Down
6 changes: 5 additions & 1 deletion SilKit/source/core/internal/internal_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class SystemStateTracker;
class ConnectPeer;
class MetricsProcessor;
class AsioGenericRawByteStream;
class AsioHttpClient;
class RetryingHttpClient;
class DashboardInstance;
class EventQueueWorkerThread;
} // namespace VSilKit
namespace SilKit {
namespace Tracing {
Expand All @@ -19,7 +23,7 @@ class ReplayScheduler;
namespace Dashboard {
class DashboardRestClient;
class DashboardSystemServiceClient;
class DashboardInstance;
class DashboardDtoMapper;
} // namespace Dashboard
namespace Experimental {
namespace NetworkSimulation {
Expand Down
6 changes: 5 additions & 1 deletion SilKit/source/core/internal/traits/SilKitLoggingTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ DefineSilKitLoggingTrait_Topic(VSilKit::AsioGenericRawByteStream, SilKit::Servic

DefineSilKitLoggingTrait_Topic(SilKit::Dashboard::DashboardRestClient, SilKit::Services::Logging::Topic::Dashboard);
DefineSilKitLoggingTrait_Topic(SilKit::Dashboard::DashboardSystemServiceClient, SilKit::Services::Logging::Topic::Dashboard);
DefineSilKitLoggingTrait_Topic(SilKit::Dashboard::DashboardInstance, SilKit::Services::Logging::Topic::Dashboard);
DefineSilKitLoggingTrait_Topic(SilKit::Dashboard::DashboardDtoMapper, SilKit::Services::Logging::Topic::Dashboard);
DefineSilKitLoggingTrait_Topic(VSilKit::DashboardInstance, SilKit::Services::Logging::Topic::Dashboard);
DefineSilKitLoggingTrait_Topic(VSilKit::EventQueueWorkerThread, SilKit::Services::Logging::Topic::Dashboard);
DefineSilKitLoggingTrait_Topic(VSilKit::AsioHttpClient, SilKit::Services::Logging::Topic::Dashboard);
DefineSilKitLoggingTrait_Topic(VSilKit::RetryingHttpClient, SilKit::Services::Logging::Topic::Dashboard);

DefineSilKitLoggingTrait_Topic(VSilKit::MetricsProcessor, SilKit::Services::Logging::Topic::Metrics);

Expand Down
Loading
Loading