SPH
Public Member Functions | Protected Attributes | List of all members
ILogWriter Class Referenceabstract

Base class for objects logging run statistics. More...

#include <LogWriter.h>

Inheritance diagram for ILogWriter:
PeriodicTrigger ITrigger Polymorphic BriefLogWriter EnergyLogWriter IntegralsLogWriter LogWriter NullLogWriter StandardLogWriter VerboseLogWriter

Public Member Functions

 ILogWriter (const SharedPtr< ILogger > &logger, const Float period=0._f)
 Constructs the log file. More...
 
virtual AutoPtr< ITriggeraction (Storage &storage, Statistics &stats) override final
 Writes to the log using provided storage and statistics. More...
 
virtual void write (const Storage &storage, const Statistics &stats)=0
 Writes to the log using provided storage and statistics. More...
 
- Public Member Functions inherited from PeriodicTrigger
 PeriodicTrigger (const Float period, const Float startTime)
 period Period in simulation time of triggered action. More...
 
virtual TriggerEnum type () const override
 Returns the type of the trigger. More...
 
virtual bool condition (const Storage &UNUSED(storage), const Statistics &stats) override
 
- Public Member Functions inherited from ITrigger
virtual bool condition (const Storage &storage, const Statistics &stats)=0
 Returns true if the trigger should be executed. More...
 
- Public Member Functions inherited from Polymorphic
virtual ~Polymorphic ()
 

Protected Attributes

SharedPtr< ILoggerlogger
 

Detailed Description

Base class for objects logging run statistics.

Definition at line 10 of file LogWriter.h.

Constructor & Destructor Documentation

◆ ILogWriter()

NAMESPACE_SPH_BEGIN ILogWriter::ILogWriter ( const SharedPtr< ILogger > &  logger,
const Float  period = 0._f 
)
explicit

Constructs the log file.

This base class actually does not use the logger in any way, it is stored there (and required in the constructor) because all derived classes are expected to use a logger; this way we can reduce the code duplication.

Parameters
loggerLogger for the written data. Must not be nullptr.
periodLog period in run time. Must be a positive value or zero; zero period means the log message is written on every time step.

Definition at line 12 of file LogWriter.cpp.

Member Function Documentation

◆ action()

AutoPtr< ITrigger > ILogWriter::action ( Storage storage,
Statistics stats 
)
finaloverridevirtual

Writes to the log using provided storage and statistics.

Same as write, implemented to allow using ILogWriter as a ITrigger.

Implements ITrigger.

Definition at line 18 of file LogWriter.cpp.

◆ write()

virtual void ILogWriter::write ( const Storage storage,
const Statistics stats 
)
pure virtual

Writes to the log using provided storage and statistics.

Used for const-correctness (loggers should not modify storage nor stats) and returning another (non-nullptr) trigger (loggers do not create more triggers).

Implemented in NullLogWriter, IntegralsLogWriter, BriefLogWriter, VerboseLogWriter, and StandardLogWriter.

Member Data Documentation

◆ logger

SharedPtr<ILogger> ILogWriter::logger
protected

Definition at line 12 of file LogWriter.h.


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