2323#include < ddspipe_yaml/Yaml.hpp>
2424#include < ddspipe_yaml/YamlManager.hpp>
2525#include < ddspipe_yaml/YamlReader.hpp>
26+ #include < ddspipe_yaml/YamlValidator.hpp>
2627
2728#include < ddspipe_core/configuration/DdsPipeConfiguration.hpp>
2829#include < ddspipe_core/configuration/MonitorConfiguration.hpp>
@@ -57,7 +58,7 @@ void YamlReader::fill(
5758 // Optional Topic QoS
5859 if (is_tag_present (yml, SPECS_QOS_TAG))
5960 {
60- fill <core::types::TopicQoS>(object. topic_qos , get_value_in_tag ( yml, SPECS_QOS_TAG) , version);
61+ object. topic_qos = YamlReader::get <core::types::TopicQoS>(yml, SPECS_QOS_TAG, version);
6162 core::types::TopicQoS::default_topic_qos.set_value (object.topic_qos );
6263 }
6364
@@ -95,6 +96,32 @@ void YamlReader::fill(
9596 }
9697}
9798
99+ template <>
100+ bool YamlValidator::validate<ddsrouter::core::SpecsConfiguration>(
101+ const Yaml& yml,
102+ const YamlReaderVersion& /* version */ )
103+ {
104+ const std::set<TagType> tags{
105+ NUMBER_THREADS_TAG,
106+ REMOVE_UNUSED_ENTITIES_TAG,
107+ SPECS_QOS_TAG,
108+ DISCOVERY_TRIGGER_TAG};
109+
110+ return YamlValidator::validate_tags_ (yml, tags);
111+ }
112+
113+ template <>
114+ ddsrouter::core::SpecsConfiguration YamlReader::get<ddsrouter::core::SpecsConfiguration>(
115+ const Yaml& yml,
116+ const YamlReaderVersion version)
117+ {
118+ YamlValidator::validate<ddsrouter::core::SpecsConfiguration>(yml, version);
119+
120+ ddsrouter::core::SpecsConfiguration object;
121+ fill<ddsrouter::core::SpecsConfiguration>(object, yml, version);
122+ return object;
123+ }
124+
98125template <>
99126ddsrouter::core::types::ParticipantKind YamlReader::get (
100127 const Yaml& yml,
@@ -190,21 +217,14 @@ void YamlReader::fill(
190217 // Get optional routes
191218 if (YamlReader::is_tag_present (yml, ROUTES_TAG))
192219 {
193- YamlReader::fill<core::RoutesConfiguration>(
194- object.routes ,
195- YamlReader::get_value_in_tag (yml, ROUTES_TAG),
196- version);
220+ object.routes = YamlReader::get<core::RoutesConfiguration>(yml, ROUTES_TAG, version);
197221 }
198222
199223 // ///
200224 // Get optional topic routes
201225 if (YamlReader::is_tag_present (yml, TOPIC_ROUTES_TAG))
202226 {
203- // get list, and parse each element as above
204- YamlReader::fill<core::TopicRoutesConfiguration>(
205- object.topic_routes ,
206- YamlReader::get_value_in_tag (yml, TOPIC_ROUTES_TAG),
207- version);
227+ object.topic_routes = YamlReader::get<core::TopicRoutesConfiguration>(yml, TOPIC_ROUTES_TAG, version);
208228 }
209229
210230 // ///
@@ -250,6 +270,7 @@ void YamlReader::fill(
250270 {
251271 ddsrouter::core::types::ParticipantKind kind =
252272 YamlReader::get<ddsrouter::core::types::ParticipantKind>(conf, PARTICIPANT_KIND_TAG, version);
273+
253274 object.participants_configurations .insert (
254275 {
255276 kind,
@@ -262,10 +283,7 @@ void YamlReader::fill(
262283 // Get optional specs configuration
263284 if (YamlReader::is_tag_present (yml, SPECS_TAG))
264285 {
265- YamlReader::fill<ddsrouter::core::SpecsConfiguration>(
266- object.advanced_options ,
267- YamlReader::get_value_in_tag (yml, SPECS_TAG),
268- version);
286+ object.advanced_options = get<ddsrouter::core::SpecsConfiguration>(YamlReader::get_value_in_tag (yml, SPECS_TAG), version);
269287 }
270288
271289 // DDS Pipe Configuration
@@ -286,18 +304,38 @@ void YamlReader::fill(
286304 // Get optional xml configuration
287305 if (YamlReader::is_tag_present (yml, XML_TAG))
288306 {
289- YamlReader::fill<participants::XmlHandlerConfiguration>(
290- object.xml_configuration ,
291- YamlReader::get_value_in_tag (yml, XML_TAG),
292- version);
307+ object.xml_configuration = YamlReader::get<participants::XmlHandlerConfiguration>(yml, XML_TAG, version);
293308 }
294309}
295310
311+ template <>
312+ DDSPIPE_YAML_DllAPI
313+ bool YamlValidator::validate<ddsrouter::core::DdsRouterConfiguration>(
314+ const Yaml& yml,
315+ const YamlReaderVersion& /* version */ )
316+ {
317+ const std::set<TagType> tags{
318+ VERSION_TAG,
319+ COLLECTION_PARTICIPANTS_TAG,
320+ XML_TAG,
321+ ALLOWLIST_TAG,
322+ BLOCKLIST_TAG,
323+ BUILTIN_TAG,
324+ ROUTES_TAG,
325+ TOPIC_ROUTES_TAG,
326+ TOPICS_TAG,
327+ SPECS_TAG};
328+
329+ return YamlValidator::validate_tags_ (yml, tags);
330+ }
331+
296332template <>
297333ddsrouter::core::DdsRouterConfiguration YamlReader::get<ddsrouter::core::DdsRouterConfiguration>(
298334 const Yaml& yml,
299335 const YamlReaderVersion version)
300336{
337+ YamlValidator::validate<ddsrouter::core::DdsRouterConfiguration>(yml, version);
338+
301339 ddsrouter::core::DdsRouterConfiguration object;
302340 fill<ddsrouter::core::DdsRouterConfiguration>(object, yml, version);
303341 return object;
0 commit comments