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
Note: Error messages should not be muted.
Example
#include <vector>
using namespace std;
using namespace TBTK;
public:
void say(const std::string &message){
}
}
};
int main(){
MyCommunicator myCommunicator;
myCommunicator.setVerbose(false);
myCommunicator.say("Don't say this");
myCommunicator.setVerbose(true);
myCommunicator.say("Say this");
myCommunicator.say("Don't say this");
}
Output