icinga2/lib/base/generator-unique.cpp
Alexander A. Klimov cbd94e060d DSL: add generators
2025-04-29 11:01:17 +02:00

27 lines
435 B
C++

/* Icinga 2 | (c) 2020 Icinga GmbH | GPLv2+ */
#include "base/generator-unique.hpp"
#include "base/objectlock.hpp"
#include "base/value.hpp"
#include <utility>
using namespace icinga;
bool GeneratorUnique::GetNext(Value& out)
{
ObjectLock oLock (this);
Value buf;
while (m_Source->GetNext(buf)) {
auto res (m_Unique.emplace(std::move(buf)));
if (res.second) {
out = *res.first;
return true;
}
}
return false;
}