libpappsomspp
Library for mass spectrometry
pappso::UiMonitorText Class Reference

#include <uimonitortext.h>

Inheritance diagram for pappso::UiMonitorText:
pappso::UiMonitorInterface pappso::UiMonitorTextPercent

Public Member Functions

 UiMonitorText (QTextStream &output_stream)
 
 ~UiMonitorText ()
 
virtual bool shouldIstop () override
 should the procces be stopped ? If true, then cancel process Use this function at strategic point of your process in order to interrupt it cleanly Implementation must take care of thread resistance if implemented More...
 
virtual void count () override
 count steps report when a step is computed in an algorithm More...
 
virtual void setTitle (const QString &title) override
 current kind of process running More...
 
virtual void setStatus (const QString &status) override
 current status of the process More...
 
virtual void appendText (const QString &text) override
 append a text to a long report More...
 
virtual void setTotalSteps (std::size_t total_number_of_steps)
 use it if the number of steps is known in an algorithm the total number of steps is usefull to report to the user a progress message in percents or with a progress bar More...
 

Protected Attributes

QTextStream & m_outputStream
 
std::size_t m_count = 0
 
- Protected Attributes inherited from pappso::UiMonitorInterface
std::size_t m_totalSteps = 0
 

Detailed Description

Todo:
simple text monitor using text stream

Definition at line 41 of file uimonitortext.h.

Constructor & Destructor Documentation

◆ UiMonitorText()

UiMonitorText::UiMonitorText ( QTextStream &  output_stream)

Default constructor

Definition at line 35 of file uimonitortext.cpp.

36  : m_outputStream(output_stream)
37 {
38 }
QTextStream & m_outputStream
Definition: uimonitortext.h:80

◆ ~UiMonitorText()

UiMonitorText::~UiMonitorText ( )

Destructor

Definition at line 40 of file uimonitortext.cpp.

41 {
42 }

Member Function Documentation

◆ appendText()

void pappso::UiMonitorText::appendText ( const QString &  text)
overridevirtual

append a text to a long report

Parameters
textstring to append in a long report

Implements pappso::UiMonitorInterface.

Definition at line 82 of file uimonitortext.cpp.

83 {
84  m_outputStream << text;
85  m_outputStream.flush();
86 }

◆ count()

void pappso::UiMonitorText::count ( )
overridevirtual

count steps report when a step is computed in an algorithm

Implements pappso::UiMonitorInterface.

Reimplemented in pappso::UiMonitorTextPercent.

Definition at line 66 of file uimonitortext.cpp.

67 {
68  m_count++;
69  if(m_count <= m_totalSteps)
70  {
71  m_outputStream << m_count << " ";
72  }
73  else
74  {
75  m_outputStream << QObject::tr("%1 on %2").arg(m_count).arg(m_totalSteps)
76  << " ";
77  }
78  m_outputStream.flush();
79 }

◆ setStatus()

void pappso::UiMonitorText::setStatus ( const QString &  status)
overridevirtual

current status of the process

Parameters
statusstatus message

Implements pappso::UiMonitorInterface.

Definition at line 59 of file uimonitortext.cpp.

60 {
61  m_outputStream << status << Qt::endl;
62  m_outputStream.flush();
63 }

◆ setTitle()

void pappso::UiMonitorText::setTitle ( const QString &  title)
overridevirtual

current kind of process running

Parameters
titleprocess title

Implements pappso::UiMonitorInterface.

Definition at line 52 of file uimonitortext.cpp.

53 {
54  m_outputStream << title << Qt::endl;
55  m_outputStream.flush();
56 }

◆ setTotalSteps()

void pappso::UiMonitorText::setTotalSteps ( std::size_t  total_number_of_steps)
virtual

use it if the number of steps is known in an algorithm the total number of steps is usefull to report to the user a progress message in percents or with a progress bar

Parameters
total_number_of_stepsthe total number of steps

Reimplemented from pappso::UiMonitorInterface.

Reimplemented in pappso::UiMonitorTextPercent.

Definition at line 89 of file uimonitortext.cpp.

90 {
91  UiMonitorInterface::setTotalSteps(total_number_of_steps);
92  m_count = 0;
93 }
virtual void setTotalSteps(std::size_t total_number_of_steps)
use it if the number of steps is known in an algorithm the total number of steps is usefull to report...

References pappso::UiMonitorInterface::setTotalSteps().

Referenced by pappso::UiMonitorTextPercent::setTotalSteps().

◆ shouldIstop()

bool pappso::UiMonitorText::shouldIstop ( )
overridevirtual

should the procces be stopped ? If true, then cancel process Use this function at strategic point of your process in order to interrupt it cleanly Implementation must take care of thread resistance if implemented

Implements pappso::UiMonitorInterface.

Definition at line 45 of file uimonitortext.cpp.

46 {
47  // by defaut not interruptible
48  return false;
49 }

Member Data Documentation

◆ m_count

std::size_t pappso::UiMonitorText::m_count = 0
protected

Definition at line 81 of file uimonitortext.h.

◆ m_outputStream

QTextStream& pappso::UiMonitorText::m_outputStream
protected

Definition at line 80 of file uimonitortext.h.


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