Skip to content

Commit

Permalink
Validate new YAML options
Browse files Browse the repository at this point in the history
Signed-off-by: tempate <[email protected]>
  • Loading branch information
Tempate committed Apr 11, 2024
1 parent 26b0729 commit 7cc6a18
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 13 deletions.
33 changes: 30 additions & 3 deletions ddspipe_yaml/src/cpp/YamlReader_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ core::TopicRoutesConfiguration YamlReader::get(
return object;
}

/*************************
* Monitor Configuration *
**************************/
/**************************
* Monitor Configuration *
**************************/

template <>
DDSPIPE_YAML_DllAPI
Expand Down Expand Up @@ -277,6 +277,20 @@ void YamlReader::fill(
}
}

template <>
DDSPIPE_YAML_DllAPI
bool YamlValidator::validate<core::MonitorConfiguration>(
const Yaml& yml,
const YamlReaderVersion& /* version */)
{
const std::set<TagType> tags{
MONITOR_DOMAIN_TAG,
MONITOR_STATUS_TAG,
MONITOR_TOPICS_TAG};

return YamlValidator::validate_tags(yml, tags);
}

template <>
DDSPIPE_YAML_DllAPI
core::MonitorConfiguration YamlReader::get(
Expand Down Expand Up @@ -308,6 +322,19 @@ void YamlReader::fill(
}
}

template <>
DDSPIPE_YAML_DllAPI
bool YamlValidator::validate<core::MonitorProducerConfiguration>(
const Yaml& yml,
const YamlReaderVersion& /* version */)
{
const std::set<TagType> tags{
MONITOR_ENABLE_TAG,
MONITOR_PERIOD_TAG};

return YamlValidator::validate_tags(yml, tags);
}

template <>
DDSPIPE_YAML_DllAPI
core::MonitorProducerConfiguration YamlReader::get(
Expand Down
58 changes: 49 additions & 9 deletions ddspipe_yaml/src/cpp/YamlReader_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,9 @@ bool YamlValidator::validate<DiscoveryServerConnectionAddress>(
std::set<TagType> tags{
COLLECTION_ADDRESSES_TAG};

switch (version)
if (version != V_1_0)
{
case V_1_0:
break;

default:
tags.insert(DISCOVERY_SERVER_GUID_PREFIX_TAG);
break;
tags.insert(DISCOVERY_SERVER_GUID_PREFIX_TAG);
}

return YamlValidator::validate_tags(yml, tags);
Expand Down Expand Up @@ -430,12 +425,29 @@ void YamlReader::fill(
}
}

template <>
DDSPIPE_YAML_DllAPI
bool YamlValidator::validate<core::DdsPublishingConfiguration>(
const Yaml& yml,
const YamlReaderVersion& /* version */)
{
const std::set<TagType> tags{
DDS_PUBLISHING_ENABLE_TAG,
DDS_PUBLISHING_DOMAIN_TAG,
DDS_PUBLISHING_TOPIC_NAME_TAG,
DDS_PUBLISHING_PUBLISH_TYPE_TAG};

return YamlValidator::validate_tags(yml, tags);
}

template <>
DDSPIPE_YAML_DllAPI
core::DdsPublishingConfiguration YamlReader::get(
const Yaml& yml,
const YamlReaderVersion version)
{
YamlValidator::validate<core::DdsPublishingConfiguration>(yml, version);

core::DdsPublishingConfiguration object;
fill<core::DdsPublishingConfiguration>(object, yml, version);
return object;
Expand Down Expand Up @@ -483,8 +495,7 @@ void YamlReader::fill(
{
if (get<bool>(yml, QOS_OWNERSHIP_TAG, version))
{
object.ownership_qos.set_value(
ddspipe::core::types::OwnershipQosPolicyKind::EXCLUSIVE_OWNERSHIP_QOS);
object.ownership_qos.set_value(ddspipe::core::types::OwnershipQosPolicyKind::EXCLUSIVE_OWNERSHIP_QOS);
}
else
{
Expand Down Expand Up @@ -589,6 +600,20 @@ void YamlReader::fill<utils::LogFilter>(
}
}

template <>
DDSPIPE_YAML_DllAPI
bool YamlValidator::validate<utils::LogFilter>(
const Yaml& yml,
const YamlReaderVersion& /* version */)
{
const std::set<TagType> tags{
LOG_FILTER_ERROR_TAG,
LOG_FILTER_WARNING_TAG,
LOG_FILTER_INFO_TAG};

return YamlValidator::validate_tags(yml, tags);
}

template <>
DDSPIPE_YAML_DllAPI
utils::LogFilter YamlReader::get(
Expand Down Expand Up @@ -639,6 +664,21 @@ void YamlReader::fill(
}
}

template <>
DDSPIPE_YAML_DllAPI
bool YamlValidator::validate<core::DdsPipeLogConfiguration>(
const Yaml& yml,
const YamlReaderVersion& /* version */)
{
const std::set<TagType> tags{
LOG_PUBLISH_TAG,
LOG_STDOUT_TAG,
LOG_VERBOSITY_TAG,
LOG_FILTER_TAG};

return YamlValidator::validate_tags(yml, tags);
}

template <>
DDSPIPE_YAML_DllAPI
core::DdsPipeLogConfiguration YamlReader::get(
Expand Down
2 changes: 1 addition & 1 deletion ddspipe_yaml/src/cpp/YamlValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool YamlValidator::validate_tags(
utils::Formatter() << "The yml: <" << yml << "> is not a yaml object map.");
}

// Check if there are any extra tags that are not in either list
// Check if there are any extra tags that are not in the list
bool has_extra_tags = false;

for (const auto& tag_it : yml)
Expand Down

0 comments on commit 7cc6a18

Please sign in to comment.