6 #ifndef SL_LOG_FILTERS_HPP
7 #define SL_LOG_FILTERS_HPP
18 #include <type_traits>
38 template <
class TProjection,
class TUnaryPredicate>
51 TProjection projection,
52 TUnaryPredicate predicate
54 noexcept(std::is_nothrow_move_constructible_v<Projection_t> && std::is_nothrow_move_constructible_v<UnaryPredicate_t>) :
55 m_Projection{ std::move(projection) },
56 m_Predicate{ std::move(predicate) }
66 template <Record TRecord>
69 return std::invoke(m_Predicate, std::invoke(m_Projection, rec));
83 template <
class TAlgorithm,
class... TFilter>
96 noexcept(std::is_nothrow_constructible_v<Algorithm_t> && (std::is_nothrow_move_constructible_v<TFilter> && ...)) :
98 m_Filter{ std::move(filter)... }
108 TAlgorithm algorithm,
110 ) noexcept(std::is_nothrow_move_constructible_v<Algorithm_t> && (std::is_nothrow_move_constructible_v<TFilter> && ...)) :
111 m_Algorithm{ std::move(algorithm) },
112 m_Filter{ std::forward<TFilter>(filter)... }
122 template <Record TRecord>
125 return std::invoke(m_Algorithm, m_Filter, rec);
133 constexpr
bool empty() const noexcept
135 return std::tuple_size_v<decltype(m_Filter)> == 0;
143 constexpr std::size_t
size() const noexcept
145 return std::tuple_size_v<decltype(m_Filter)>;
150 std::tuple<TFilter...> m_Filter;
164 template <
class... TFilter>
168 using Algorithm_t = detail::TupleAllOf;
178 noexcept((std::is_nothrow_move_constructible_v<TFilter> && ...)) :
179 FilterChain<Algorithm_t, TFilter...>{ std::move(filter)... }
188 template <
class... TFilter>
192 using Algorithm_t = detail::TupleAnyOf;
202 noexcept((std::is_nothrow_move_constructible_v<TFilter> && ...)) :
203 FilterChain<Algorithm_t, TFilter...>{ std::move(filter)... }
212 template <
class... TFilter>
214 public FilterChain<detail::TupleNoneOf, TFilter...>
216 using Algorithm_t = detail::TupleNoneOf;
226 noexcept((std::is_nothrow_move_constructible_v<TFilter> && ...)) :
227 FilterChain<Algorithm_t, TFilter...>{ std::move(filter)... }
242 template <Record TRecord, std::predicate<const RecordMessage_t<TRecord>&> TUnaryPredicate>
258 template <Record TRecord, std::predicate<const RecordSeverity_t<TRecord>&> TUnaryPredicate>
274 template <Record TRecord, std::predicate<const RecordChannel_t<TRecord>&> TUnaryPredicate>
290 template <Record TRecord, std::predicate<const RecordTimePo
int_t<TRecord>&> TUnaryPredicate>
Convenience type for chaining multiple filter with AND.
Definition: Filters.hpp:167
constexpr FilterAllOf(TFilter ... filter) noexcept((std::is_nothrow_move_constructible_v< TFilter > &&...))
Constructor.
Definition: Filters.hpp:175
Convenience type for chaining multiple filter with OR.
Definition: Filters.hpp:191
constexpr FilterAnyOf(TFilter ... filter) noexcept((std::is_nothrow_move_constructible_v< TFilter > &&...))
Constructor.
Definition: Filters.hpp:199
Chains multiple filter together.
Definition: Filters.hpp:85
constexpr std::size_t size() const noexcept
Obtains the amount of attached sub-filters.
Definition: Filters.hpp:143
constexpr FilterChain(TAlgorithm algorithm, TFilter ...filter) noexcept(std::is_nothrow_move_constructible_v< Algorithm_t > &&(std::is_nothrow_move_constructible_v< TFilter > &&...))
Constructor overload.
Definition: Filters.hpp:107
std::remove_cvref_t< TAlgorithm > Algorithm_t
Definition: Filters.hpp:87
constexpr FilterChain(TFilter ...filter) noexcept(std::is_nothrow_constructible_v< Algorithm_t > &&(std::is_nothrow_move_constructible_v< TFilter > &&...))
Constructor.
Definition: Filters.hpp:93
constexpr bool operator()(const TRecord &rec)
Call-operator.
Definition: Filters.hpp:123
constexpr bool empty() const noexcept
Returns whether the are no sub-filters attached.
Definition: Filters.hpp:133
Convenience type for chaining multiple filter with NOR.
Definition: Filters.hpp:215
constexpr FilterNoneOf(TFilter ... filter) noexcept((std::is_nothrow_move_constructible_v< TFilter > &&...))
Constructor.
Definition: Filters.hpp:223
Combines a projection on Record type with a predicate into an invokable object.
Definition: Filters.hpp:40
std::remove_cvref_t< TProjection > Projection_t
Definition: Filters.hpp:42
constexpr bool operator()(const TRecord &rec)
Call-operator.
Definition: Filters.hpp:67
std::remove_cvref_t< TUnaryPredicate > UnaryPredicate_t
Definition: Filters.hpp:43
constexpr ProjectionFilter(TProjection projection, TUnaryPredicate predicate) noexcept(std::is_nothrow_move_constructible_v< Projection_t > &&std::is_nothrow_move_constructible_v< UnaryPredicate_t >)
Constructor.
Definition: Filters.hpp:50
constexpr auto makeMessageFilterFor(TUnaryPredicate &&predicate)
Factory function for creating ProjectionFilter of Record::message member.
Definition: Filters.hpp:243
constexpr auto makeSeverityFilterFor(TUnaryPredicate &&predicate)
Factory function for creating ProjectionFilter of Record::severity member.
Definition: Filters.hpp:259
constexpr auto makeTimePointFilterFor(TUnaryPredicate &&predicate)
Factory function for creating ProjectionFilter of Record::timePoint member.
Definition: Filters.hpp:291
constexpr auto makeChannelFilterFor(TUnaryPredicate &&predicate)
Factory function for creating ProjectionFilter of Record::channel member.
Definition: Filters.hpp:275
Definition: BasicSink.hpp:22
Provides a layer of abstraction to Record member setter.
Definition: Record.hpp:118