numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
num_collect::logging::iterations::iteration_logger< Algorithm > Class Template Reference

Class to write logs of iterations. More...

#include <num_collect/logging/iterations/iteration_logger.h>

+ Collaboration diagram for num_collect::logging::iterations::iteration_logger< Algorithm >:

Public Member Functions

 iteration_logger (logger &logger)
 Constructor.
 
void append (std::shared_ptr< iteration_parameter_base< Algorithm > > parameter)
 Append a parameter.
 
template<concepts::formattable_iteration_parameter_value Value>
auto append (std::string label, const Value &value) -> iteration_parameter< Algorithm, Value, variable_iteration_parameter_value< Algorithm, Value > > *
 Append a parameter specified by variables.
 
template<concepts::formattable_iteration_parameter_value Value>
auto append (std::string label, const Value Algorithm::*ptr) -> iteration_parameter< Algorithm, Value, member_variable_iteration_parameter_value< Algorithm, Value > > *
 Append a parameter specified by member variables.
 
template<concepts::formattable_iteration_parameter_value Value, concepts::getter_of< Value > Function>
auto append (std::string label, Function &&function) -> iteration_parameter< Algorithm, Value, function_iteration_parameter_value< Algorithm, Value, std::decay_t< Function > > > *
 Append a parameter specified by functions.
 
template<concepts::formattable_iteration_parameter_value Value, concepts::member_getter_of< Value, Algorithm > Function>
auto append (std::string label, Function &&function) -> iteration_parameter< Algorithm, Value, member_function_iteration_parameter_value< Algorithm, Value, std::decay_t< Function > > > *
 Append a parameter specified by member functions.
 
template<concepts::formattable_iteration_parameter_value Value, concepts::iteration_parameter_value< Algorithm, Value > ParameterValue>
auto append (std::string label, ParameterValue value) -> iteration_parameter< Algorithm, Value, ParameterValue > *
 Append a parameter.
 
void start (logger &logger)
 Start iterations.
 
void write_iteration (Algorithm *algorithm, util::source_info_view source=util::source_info_view())
 Write an iteration to the logger.
 
void write_iteration (util::source_info_view source=util::source_info_view())
 Write an iteration to the logger.
 
void write_summary (Algorithm *algorithm, util::source_info_view source=util::source_info_view())
 Write a summary to a logger.
 
void write_summary (util::source_info_view source=util::source_info_view())
 Write a summary to a logger.
 

Private Member Functions

void format_labels_to (fmt::memory_buffer &buffer) const
 Format a line of labels.
 
void format_summary_to (fmt::memory_buffer &buffer) const
 Format a line of summary.
 
void format_summary_to (fmt::memory_buffer &buffer, Algorithm *algorithm) const
 Format a line of summary.
 
void format_values_to (fmt::memory_buffer &buffer) const
 Format a line of values.
 
void format_values_to (fmt::memory_buffer &buffer, Algorithm *algorithm) const
 Format a line of values.
 
auto should_write_iteration () -> bool
 Determine whether to write an iteration to the logger.
 
void write_label_if_needed (util::source_info_view source)
 Write labels if needed.
 

Private Attributes

fmt::memory_buffer buffer_ {}
 Buffer of logging data.
 
util::iteration_period_checker iteration_label_period_checker_
 Checker of periods to write labels of iteration logs.
 
util::iteration_period_checker iteration_output_period_checker_
 Checker of periods to write iteration logs.
 
std::vector< std::shared_ptr< iteration_parameter_base< Algorithm > > > parameters_ {}
 Parameters.
 
sinks::log_sink sink_
 Log sink.
 
log_tag_view tag_
 Log tag.
 
bool write_iterations_ {false}
 Whether to write iteration logs.
 
bool write_summaries_ {false}
 Whether to write summary logs.
 

Detailed Description

template<typename Algorithm = std::monostate>
class num_collect::logging::iterations::iteration_logger< Algorithm >

Class to write logs of iterations.

Template Parameters
AlgorithmType of the algorithm. If the pointer of an algorithm is not used, this template parameter can be any type as the default type.

Definition at line 59 of file iteration_logger.h.

Constructor & Destructor Documentation

◆ iteration_logger()

template<typename Algorithm = std::monostate>
num_collect::logging::iterations::iteration_logger< Algorithm >::iteration_logger ( logger & logger)
inlineexplicit

Constructor.

Parameters
[in]loggerLogger.

Definition at line 66 of file iteration_logger.h.

Member Function Documentation

◆ append() [1/6]

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::append ( std::shared_ptr< iteration_parameter_base< Algorithm > > parameter)
inline

Append a parameter.

Parameters
[in]parameterParameter.

Definition at line 93 of file iteration_logger.h.

◆ append() [2/6]

template<typename Algorithm = std::monostate>
template<concepts::formattable_iteration_parameter_value Value>
auto num_collect::logging::iterations::iteration_logger< Algorithm >::append ( std::string label,
const Value & value ) -> iteration_parameter<Algorithm, Value, variable_iteration_parameter_value<Algorithm, Value>>*
inline

Append a parameter specified by variables.

Template Parameters
ValueType of values.
Parameters
[in]labelLabel.
[in]valueParameter value.
Returns
Parameter.

Definition at line 129 of file iteration_logger.h.

◆ append() [3/6]

template<typename Algorithm = std::monostate>
template<concepts::formattable_iteration_parameter_value Value>
auto num_collect::logging::iterations::iteration_logger< Algorithm >::append ( std::string label,
const Value Algorithm::* ptr ) -> iteration_parameter<Algorithm, Value, member_variable_iteration_parameter_value<Algorithm, Value>>*
inline

Append a parameter specified by member variables.

Template Parameters
ValueType of values.
Parameters
[in]labelLabel.
[in]ptrPointer to the member variable.
Returns
Parameter.

Definition at line 165 of file iteration_logger.h.

◆ append() [4/6]

template<typename Algorithm = std::monostate>
template<concepts::formattable_iteration_parameter_value Value, concepts::getter_of< Value > Function>
auto num_collect::logging::iterations::iteration_logger< Algorithm >::append ( std::string label,
Function && function ) -> iteration_parameter<Algorithm, Value, function_iteration_parameter_value<Algorithm, Value, std::decay_t<Function>>>*
inline

Append a parameter specified by functions.

Template Parameters
ValueType of values.
FunctionType of the function.
Parameters
[in]labelLabel.
[in]functionFunction to get values.
Returns
Parameter.

Definition at line 147 of file iteration_logger.h.

◆ append() [5/6]

template<typename Algorithm = std::monostate>
template<concepts::formattable_iteration_parameter_value Value, concepts::member_getter_of< Value, Algorithm > Function>
auto num_collect::logging::iterations::iteration_logger< Algorithm >::append ( std::string label,
Function && function ) -> iteration_parameter<Algorithm, Value, member_function_iteration_parameter_value<Algorithm, Value, std::decay_t<Function>>>*
inline

Append a parameter specified by member functions.

Template Parameters
ValueType of values.
FunctionType of the function.
Parameters
[in]labelLabel.
[in]functionPointer to the member function.
Returns
Parameter.

Definition at line 183 of file iteration_logger.h.

◆ append() [6/6]

template<typename Algorithm = std::monostate>
template<concepts::formattable_iteration_parameter_value Value, concepts::iteration_parameter_value< Algorithm, Value > ParameterValue>
auto num_collect::logging::iterations::iteration_logger< Algorithm >::append ( std::string label,
ParameterValue value ) -> iteration_parameter<Algorithm, Value, ParameterValue>*
inline

Append a parameter.

Template Parameters
ValueType of values.
ParameterValueClass of parameters values in iterations specified by variables.
Parameters
[in]labelLabel.
[in]valueParameter value.
Returns
Parameter.

Definition at line 110 of file iteration_logger.h.

◆ format_labels_to()

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::format_labels_to ( fmt::memory_buffer & buffer) const
inlineprivate

Format a line of labels.

Parameters
[out]bufferBuffer to format to.

Definition at line 314 of file iteration_logger.h.

◆ format_summary_to() [1/2]

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::format_summary_to ( fmt::memory_buffer & buffer) const
inlineprivate

Format a line of summary.

Parameters
[out]bufferBuffer to format to.

Definition at line 352 of file iteration_logger.h.

◆ format_summary_to() [2/2]

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::format_summary_to ( fmt::memory_buffer & buffer,
Algorithm * algorithm ) const
inlineprivate

Format a line of summary.

Parameters
[out]bufferBuffer to format to.
[in]algorithmAlgorithm.

Definition at line 372 of file iteration_logger.h.

◆ format_values_to() [1/2]

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::format_values_to ( fmt::memory_buffer & buffer) const
inlineprivate

Format a line of values.

Parameters
[out]bufferBuffer to format to.

Definition at line 326 of file iteration_logger.h.

◆ format_values_to() [2/2]

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::format_values_to ( fmt::memory_buffer & buffer,
Algorithm * algorithm ) const
inlineprivate

Format a line of values.

Parameters
[out]bufferBuffer to format to.
[in]algorithmAlgorithm.

Definition at line 339 of file iteration_logger.h.

◆ should_write_iteration()

template<typename Algorithm = std::monostate>
auto num_collect::logging::iterations::iteration_logger< Algorithm >::should_write_iteration ( ) -> bool
inlinenodiscardprivate

Determine whether to write an iteration to the logger.

Returns
Whether to write an iteration to the logger.

Definition at line 280 of file iteration_logger.h.

◆ start()

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::start ( logger & logger)
inline

Start iterations.

Parameters
[in]loggerLogger.

Definition at line 81 of file iteration_logger.h.

◆ write_iteration() [1/2]

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::write_iteration ( Algorithm * algorithm,
util::source_info_view source = util::source_info_view() )
inline

Write an iteration to the logger.

Parameters
[in]algorithmAlgorithm.
[in]sourceInformation of the source code.
Note
This will write logs taking period configurations into account.

Definition at line 223 of file iteration_logger.h.

◆ write_iteration() [2/2]

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::write_iteration ( util::source_info_view source = util::source_info_view())
inline

Write an iteration to the logger.

Parameters
[in]sourceInformation of the source code.
Note
This will write logs taking period configurations into account.

Definition at line 199 of file iteration_logger.h.

◆ write_label_if_needed()

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::write_label_if_needed ( util::source_info_view source)
inlineprivate

Write labels if needed.

Parameters
[in]sourceInformation of the source code.

Definition at line 298 of file iteration_logger.h.

◆ write_summary() [1/2]

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::write_summary ( Algorithm * algorithm,
util::source_info_view source = util::source_info_view() )
inline

Write a summary to a logger.

Parameters
[in]algorithmAlgorithm.
[in]sourceInformation of the source code.

Definition at line 262 of file iteration_logger.h.

◆ write_summary() [2/2]

template<typename Algorithm = std::monostate>
void num_collect::logging::iterations::iteration_logger< Algorithm >::write_summary ( util::source_info_view source = util::source_info_view())
inline

Write a summary to a logger.

Parameters
[in]sourceInformation of the source code.

Definition at line 244 of file iteration_logger.h.

Member Data Documentation

◆ buffer_

template<typename Algorithm = std::monostate>
fmt::memory_buffer num_collect::logging::iterations::iteration_logger< Algorithm >::buffer_ {}
private

Buffer of logging data.

Definition at line 410 of file iteration_logger.h.

◆ iteration_label_period_checker_

template<typename Algorithm = std::monostate>
util::iteration_period_checker num_collect::logging::iterations::iteration_logger< Algorithm >::iteration_label_period_checker_
private

Checker of periods to write labels of iteration logs.

Definition at line 403 of file iteration_logger.h.

◆ iteration_output_period_checker_

template<typename Algorithm = std::monostate>
util::iteration_period_checker num_collect::logging::iterations::iteration_logger< Algorithm >::iteration_output_period_checker_
private

Checker of periods to write iteration logs.

Definition at line 400 of file iteration_logger.h.

◆ parameters_

template<typename Algorithm = std::monostate>
std::vector<std::shared_ptr<iteration_parameter_base<Algorithm> > > num_collect::logging::iterations::iteration_logger< Algorithm >::parameters_ {}
private

Parameters.

Definition at line 407 of file iteration_logger.h.

◆ sink_

template<typename Algorithm = std::monostate>
sinks::log_sink num_collect::logging::iterations::iteration_logger< Algorithm >::sink_
private

Log sink.

Definition at line 397 of file iteration_logger.h.

◆ tag_

template<typename Algorithm = std::monostate>
log_tag_view num_collect::logging::iterations::iteration_logger< Algorithm >::tag_
private

Log tag.

Definition at line 388 of file iteration_logger.h.

◆ write_iterations_

template<typename Algorithm = std::monostate>
bool num_collect::logging::iterations::iteration_logger< Algorithm >::write_iterations_ {false}
private

Whether to write iteration logs.

Definition at line 391 of file iteration_logger.h.

◆ write_summaries_

template<typename Algorithm = std::monostate>
bool num_collect::logging::iterations::iteration_logger< Algorithm >::write_summaries_ {false}
private

Whether to write summary logs.

Definition at line 394 of file iteration_logger.h.


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