1- /* Copyright (c) 2022 Vector Informatik GmbH
2-
3- Permission is hereby granted, free of charge, to any person obtaining
4- a copy of this software and associated documentation files (the
5- "Software"), to deal in the Software without restriction, including
6- without limitation the rights to use, copy, modify, merge, publish,
7- distribute, sublicense, and/or sell copies of the Software, and to
8- permit persons to whom the Software is furnished to do so, subject to
9- the following conditions:
10-
11- The above copyright notice and this permission notice shall be
12- included in all copies or substantial portions of the Software.
13-
14- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1+ // SPDX-FileCopyrightText: 2022-2025 Vector Informatik GmbH
2+ //
3+ // SPDX-License-Identifier: MIT
214
225#include " ParticipantConfiguration.hpp"
23- #include " Filesystem.hpp"
246
7+ #include < filesystem>
258#include < fstream>
269#include < sstream>
2710#include < iomanip>
11+ #include < optional>
2812#include < set>
2913#include < utility>
3014#include < vector>
@@ -52,40 +36,40 @@ using ConfigInclude = std::pair<std::string, SilKit::Config::V1::ParticipantConf
5236struct MiddlewareCache
5337{
5438 std::vector<std::string> acceptorUris;
55- SilKit::Util::Optional <std::string> registryUri;
56- SilKit::Util::Optional <double > connectTimeoutSeconds;
57- SilKit::Util::Optional <int > connectAttempts;
58- SilKit::Util::Optional <int > tcpReceiveBufferSize;
59- SilKit::Util::Optional <int > tcpSendBufferSize;
60- SilKit::Util::Optional <bool > tcpNoDelay;
61- SilKit::Util::Optional <bool > tcpQuickAck;
62- SilKit::Util::Optional <bool > enableDomainSockets;
63- SilKit::Util::Optional <bool > registryAsFallbackProxy;
64- SilKit::Util::Optional <bool > experimentalRemoteParticipantConnection;
39+ std::optional <std::string> registryUri;
40+ std::optional <double > connectTimeoutSeconds;
41+ std::optional <int > connectAttempts;
42+ std::optional <int > tcpReceiveBufferSize;
43+ std::optional <int > tcpSendBufferSize;
44+ std::optional <bool > tcpNoDelay;
45+ std::optional <bool > tcpQuickAck;
46+ std::optional <bool > enableDomainSockets;
47+ std::optional <bool > registryAsFallbackProxy;
48+ std::optional <bool > experimentalRemoteParticipantConnection;
6549};
6650
6751struct GlobalLogCache
6852{
69- SilKit::Util::Optional <bool > logFromRemotes;
70- SilKit::Util::Optional <Services::Logging::Level> flushLevel;
53+ std::optional <bool > logFromRemotes;
54+ std::optional <Services::Logging::Level> flushLevel;
7155 std::set<Sink> fileSinks;
72- SilKit::Util::Optional <Sink> stdOutSink;
73- SilKit::Util::Optional <Sink> remoteSink;
56+ std::optional <Sink> stdOutSink;
57+ std::optional <Sink> remoteSink;
7458 std::set<std::string> fileNames;
7559};
7660
7761struct TimeSynchronizationCache
7862{
79- SilKit::Util::Optional <double > animationFactor;
80- SilKit::Util::Optional <Aggregation> enableMessageAggregation;
63+ std::optional <double > animationFactor;
64+ std::optional <Aggregation> enableMessageAggregation;
8165};
8266
8367struct MetricsCache
8468{
85- SilKit::Util::Optional <bool > collectFromRemote;
69+ std::optional <bool > collectFromRemote;
8670 std::set<MetricsSink> jsonFileSinks;
8771 std::set<std::string> fileNames;
88- SilKit::Util::Optional <MetricsSink> remoteSink;
72+ std::optional <MetricsSink> remoteSink;
8973};
9074
9175struct ExperimentalCache
@@ -137,9 +121,9 @@ void Validate(const std::string& text)
137121// ================================================================================
138122std::string GetConfigParentPath (const std::string& configFile)
139123{
140- namespace fs = SilKit::Filesystem ;
141- auto filePath = fs::concatenate_paths ( fs:: current_path (). string (), configFile) ;
142- return fs:: parent_path (filePath ).string ();
124+ namespace fs = std::filesystem ;
125+ const auto filePath = fs::current_path () / configFile;
126+ return filePath. parent_path ().string ();
143127}
144128
145129void AppendToSearchPaths (const ParticipantConfiguration& config, ConfigIncludeData& configData)
@@ -158,7 +142,7 @@ void AppendToSearchPaths(const ParticipantConfiguration& config, ConfigIncludeDa
158142 // Make sure they have a seperator
159143 if (lastChar != ' /' && lastChar != ' \\ ' )
160144 {
161- suffix = SilKit::Filesystem ::path::preferred_separator;
145+ suffix = std::filesystem ::path::preferred_separator;
162146 }
163147
164148 configData.searchPaths .insert (searchPath + suffix);
@@ -200,7 +184,7 @@ std::string OpenFileWithSearchHints(const std::string& configFile, const std::se
200184// Helper functions to merge config fields/vectors/sets
201185// ================================================================================
202186template <typename FieldT>
203- void MergeCacheField (const SilKit::Util::Optional <FieldT>& includeObject, FieldT& rootObject)
187+ void MergeCacheField (const std::optional <FieldT>& includeObject, FieldT& rootObject)
204188{
205189 if (includeObject.has_value ())
206190 {
@@ -254,11 +238,11 @@ void MergeCacheSet(const std::set<T>& cache, std::vector<T>& root)
254238
255239template <typename T>
256240void CacheNonDefault (const T& defaultValue, const T& value, const std::string& configName,
257- SilKit::Util::Optional <T>& cacheValue)
241+ std::optional <T>& cacheValue)
258242{
259243 if (defaultValue != value)
260244 {
261- SilKit::Util::Optional <T> optValue{value};
245+ std::optional <T> optValue{value};
262246
263247 if (cacheValue.has_value () && (cacheValue != optValue))
264248 {
0 commit comments