LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line::util::LineConsole Class Reference

#include <line/util/line_console.h>

Classes

class  Run
 RAII guard: opens a run on construction, closes it on scope exit. More...
class  Quiet
 RAII guard that suppresses structure-compile detail while it lives. More...
class  OwnModelCompile
 Lift the compile detail rule while the run compiles its OWN model. More...

Static Public Member Functions

static void set_verbose (VerboseLevel level)
 Set the session verbosity.
static VerboseLevel get_verbose ()
 The session verbosity.
static void reset ()
 Forget any open run (used after an interrupted solve).
static bool wanted (bool verbose=true)
 Resolve whether a run should narrate.
static bool is_active ()
 True while a run is narrating; gates SUPPRESSION of legacy prints.
static bool owns_log ()
 True only inside the OUTERMOST open run; gates EMISSION.
static bool writes ()
 True when a progress line should be printed: either the outermost run is narrating, or no run is open and the session is at DEBUG – the second case is what lets model construction narrate before any solver exists.
static bool begin_run (const std::string &tag, const std::string &model_name, bool verbose=true)
 Open a console run.
static void setup_done ()
 Mark the end of the setup phase, so the closing line can split the time.
static void end_run ()
 Close the innermost open run, writing the closing line.
static void step (const char *fmt,...)
 Write one progress line.
static void substep (const char *fmt,...)
 Write one indented progress line.
static void compile_detail (const char *fmt,...)
 One stage line of a structure compile: silenced inside a Quiet scope, and inside an open run, where the structures compiled are those of auxiliary models rather than of the model under study.
static void compiling (const std::string &name)
 Announce the compilation of a model structure.
static void loop (const char *fmt,...)
 Announce an iteration loop and reset its reporting budget.
static void iter (long k, const char *fmt,...)
 Report iteration k of the current loop.
static std::string plural (long n, const std::string &singular, const std::string &plural_form)
 Count with an agreeing noun, e.g.

Detailed Description

Definition at line 59 of file line_console.h.

Member Function Documentation

◆ begin_run()

bool line::util::LineConsole::begin_run ( const std::string & tag,
const std::string & model_name,
bool verbose = true )
inlinestatic

Open a console run.

Pair with end_run(), or use the Run guard below so that a failed analysis still reports what it had reached.

Parameters
tagshort solver name, e.g. "MVA"
model_namethe model under study
verbosethe run's own verbosity flag

Definition at line 139 of file line_console.h.

References wanted().

Referenced by line::util::LineConsole::Run::Run().

◆ compile_detail()

void line::util::LineConsole::compile_detail ( const char * fmt,
... )
inlinestatic

One stage line of a structure compile: silenced inside a Quiet scope, and inside an open run, where the structures compiled are those of auxiliary models rather than of the model under study.

Definition at line 252 of file line_console.h.

References writes().

Referenced by line::qn::NetworkStruct< T >::refresh_struct().

◆ compiling()

void line::util::LineConsole::compiling ( const std::string & name)
inlinestatic

Announce the compilation of a model structure.

A run opened before the model file was read carries no model name yet (the CLI knows the solver method name first), so the FIRST compile inside such a run names the run: it is the model under study, not an auxiliary one.

Definition at line 271 of file line_console.h.

References step().

Referenced by line::qn::NetworkStruct< T >::refresh_struct().

◆ end_run()

void line::util::LineConsole::end_run ( )
inlinestatic

Close the innermost open run, writing the closing line.

Definition at line 180 of file line_console.h.

References reset(), and step().

Referenced by line::util::LineConsole::Run::~Run().

◆ get_verbose()

VerboseLevel line::util::LineConsole::get_verbose ( )
inlinestatic

The session verbosity.

Definition at line 70 of file line_console.h.

◆ is_active()

bool line::util::LineConsole::is_active ( )
inlinestatic

True while a run is narrating; gates SUPPRESSION of legacy prints.

Definition at line 109 of file line_console.h.

◆ iter()

void line::util::LineConsole::iter ( long k,
const char * fmt,
... )
inlinestatic

Report iteration k of the current loop.

The first 20 iterations report in full, then every 10th, and the loop stops after 30 lines so a long run cannot bury the rest of the narration.

Definition at line 344 of file line_console.h.

References owns_log().

Referenced by line::ssa::NrmEngine< T >::run(), line::mva::solver_amvald(), and line::fluid::solver_fluid_moments().

◆ loop()

void line::util::LineConsole::loop ( const char * fmt,
... )
inlinestatic

Announce an iteration loop and reset its reporting budget.

Re-announcing the SAME text (a solver that restarts its loop) neither reprints the header nor refills the budget.

Definition at line 325 of file line_console.h.

References owns_log().

Referenced by line::ssa::NrmEngine< T >::run(), line::mva::solver_amvald(), and line::fluid::solver_fluid_moments().

◆ owns_log()

bool line::util::LineConsole::owns_log ( )
inlinestatic

True only inside the OUTERMOST open run; gates EMISSION.

Definition at line 112 of file line_console.h.

Referenced by line::mva::fj_fixed_point(), iter(), loop(), line::mva::solver_amvald(), and writes().

◆ plural()

std::string line::util::LineConsole::plural ( long n,
const std::string & singular,
const std::string & plural_form )
inlinestatic

Count with an agreeing noun, e.g.

"1 chain" or "3 chains".

Definition at line 364 of file line_console.h.

Referenced by line::qn::NetworkStruct< T >::refresh_struct().

◆ reset()

void line::util::LineConsole::reset ( )
inlinestatic

Forget any open run (used after an interrupted solve).

Definition at line 73 of file line_console.h.

Referenced by end_run(), and set_verbose().

◆ set_verbose()

void line::util::LineConsole::set_verbose ( VerboseLevel level)
inlinestatic

Set the session verbosity.

DEBUG is what switches the console on.

Definition at line 64 of file line_console.h.

References reset().

Referenced by main().

◆ setup_done()

void line::util::LineConsole::setup_done ( )
inlinestatic

Mark the end of the setup phase, so the closing line can split the time.

Definition at line 174 of file line_console.h.

◆ step()

◆ substep()

void line::util::LineConsole::substep ( const char * fmt,
... )
inlinestatic

Write one indented progress line.

Definition at line 238 of file line_console.h.

References writes().

Referenced by line::jmt::solver_jmt_run_analyzer().

◆ wanted()

bool line::util::LineConsole::wanted ( bool verbose = true)
inlinestatic

Resolve whether a run should narrate.

THE CONSOLE IS DEBUG, and this is the whole rule: a run narrates when the session is at DEBUG and at no lower level. The run's own verbose flag still vetoes – it spells SILENT when false, and a run asked to stay silent stays silent whatever the session asks for – but it cannot switch the console ON, because true there means STD, not DEBUG.

Definition at line 104 of file line_console.h.

References line::util::DEBUG.

Referenced by begin_run().

◆ writes()

bool line::util::LineConsole::writes ( )
inlinestatic

True when a progress line should be printed: either the outermost run is narrating, or no run is open and the session is at DEBUG – the second case is what lets model construction narrate before any solver exists.

Definition at line 122 of file line_console.h.

References line::util::DEBUG, and owns_log().

Referenced by compile_detail(), step(), and substep().


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