Simple-Log  alpha-v0.7
sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule > Class Template Reference

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...
 

Detailed Description

template<class TPredicate, class TProjection = std::identity, class TInvocationRule = detail::PredProjInvocation>
class sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule >

A customizable FlushPolicy class.

Template Parameters
TPredicateThe predicate must be invokable with the result of TProjection and must boolean-comparable results.
TProjectionThe projection must be invokable with the used Record type and must return something non-void.
TInvocationRuleThis 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.

Member Typedef Documentation

◆ InvocationRule_t

template<class TPredicate , class TProjection = std::identity, class TInvocationRule = detail::PredProjInvocation>
using sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule >::InvocationRule_t = std::remove_cvref_t<TInvocationRule>

◆ Predicate_t

template<class TPredicate , class TProjection = std::identity, class TInvocationRule = detail::PredProjInvocation>
using sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule >::Predicate_t = std::remove_cvref_t<TPredicate>

◆ Projection_t

template<class TPredicate , class TProjection = std::identity, class TInvocationRule = detail::PredProjInvocation>
using sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule >::Projection_t = std::remove_cvref_t<TProjection>

Constructor & Destructor Documentation

◆ FlushPolicy() [1/2]

template<class TPredicate , class TProjection = std::identity, class TInvocationRule = detail::PredProjInvocation>
sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule >::FlushPolicy ( TPredicate  predicate = Predicate_t{},
TProjection  projection = Projection_t{},
TInvocationRule  invocation = InvocationRule_t{} 
)
inlineexplicitnoexcept

Constructor.

Parameters
predicateUsed predicate. May be default constructed via default argument.
projectionUsed projection. May be default constructed via default argument.
invocationUsed invocation rule. May be default constructed via default argument.

◆ FlushPolicy() [2/2]

template<class TPredicate , class TProjection = std::identity, class TInvocationRule = detail::PredProjInvocation>
template<class... TArgs>
requires std::constructible_from<Predicate_t, TArgs...> sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule >::FlushPolicy ( std::in_place_t  _,
TArgs &&...  args 
)
inlineexplicitnoexcept

Constructor overload for in_place predicate initializing.

Template Parameters
TArgsTypes of the predicate constructor arguments
Parameters
_Dummy value used for detecting the overload. Simply pass std::in_place as argument.
argsConstructor arguments for the predicate

Constructs the predicate in-place

Member Function Documentation

◆ flushed()

template<class TPredicate , class TProjection = std::identity, class TInvocationRule = detail::PredProjInvocation>
constexpr void sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule >::flushed ( ) const
inlineconstexprnoexcept

NoOp.

◆ operator()()

template<class TPredicate , class TProjection = std::identity, class TInvocationRule = detail::PredProjInvocation>
template<Record TRecord>
bool sl::log::FlushPolicy< TPredicate, TProjection, TInvocationRule >::operator() ( const TRecord &  record,
std::size_t  messageByteSize 
)
inline

Invoke operator.

Template Parameters
TRecordUsed Record type
Parameters
recordThe current handled Record object
messageByteSizeThe size of the current handled message in bytes
Returns
Returns the result of the predicate invocation

Just invokes the predicate with the result of the invoked projection and messageByteSize


The documentation for this class was generated from the following file: