2016-06-15 23:48:41 +02:00
|
|
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
|
|
|
|
2020-06-03 23:14:17 +02:00
|
|
|
ServiceInterfaceStream::ServiceInterfaceStream(std::string setMessage,
|
2020-06-04 14:08:26 +02:00
|
|
|
bool addCrToPreamble, bool buffered, bool errStream, uint16_t port) :
|
|
|
|
std::ostream(&buf),
|
|
|
|
buf(setMessage, addCrToPreamble, buffered, errStream, port) {
|
2020-06-03 23:14:17 +02:00
|
|
|
}
|
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
void ServiceInterfaceStream::setActive( bool myActive) {
|
2020-06-04 14:08:26 +02:00
|
|
|
this->buf.isActive = myActive;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
2020-06-03 23:14:17 +02:00
|
|
|
std::string ServiceInterfaceStream::getPreamble() {
|
2020-06-04 14:08:26 +02:00
|
|
|
return buf.getPreamble();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceInterfaceStream::print(std::string error,
|
|
|
|
bool withPreamble, bool withNewline, bool flush) {
|
|
|
|
if(not buffered and withPreamble) {
|
|
|
|
*this << getPreamble() << error;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*this << error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(withNewline) {
|
|
|
|
*this << "\n";
|
|
|
|
}
|
|
|
|
// if mode is non-buffered, no need to flush.
|
|
|
|
if(flush and buffered) {
|
|
|
|
this->flush();
|
|
|
|
}
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|