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 < ddsrouter_core/configuration/DdsRouterConfiguration.hpp>
@@ -56,7 +57,7 @@ void YamlReader::fill(
5657 // Optional Topic QoS
5758 if (is_tag_present (yml, SPECS_QOS_TAG))
5859 {
59- fill <core::types::TopicQoS>(object. topic_qos , get_value_in_tag ( yml, SPECS_QOS_TAG) , version);
60+ object. topic_qos = YamlReader::get <core::types::TopicQoS>(yml, SPECS_QOS_TAG, version);
6061 core::types::TopicQoS::default_topic_qos.set_value (object.topic_qos );
6162 }
6263
@@ -79,6 +80,32 @@ void YamlReader::fill(
7980 }
8081}
8182
83+ template <>
84+ bool YamlValidator::validate<ddsrouter::core::SpecsConfiguration>(
85+ const Yaml& yml,
86+ const YamlReaderVersion& /* version */ )
87+ {
88+ const std::set<TagType> tags{
89+ NUMBER_THREADS_TAG,
90+ REMOVE_UNUSED_ENTITIES_TAG,
91+ SPECS_QOS_TAG,
92+ DISCOVERY_TRIGGER_TAG};
93+
94+ return YamlValidator::validate_tags_ (yml, tags);
95+ }
96+
97+ template <>
98+ ddsrouter::core::SpecsConfiguration YamlReader::get<ddsrouter::core::SpecsConfiguration>(
99+ const Yaml& yml,
100+ const YamlReaderVersion version)
101+ {
102+ YamlValidator::validate<ddsrouter::core::SpecsConfiguration>(yml, version);
103+
104+ ddsrouter::core::SpecsConfiguration object;
105+ fill<ddsrouter::core::SpecsConfiguration>(object, yml, version);
106+ return object;
107+ }
108+
82109template <>
83110ddsrouter::core::types::ParticipantKind YamlReader::get (
84111 const Yaml& yml,
@@ -174,21 +201,14 @@ void YamlReader::fill(
174201 // Get optional routes
175202 if (YamlReader::is_tag_present (yml, ROUTES_TAG))
176203 {
177- YamlReader::fill<core::RoutesConfiguration>(
178- object.routes ,
179- YamlReader::get_value_in_tag (yml, ROUTES_TAG),
180- version);
204+ object.routes = YamlReader::get<core::RoutesConfiguration>(yml, ROUTES_TAG, version);
181205 }
182206
183207 // ///
184208 // Get optional topic routes
185209 if (YamlReader::is_tag_present (yml, TOPIC_ROUTES_TAG))
186210 {
187- // get list, and parse each element as above
188- YamlReader::fill<core::TopicRoutesConfiguration>(
189- object.topic_routes ,
190- YamlReader::get_value_in_tag (yml, TOPIC_ROUTES_TAG),
191- version);
211+ object.topic_routes = YamlReader::get<core::TopicRoutesConfiguration>(yml, TOPIC_ROUTES_TAG, version);
192212 }
193213
194214 // ///
@@ -234,6 +254,7 @@ void YamlReader::fill(
234254 {
235255 ddsrouter::core::types::ParticipantKind kind =
236256 YamlReader::get<ddsrouter::core::types::ParticipantKind>(conf, PARTICIPANT_KIND_TAG, version);
257+
237258 object.participants_configurations .insert (
238259 {
239260 kind,
@@ -246,10 +267,7 @@ void YamlReader::fill(
246267 // Get optional specs configuration
247268 if (YamlReader::is_tag_present (yml, SPECS_TAG))
248269 {
249- YamlReader::fill<ddsrouter::core::SpecsConfiguration>(
250- object.advanced_options ,
251- YamlReader::get_value_in_tag (yml, SPECS_TAG),
252- version);
270+ object.advanced_options = get<ddsrouter::core::SpecsConfiguration>(YamlReader::get_value_in_tag (yml, SPECS_TAG), version);
253271 }
254272
255273 // DDS Pipe Configuration
@@ -269,18 +287,38 @@ void YamlReader::fill(
269287 // Get optional xml configuration
270288 if (YamlReader::is_tag_present (yml, XML_TAG))
271289 {
272- YamlReader::fill<participants::XmlHandlerConfiguration>(
273- object.xml_configuration ,
274- YamlReader::get_value_in_tag (yml, XML_TAG),
275- version);
290+ object.xml_configuration = YamlReader::get<participants::XmlHandlerConfiguration>(yml, XML_TAG, version);
276291 }
277292}
278293
294+ template <>
295+ DDSPIPE_YAML_DllAPI
296+ bool YamlValidator::validate<ddsrouter::core::DdsRouterConfiguration>(
297+ const Yaml& yml,
298+ const YamlReaderVersion& /* version */ )
299+ {
300+ const std::set<TagType> tags{
301+ VERSION_TAG,
302+ COLLECTION_PARTICIPANTS_TAG,
303+ XML_TAG,
304+ ALLOWLIST_TAG,
305+ BLOCKLIST_TAG,
306+ BUILTIN_TAG,
307+ ROUTES_TAG,
308+ TOPIC_ROUTES_TAG,
309+ TOPICS_TAG,
310+ SPECS_TAG};
311+
312+ return YamlValidator::validate_tags_ (yml, tags);
313+ }
314+
279315template <>
280316ddsrouter::core::DdsRouterConfiguration YamlReader::get<ddsrouter::core::DdsRouterConfiguration>(
281317 const Yaml& yml,
282318 const YamlReaderVersion version)
283319{
320+ YamlValidator::validate<ddsrouter::core::DdsRouterConfiguration>(yml, version);
321+
284322 ddsrouter::core::DdsRouterConfiguration object;
285323 fill<ddsrouter::core::DdsRouterConfiguration>(object, yml, version);
286324 return object;
0 commit comments