Need a break? Support the development by playing Polarity Puzzles
TBTK::Communicator Class Reference

Base class for classes that can communicate their status during execution. More...

#include <Communicator.h>

Inheritance diagram for TBTK::Communicator:
TBTK::LUSolver TBTK::Model TBTK::Solver::ArnoldiIterator TBTK::Solver::BlockDiagonalizer TBTK::Solver::ChebyshevExpander TBTK::Solver::Diagonalizer TBTK::Solver::LinearEquationSolver TBTK::Models::SquareLattice

Public Member Functions

 Communicator (bool verbose)
void setVerbose (bool verbose)
bool getVerbose () const

Static Public Member Functions

static void setGlobalVerbose (bool globalVerbose)
static bool getGlobalVerbose ()

Detailed Description

Base class for classes that can communicate their status during execution.

The communicator allows for both the global verbosity and the verbosity of individual objects to be modified. A class that inherits from Communicator is provided with two functions for setting and getting its verbosity. Setting the verbosity to true means the object may output text to the Streams during execution.

The Communicator class also provides two static functions for setting the verbosity globally. If the global verbosity set to false, no information should be written to the Streams even if the individual objects have their verbosity set to true. To respect this behavior, classes that derive from the communicator should enclose any output to Streams with the statement

if(getVerbose() && Streams::getGlobalVerbose()){
//Output to Streams here

Note: Error messages should not be muted.


#include "TBTK/Streams.h"
#include "TBTK/TBTK.h"
#include <vector>
using namespace std;
using namespace TBTK;
class MyCommunicator : public Communicator{
MyCommunicator() : Communicator(true){}
void say(const std::string &message){
Streams::out << message << "\n";
int main(){
MyCommunicator myCommunicator;
myCommunicator.say("Don't say this");
myCommunicator.say("Say this");
myCommunicator.say("Don't say this");


Say this

Constructor & Destructor Documentation

◆ Communicator()

TBTK::Communicator::Communicator ( bool  verbose)


verboseFlag indicating whether or not the communicator is verbose

Member Function Documentation

◆ getGlobalVerbose()

bool TBTK::Communicator::getGlobalVerbose ( )

Get global verbose.

False if communication is suppressed globally.

◆ getVerbose()

bool TBTK::Communicator::getVerbose ( ) const

Get verbose.

True if the Communicator is verbose, otherwise false.

◆ setGlobalVerbose()

void TBTK::Communicator::setGlobalVerbose ( bool  globalVerbose)

Set global verbose.

globalVerboseIf set to false, Communicators will not communicate even if they are verbose.

◆ setVerbose()

void TBTK::Communicator::setVerbose ( bool  verbose)

Set verbose.

verboseFlag indicating whether or not the Communicator is verbose.

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