1#ifndef IV_SRC_UNITS_BUILDERS_UTILS_HPP_
2#define IV_SRC_UNITS_BUILDERS_UTILS_HPP_
21 this->pmmName = std::move(
pmmName);
22 this->chName = std::move(
chName);
30 std::regex pattern(R
"(^.{1,3}_.+$)");
31 return std::regex_match(chId, pattern);
41 auto separatorPos = channelId.find(
'_');
42 std::string pmmName = channelId.substr(0, separatorPos);
43 std::string chName = channelId.substr(separatorPos + 1, channelId.size());
60 std::string lastOccurrence;
61 for (
const auto &channelPair: pmmUnit.
getChannels())
64 if (pmmAndChannelNames.has_value())
66 if (lastOccurrence != pmmAndChannelNames->pmmName)
68 lastOccurrence = pmmAndChannelNames->pmmName;
72 return pmmAndChannelNames->pmmName;
79inline std::pair<bool, std::shared_ptr<iv::channels::AbstractChannel>>
83 auto it = std::find_if(
84 pmmChannels.begin(), pmmChannels.end(),
86 const std::pair<
iv::types::channelId, std::shared_ptr<iv::channels::AbstractChannel>> &channelPair)
88 const auto pmmAndChannelNames = getPmmAndChannelNames(channelPair.first);
89 if (pmmAndChannelNames.has_value() and pmmAndChannelNames->chName == channelName)
97 if (it == pmmChannels.end())
102 return {
true, it->second};
const std::unordered_map< iv::types::channelId, std::shared_ptr< iv::channels::AbstractChannel > > & getChannels() const
Definition Unit.cpp:688
std::optional< iv::units::eUnitType > m_unitType
Definition Unit.hpp:109
std::string channelId
Definition types.hpp:66
bool hasPmmChIdStructure(iv::types::channelId chId)
Definition utils.hpp:28
std::optional< std::string > getPmmName(const iv::units::Unit &pmmUnit)
Get the name of the PMM from a unit.
Definition utils.hpp:53
std::optional< PmmAndChannelNames > getPmmAndChannelNames(const iv::types::channelId &channelId)
Definition utils.hpp:34
std::pair< bool, std::shared_ptr< iv::channels::AbstractChannel > > hasPmmChannelByChName(const iv::units::Unit &pmmUnit, const std::string &channelName)
Definition utils.hpp:80
Definition constants.hpp:7
std::string chName
Definition utils.hpp:25
std::string pmmName
Definition utils.hpp:24
PmmAndChannelNames(std::string pmmName, std::string chName)
Definition utils.hpp:19