crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
crawlservpp::Struct::StatusSetter Struct Reference

Structure containing all the data needed to keep the status of a thread updated. More...

#include <StatusSetter.hpp>

Properties

std::string currentStatus
 The current status, to which the current progress will be added. More...
 
float progressAfter
 The progress to which the thread will be (re-)set when the current task has been finished, in percent. More...
 

Callback Functions

std::function< void(const std::string &)> callbackSetStatus
 Callback function to update the status message of the current thread. More...
 
std::function< void(float)> callbackSetProgress
 Callback function to update the progress of the current thread, in percent. More...
 
std::function< bool()> callbackIsRunning
 Callback function to check whether the current thread should still be running. More...
 

Constructor

 StatusSetter (const std::string &setCurrentStatus, float setProgressAfter, std::function< void(const std::string &)> callbackToSetStatus, std::function< void(float)> callbackToSetProgress, std::function< bool()> callbackToCheckIsRunning)
 Constructor setting the initial status. More...
 
bool change (const std::string &statusMessage)
 Changes the status message and resets the current progress. More...
 
bool update (std::size_t done, std::size_t total) const
 Updates the status with a fractal progress. More...
 
bool update (float percentage, bool precise) const
 Updates the status with a percentage. More...
 
bool update (std::size_t done, std::size_t total, bool precise) const
 Calculates the current percentage and updates the status accordingly. More...
 
bool isRunning () const
 Checks whether the thread is still supposed to run. More...
 
void finish () const
 Re-sets the progress of the thread. More...
 

Detailed Description

Structure containing all the data needed to keep the status of a thread updated.

Constructor & Destructor Documentation

◆ StatusSetter()

crawlservpp::Struct::StatusSetter::StatusSetter ( const std::string &  setCurrentStatus,
float  setProgressAfter,
std::function< void(const std::string &)>  callbackToSetStatus,
std::function< void(float)>  callbackToSetProgress,
std::function< bool()>  callbackToCheckIsRunning 
)
inline

Constructor setting the initial status.

Note
The constructor will already use use the given callback function!
Parameters
setCurrentStatusThe current status that will be set on construction and updated on further progress.
setProgressAfterThe progress to which the thread should be set after finishing the task, in percent, or 1.F, if the progress should remain at 100% in the end.
callbackToSetStatusThe function (or lambda) that will be used to set the status message of the current thread.
callbackToSetProgressThe function (or lambda) that will be used to set the progress of the current thread, in percent.
callbackToCheckIsRunningThe function (or lambda) that will be used to check whether the thread is still supposed to run.

References callbackIsRunning, callbackSetProgress, and callbackSetStatus.

Member Function Documentation

◆ change()

bool crawlservpp::Struct::StatusSetter::change ( const std::string &  statusMessage)
inline

Changes the status message and resets the current progress.

Parameters
statusMessageConstant reference to a string containing the new status message.
Returns
True, if the thread is supposed to continue running. False, otherwise.

References callbackIsRunning, callbackSetProgress, and callbackSetStatus.

Referenced by crawlservpp::Module::Analyzer::Thread::checkCorpusSources(), crawlservpp::Module::Analyzer::Database::checkSources(), crawlservpp::Module::Analyzer::Thread::cleanUpQueries(), crawlservpp::Data::Corpus::clear(), crawlservpp::Data::Corpus::Corpus(), crawlservpp::Data::Corpus::filterArticles(), and crawlservpp::Module::Analyzer::Algo::TopicModelling::resetAlgo().

◆ finish()

◆ isRunning()

bool crawlservpp::Struct::StatusSetter::isRunning ( ) const
inline

Checks whether the thread is still supposed to run.

Returns
True, if the thread is supposed to continue running. False, otherwise.

References callbackIsRunning.

Referenced by crawlservpp::Module::Analyzer::Database::checkSources(), crawlservpp::Module::Analyzer::Thread::cleanUpQueries(), crawlservpp::Data::Corpus::clear(), and crawlservpp::Module::Analyzer::Database::getCorpus().

◆ update() [1/3]

bool crawlservpp::Struct::StatusSetter::update ( std::size_t  done,
std::size_t  total 
) const
inline

◆ update() [2/3]

bool crawlservpp::Struct::StatusSetter::update ( float  percentage,
bool  precise 
) const
inline

Updates the status with a percentage.

Parameters
percentageProgress between 0.F (none) and 1.F (done).
preciseIf set to true, the progress will be added to the status with higher precision.
Returns
True, if the thread is supposed to continue running. False, otherwise.
See also
precisionProgress

References callbackIsRunning, callbackSetProgress, callbackSetStatus, currentStatus, crawlservpp::Struct::percentageFactor, and crawlservpp::Struct::precisionProgress.

◆ update() [3/3]

bool crawlservpp::Struct::StatusSetter::update ( std::size_t  done,
std::size_t  total,
bool  precise 
) const
inline

Calculates the current percentage and updates the status accordingly.

Parameters
doneThe number of processed units.
totalThe total number of units to be processed.
preciseIf set to true, the progress will be added to the status with higher precision.
Returns
True, if the thread is supposed to continue running. False, otherwise.
See also
precisionProgress

References update().

Member Data Documentation

◆ callbackIsRunning

std::function<bool()> crawlservpp::Struct::StatusSetter::callbackIsRunning

Callback function to check whether the current thread should still be running.

Referenced by change(), isRunning(), StatusSetter(), and update().

◆ callbackSetProgress

std::function<void(float)> crawlservpp::Struct::StatusSetter::callbackSetProgress

Callback function to update the progress of the current thread, in percent.

Referenced by change(), finish(), StatusSetter(), and update().

◆ callbackSetStatus

std::function<void(const std::string&)> crawlservpp::Struct::StatusSetter::callbackSetStatus

Callback function to update the status message of the current thread.

Referenced by change(), finish(), StatusSetter(), and update().

◆ currentStatus

std::string crawlservpp::Struct::StatusSetter::currentStatus

The current status, to which the current progress will be added.

Referenced by update().

◆ progressAfter

float crawlservpp::Struct::StatusSetter::progressAfter

The progress to which the thread will be (re-)set when the current task has been finished, in percent.

Set to a value between 0.F (none) to 1.F (done).


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