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

37 lines
568 B
C++

/* Icinga 2 | (c) 2020 Icinga GmbH | GPLv2+ */
#ifndef GENERATOR_UNIQUE_H
#define GENERATOR_UNIQUE_H
#include "base/generator.hpp"
#include "base/value.hpp"
#include <set>
#include <utility>
namespace icinga
{
/**
* Filters another generator's unique items.
*
* @ingroup base
*/
class GeneratorUnique final : public Generator
{
public:
inline GeneratorUnique(Generator::Ptr source)
: m_Source(std::move(source))
{
}
bool GetNext(Value& out) override;
private:
Generator::Ptr m_Source;
std::set<Value> m_Unique;
};
}
#endif /* GENERATOR_UNIQUE_H */