Simple-Log
alpha-v0.7
|
A customizable FlushPolicy class. More...
#include <FlushPolicies.hpp>
Public Types | |
using | Predicate_t = std::remove_cvref_t< TPredicate > |
using | Projection_t = std::remove_cvref_t< TProjection > |
using | InvocationRule_t = std::remove_cvref_t< TInvocationRule > |
Public Member Functions | |
FlushPolicy (TPredicate predicate=Predicate_t{}, TProjection projection=Projection_t{}, TInvocationRule invocation=InvocationRule_t{}) noexcept(std::is_nothrow_move_constructible_v< TPredicate > &&std::is_nothrow_move_constructible_v< TProjection > &&std::is_nothrow_move_constructible_v< TInvocationRule >) | |
Constructor. More... | |
template<class... TArgs> | |
requires std::constructible_from< Predicate_t, TArgs... > | FlushPolicy (std::in_place_t _, TArgs &&... args) noexcept(std::is_nothrow_constructible_v< TPredicate, TArgs... > &&std::is_nothrow_constructible_v< TProjection > &&std::is_nothrow_constructible_v< TInvocationRule >) |
Constructor overload for in_place predicate initializing. More... | |
template<Record TRecord> | |
bool | operator() (const TRecord &record, std::size_t messageByteSize) |
Invoke operator. More... | |
constexpr void | flushed () const noexcept |
NoOp. More... | |
A customizable FlushPolicy class.
TPredicate | The predicate must be invokable with the result of TProjection and must boolean-comparable results. |
TProjection | The projection must be invokable with the used Record type and must return something non-void. |
TInvocationRule | This type is used for internal determination how to chain the invocations. |
This is a customizable class when a Flush-Policy does not carrie any internal state which has to be reset after flushing happened. In other words, users can pass any type of predicate, which fulfills the requirements, but will never receive the flushed() signal. If you need to act on that signal, users can simply write their own FlushPolicy class. There is no base class FlushPolicies must inherit from. Additionally it is possible to use a projection, which will be invoked before the actual predicate. This projection must accept an object of the used Record type as single parameter.
using sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule >::InvocationRule_t = std::remove_cvref_t<TInvocationRule> |
using sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule >::Predicate_t = std::remove_cvref_t<TPredicate> |
using sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule >::Projection_t = std::remove_cvref_t<TProjection> |
|
inlineexplicitnoexcept |
Constructor.
predicate | Used predicate. May be default constructed via default argument. |
projection | Used projection. May be default constructed via default argument. |
invocation | Used invocation rule. May be default constructed via default argument. |
|
inlineexplicitnoexcept |
Constructor overload for in_place predicate initializing.
TArgs | Types of the predicate constructor arguments |
_ | Dummy value used for detecting the overload. Simply pass std::in_place as argument. |
args | Constructor arguments for the predicate |
Constructs the predicate in-place
|
inlineconstexprnoexcept |
NoOp.
|
inline |
Invoke operator.
TRecord | Used Record type |
record | The current handled Record object |
messageByteSize | The size of the current handled message in bytes |
Just invokes the predicate with the result of the invoked projection and messageByteSize