From b7ebfa43e49eddddfc04bd9d8e45ad63291df8ce Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Fri, 9 Feb 2024 09:32:40 -0500 Subject: [PATCH] reorganize source code slightly, we shouldn't define logic in the CPP files for the talkgroup rules data classes, and instead we should define the logic in the header (since logic for these data classes shouldn't be anything complicated anyway); --- src/common/lookups/TalkgroupRulesLookup.cpp | 61 ------------------ src/common/lookups/TalkgroupRulesLookup.h | 68 +++++++++++++++++++-- 2 files changed, 64 insertions(+), 65 deletions(-) diff --git a/src/common/lookups/TalkgroupRulesLookup.cpp b/src/common/lookups/TalkgroupRulesLookup.cpp index be114026..203421fb 100644 --- a/src/common/lookups/TalkgroupRulesLookup.cpp +++ b/src/common/lookups/TalkgroupRulesLookup.cpp @@ -307,67 +307,6 @@ bool TalkgroupRulesLookup::getACL() return m_acl; } -void TalkgroupRuleGroupVoice::getYaml(yaml::Node &node) -{ - // Get all the properties - node["name"] = m_name; - yaml::Node config, source; - m_config.getYaml(config); - m_source.getYaml(source); - node["config"] = config; - node["source"] = source; -} - -void TalkgroupRuleConfig::getYaml(yaml::Node &node) -{ - - // We have to convert the bools back to strings to pass to the yaml node - node["active"] = __BOOL_STR(m_active); - node["affiliated"] = __BOOL_STR(m_affiliated); - node["parrot"] = __BOOL_STR(m_parrot); - - // Get the lists - yaml::Node inclusionList; - if (m_inclusion.size() > 0U) { - for (auto inc : m_inclusion) { - yaml::Node& newIn = inclusionList.push_back(); - newIn = __INT_STR(inc); - } - } - node["inclusion"] = inclusionList; - - yaml::Node exclusionList; - if (m_exclusion.size() > 0U) { - for (auto exc : m_exclusion) { - yaml::Node& newEx = exclusionList.push_back(); - newEx = __INT_STR(exc); - } - } - node["exclusion"] = exclusionList; - - yaml::Node rewriteList; - if (m_rewrite.size() > 0U) { - for (auto rule : m_rewrite) { - yaml::Node& rewrite = rewriteList.push_back(); - rule.getYaml(rewrite); - } - } - node["rewrite"] = rewriteList; -} - -void TalkgroupRuleGroupVoiceSource::getYaml(yaml::Node &node) -{ - node["tgid"] = __INT_STR(m_tgId); - node["slot"] = __INT_STR(m_tgSlot); -} - -void TalkgroupRuleRewrite::getYaml(yaml::Node &node) -{ - node["peerid"] = __INT_STR(m_peerId); - node["tgid"] = __INT_STR(m_tgId); - node["slot"] = __INT_STR(m_tgSlot); -} - // --------------------------------------------------------------------------- // Private Class Members // --------------------------------------------------------------------------- diff --git a/src/common/lookups/TalkgroupRulesLookup.h b/src/common/lookups/TalkgroupRulesLookup.h index 3bdc17b1..8cf2c8b0 100644 --- a/src/common/lookups/TalkgroupRulesLookup.h +++ b/src/common/lookups/TalkgroupRulesLookup.h @@ -17,6 +17,7 @@ #include "common/Defines.h" #include "common/lookups/LookupTable.h" #include "common/yaml/Yaml.h" +#include "common/Utils.h" #include #include @@ -59,7 +60,12 @@ namespace lookups return *this; } - void getYaml(yaml::Node &node); + /// Return the YAML structure for this TalkgroupRuleGroupVoiceSource. + void getYaml(yaml::Node &node) + { + node["tgid"] = __INT_STR(m_tgId); + node["slot"] = __INT_STR(m_tgSlot); + } public: /// Talkgroup ID. @@ -105,7 +111,13 @@ namespace lookups return *this; } - void getYaml(yaml::Node &node); + /// Return the YAML structure for this TalkgroupRuleRewrite. + void getYaml(yaml::Node &node) + { + node["peerid"] = __INT_STR(m_peerId); + node["tgid"] = __INT_STR(m_tgId); + node["slot"] = __INT_STR(m_tgSlot); + } public: /// Peer ID. @@ -183,7 +195,42 @@ namespace lookups return *this; } - void getYaml(yaml::Node &node); + /// Return the YAML structure for this TalkgroupRuleConfig. + void getYaml(yaml::Node &node) + { + // We have to convert the bools back to strings to pass to the yaml node + node["active"] = __BOOL_STR(m_active); + node["affiliated"] = __BOOL_STR(m_affiliated); + node["parrot"] = __BOOL_STR(m_parrot); + + // Get the lists + yaml::Node inclusionList; + if (m_inclusion.size() > 0U) { + for (auto inc : m_inclusion) { + yaml::Node& newIn = inclusionList.push_back(); + newIn = __INT_STR(inc); + } + } + node["inclusion"] = inclusionList; + + yaml::Node exclusionList; + if (m_exclusion.size() > 0U) { + for (auto exc : m_exclusion) { + yaml::Node& newEx = exclusionList.push_back(); + newEx = __INT_STR(exc); + } + } + node["exclusion"] = exclusionList; + + yaml::Node rewriteList; + if (m_rewrite.size() > 0U) { + for (auto rule : m_rewrite) { + yaml::Node& rewrite = rewriteList.push_back(); + rule.getYaml(rewrite); + } + } + node["rewrite"] = rewriteList; + } public: /// Flag indicating whether the rule is active. @@ -245,7 +292,20 @@ namespace lookups return false; } - void getYaml(yaml::Node &node); + /// Return the YAML structure for this TalkgroupRuleGroupVoice. + void getYaml(yaml::Node &node) + { + // Get all the properties + node["name"] = m_name; + + yaml::Node config, source; + m_config.getYaml(config); + m_source.getYaml(source); + + node["config"] = config; + node["source"] = source; + } + public: /// Textual name for the routing rule.