NOMAD Source  Version 4.0.0 Beta
OutputQueue Class Reference

Queue of all information that was not output yet. More...

#include <OutputQueue.hpp>

Collaboration diagram for OutputQueue:

Public Member Functions

virtual ~OutputQueue ()
 
void initParameters (const std::shared_ptr< DisplayParameters > &params)
 
void reset ()
 Flush and close stats file (called by initParameters) if OutputQueue has been already initialized. More...
 
void add (OutputInfo outputInfo)
 
void add (const std::string &s, OutputLevel outputLevel=OutputLevel::LEVEL_INFO)
 
void add (const StatsInfo &statsInfo)
 
size_t getMaxStepLevel () const
 
void setMaxStepLevel (const size_t maxStepLevel)
 
bool goodLevel (const OutputLevel &outputLevel) const
 
void setDisplayDegree (const int displayDegree)
 
void setStatsFileName (const std::string &statsFile)
 
void initStatsFile ()
 
const std::string & getStatsFileName () const
 
void setStatsFileFormat (const DisplayStatsTypeList &statsFileFormat)
 
const DisplayStatsTypeListgetStatsFileFormat () const
 
const ArrayOfDoublegetSolFormat () const
 

Static Public Member Functions

static std::unique_ptr< OutputQueue > & getInstance ()
 Access to singleton. More...
 
static void Add (OutputInfo outputInfo)
 
static void Add (const std::string &s, OutputLevel outputLevel=OutputLevel::LEVEL_INFO)
 
static void Add (const StatsInfo &statsInfo)
 
static void Flush ()
 Print all in the queue and flush. More...
 
static bool GoodLevel (const OutputLevel &outputLevel)
 

Private Member Functions

 OutputQueue ()
 Private constructor. More...
 
void startBlock ()
 
void endBlock ()
 
void flush ()
 
void flushBlock (const OutputInfo &outputInfo)
 
void flushStatsToStatsFile (const StatsInfo *statsInfo)
 
void flushStatsToStdout (const StatsInfo *statsInfo)
 
void indent (int level)
 

Private Attributes

std::vector< OutputInfo_queue
 Queue of all the OutputInfo we have to print. More...
 
std::shared_ptr< DisplayParameters_params
 Display parameters. More...
 
std::string _statsFile
 
std::ofstream _statsStream
 
DisplayStatsTypeList _statsFileFormat
 
size_t _statsLineCount
 
size_t _objWidth
 
size_t _hWidth
 
size_t _maxStepLevel
 Maximum step level we want to print out. More...
 
OutputLevel _maxOutputLevel
 Output level (~display degree) we want to print out. More...
 
int _indentLevel
 Internal indentation level. More...
 
const std::string _blockStart
 Symbol for a block start. More...
 
const std::string _blockEnd
 Symbol for an end block. More...
 

Static Private Attributes

static bool _hasBeenInitialized
 Flag for initialization (initialization cannot be performed more than once). More...
 
static std::unique_ptr< OutputQueue_single
 The singleton. More...
 

Detailed Description

Queue of all information that was not output yet.

The output queue is a singleton. Some OutputInfo can be added to the queue. The output information is displayed when calling OutputQueue::Flush and queue is emptied.
The information can be send to the standard display and to a stats file.
The display is formatted with indendation of blocks of information. The display parameters (DisplayParameters) are attributes of the class provided by calling OutputQueue::initParameters.
The display can be limited to a maximum block/step level. (OutputQueue::_maxStepLevel).

Todo:
Replace calls to std::cout by something more general.

Definition at line 75 of file OutputQueue.hpp.

Constructor & Destructor Documentation

◆ OutputQueue()

OutputQueue::OutputQueue ( )
private

Private constructor.

◆ ~OutputQueue()

virtual OutputQueue::~OutputQueue ( )
virtual

Member Function Documentation

◆ add() [1/3]

void OutputQueue::add ( const StatsInfo statsInfo)

◆ Add() [1/3]

static void OutputQueue::Add ( const StatsInfo statsInfo)
inlinestatic

Definition at line 108 of file OutputQueue.hpp.

109  {
110  getInstance()->add(statsInfo);
111  }

◆ add() [2/3]

void OutputQueue::add ( const std::string &  s,
OutputLevel  outputLevel = OutputLevel::LEVEL_INFO 
)

◆ Add() [2/3]

static void OutputQueue::Add ( const std::string &  s,
OutputLevel  outputLevel = OutputLevel::LEVEL_INFO 
)
inlinestatic

Definition at line 101 of file OutputQueue.hpp.

103  {
104  getInstance()->add(s, outputLevel);
105  }

◆ add() [3/3]

void OutputQueue::add ( OutputInfo  outputInfo)

◆ Add() [3/3]

static void OutputQueue::Add ( OutputInfo  outputInfo)
inlinestatic

Definition at line 94 of file OutputQueue.hpp.

95  {
96  getInstance()->add(std::move(outputInfo));
97  }

◆ endBlock()

void OutputQueue::endBlock ( )
private

◆ Flush()

static void OutputQueue::Flush ( )
inlinestatic

Print all in the queue and flush.

OutputInfo block start and block end flags will print _blockStart after the msg, or _blockEnd before.

Note
Example output:
Start step MADS {
_______Start step SEARCH {
_____________Things happening in SEARCH
_____________More things happening in SEARCH
_______} End step SEARCH
_______Start step POLL {
_____________Things happening in POLL
_____________More things happening in POLL
_______} End step POLL
} End step MADS
If there are more than one line to print, flags for block start and end are ignored.

Definition at line 131 of file OutputQueue.hpp.

132  {
133  getInstance()->flush();
134  }

◆ flush()

void OutputQueue::flush ( )
private

◆ flushBlock()

void OutputQueue::flushBlock ( const OutputInfo outputInfo)
private

◆ flushStatsToStatsFile()

void OutputQueue::flushStatsToStatsFile ( const StatsInfo statsInfo)
private

◆ flushStatsToStdout()

void OutputQueue::flushStatsToStdout ( const StatsInfo statsInfo)
private

◆ getInstance()

static std::unique_ptr<OutputQueue>& OutputQueue::getInstance ( )
static

Access to singleton.

◆ getMaxStepLevel()

size_t OutputQueue::getMaxStepLevel ( ) const
inline

Definition at line 137 of file OutputQueue.hpp.

137 { return _maxStepLevel; }

◆ getSolFormat()

const ArrayOfDouble& OutputQueue::getSolFormat ( ) const
inline

Definition at line 167 of file OutputQueue.hpp.

168  {
169  return _params->getAttributeValue<ArrayOfDouble>("SOL_FORMAT");
170  }

◆ getStatsFileFormat()

const DisplayStatsTypeList& OutputQueue::getStatsFileFormat ( ) const
inline

Definition at line 164 of file OutputQueue.hpp.

164 { return _statsFileFormat; }

◆ getStatsFileName()

const std::string& OutputQueue::getStatsFileName ( ) const
inline

Definition at line 158 of file OutputQueue.hpp.

158 { return _statsFile; }

◆ GoodLevel()

static bool OutputQueue::GoodLevel ( const OutputLevel outputLevel)
inlinestatic

Definition at line 141 of file OutputQueue.hpp.

142  {
143  return getInstance()->goodLevel(outputLevel);
144  }

◆ goodLevel()

bool OutputQueue::goodLevel ( const OutputLevel outputLevel) const

◆ indent()

void OutputQueue::indent ( int  level)
private

◆ initParameters()

void OutputQueue::initParameters ( const std::shared_ptr< DisplayParameters > &  params)

◆ initStatsFile()

void OutputQueue::initStatsFile ( )

◆ reset()

void OutputQueue::reset ( )

Flush and close stats file (called by initParameters) if OutputQueue has been already initialized.

◆ setDisplayDegree()

void OutputQueue::setDisplayDegree ( const int  displayDegree)

◆ setMaxStepLevel()

void OutputQueue::setMaxStepLevel ( const size_t  maxStepLevel)
inline

Definition at line 138 of file OutputQueue.hpp.

138 { _maxStepLevel = maxStepLevel; }

◆ setStatsFileFormat()

void OutputQueue::setStatsFileFormat ( const DisplayStatsTypeList statsFileFormat)
inline

Definition at line 160 of file OutputQueue.hpp.

161  {
162  _statsFileFormat = statsFileFormat;
163  }

◆ setStatsFileName()

void OutputQueue::setStatsFileName ( const std::string &  statsFile)
inline

Definition at line 156 of file OutputQueue.hpp.

156 { _statsFile = statsFile; }

◆ startBlock()

void OutputQueue::startBlock ( )
private

Member Data Documentation

◆ _blockEnd

const std::string OutputQueue::_blockEnd
private

Symbol for an end block.

Definition at line 218 of file OutputQueue.hpp.

◆ _blockStart

const std::string OutputQueue::_blockStart
private

Symbol for a block start.

Definition at line 217 of file OutputQueue.hpp.

◆ _hasBeenInitialized

bool OutputQueue::_hasBeenInitialized
staticprivate

Flag for initialization (initialization cannot be performed more than once).

Definition at line 181 of file OutputQueue.hpp.

◆ _hWidth

size_t OutputQueue::_hWidth
private

Definition at line 211 of file OutputQueue.hpp.

◆ _indentLevel

int OutputQueue::_indentLevel
private

Internal indentation level.

Definition at line 215 of file OutputQueue.hpp.

◆ _maxOutputLevel

OutputLevel OutputQueue::_maxOutputLevel
private

Output level (~display degree) we want to print out.

Definition at line 214 of file OutputQueue.hpp.

◆ _maxStepLevel

size_t OutputQueue::_maxStepLevel
private

Maximum step level we want to print out.

Definition at line 213 of file OutputQueue.hpp.

◆ _objWidth

size_t OutputQueue::_objWidth
private

Format width for OBJ and CONS_H. May be enlarged during the run.

Definition at line 209 of file OutputQueue.hpp.

◆ _params

std::shared_ptr<DisplayParameters> OutputQueue::_params
private

Display parameters.

Definition at line 189 of file OutputQueue.hpp.

◆ _queue

std::vector<OutputInfo> OutputQueue::_queue
private

Queue of all the OutputInfo we have to print.

Definition at line 186 of file OutputQueue.hpp.

◆ _single

std::unique_ptr<OutputQueue> OutputQueue::_single
staticprivate

The singleton.

Definition at line 183 of file OutputQueue.hpp.

◆ _statsFile

std::string OutputQueue::_statsFile
private

Definition at line 191 of file OutputQueue.hpp.

◆ _statsFileFormat

DisplayStatsTypeList OutputQueue::_statsFileFormat
private

Format for stats in a file (parameter STATS_FILE). Might include some raw strings, do not convert to DisplayStatsType.

Definition at line 198 of file OutputQueue.hpp.

◆ _statsLineCount

size_t OutputQueue::_statsLineCount
private

Keep track of the number of lines printed to output (DISPLAY_STATS). Used to print stats header regularly.

Definition at line 204 of file OutputQueue.hpp.

◆ _statsStream

std::ofstream OutputQueue::_statsStream
private

Definition at line 192 of file OutputQueue.hpp.


The documentation for this class was generated from the following file:
OutputQueue::_statsFile
std::string _statsFile
Definition: OutputQueue.hpp:191
ArrayOfDouble
Class for the representation of an array of n values.
Definition: ArrayOfDouble.hpp:67
OutputQueue::_maxStepLevel
size_t _maxStepLevel
Maximum step level we want to print out.
Definition: OutputQueue.hpp:213
OutputQueue::_statsFileFormat
DisplayStatsTypeList _statsFileFormat
Definition: OutputQueue.hpp:198
OutputQueue::getInstance
static std::unique_ptr< OutputQueue > & getInstance()
Access to singleton.
OutputQueue::_params
std::shared_ptr< DisplayParameters > _params
Display parameters.
Definition: OutputQueue.hpp:189