Library of Assembled Shared Sources
|
A proxy output stream can distribute output to multiple destination streams. More...
#include <proxy_o_stream.h>
Public Member Functions | |
ProxyOStream (std::ostream *destination=&std::cout, TMask filterMask=acceptAll) | |
Construct a proxy with a destination, and set a filter for it. | |
void | add (std::ostream *destination, TMask filterMask=acceptAll) |
Add a std::ostream to the list of destination streams. | |
void | remove (std::ostream *destination) |
Remove a std::ostream from the list of destination streams. | |
TMask | filter (std::ostream *destination) const |
Return accept mask on destination stream. | |
void | setFilter (std::ostream *destination, TMask filterMask) |
Set filter on destination stream. | |
template<typename T> | |
impl::ProxyOStreamLock | operator<< (const T &x) |
ProxyOStreamLock proxy stream for output on 'acceptAll' and distribute input. | |
impl::ProxyOStreamLock | operator<< (std::ostream &(*x)(std::ostream &)) |
ProxyOStreamLock proxy stream for output on 'acceptAll' and distribute the std manipulator. | |
void | flush () |
flush all destination streams. | |
A proxy output stream can distribute output to multiple destination streams.
You can add multiple destination streams to a proxy stream, and all output to the proxy stream will be redirected to all these destinations.
You can also assign a filter to the proxy, and only messages with levels set in the filter will pass. e.g. if you set the filter of the proxy as proxy.setFilter() = 0, then only messages of warning or error levels will pass.
How do you tell what level your message has? Simple, before you use the insertor, you call the function operator on the stream with the correct level. This returns a lock on the proxy, and now you send the message to the lock (by the insertor) Wheter this message will pass or not, is determined by the lock. At the end of the lifetime of the lock, the proxy is also flushed.
proxy(Warning) << "This is a warning: " << theWarning;
In the above example, the proxy is locked in warning level, and the string and theWarning is passed to the lock. At the end, the lock flushes te proxy.
If you don't use the function operator to set the message level, the level is implicit set to ProxyOStream::Note.
OK, seriously, i have no longer any idea why we need this ... get rid of it?
Definition at line 123 of file proxy_o_stream.h.
lass::io::ProxyOStream::ProxyOStream | ( | std::ostream * | destination = &std::cout, |
TMask | destinationMask = acceptAll ) |
Construct a proxy with a destination, and set a filter for it.
Construct a proxy with a destination, and set a filter for it
Definition at line 63 of file proxy_o_stream.cpp.
References add().
void lass::io::ProxyOStream::add | ( | std::ostream * | destination, |
TMask | destinationMask = acceptAll ) |
Add a std::ostream to the list of destination streams.
Definition at line 75 of file proxy_o_stream.cpp.
Referenced by ProxyOStream(), and lass::io::Logger::subscribeTo().
void lass::io::ProxyOStream::remove | ( | std::ostream * | destination | ) |
Remove a std::ostream from the list of destination streams.
Definition at line 96 of file proxy_o_stream.cpp.
Referenced by lass::io::Logger::unsubscribeTo(), and lass::io::Logger::~Logger().
ProxyOStream::TMask lass::io::ProxyOStream::filter | ( | std::ostream * | destination | ) | const |
Return accept mask on destination stream.
If destination stream does not exists in proxy, it throws an exception.
Definition at line 111 of file proxy_o_stream.cpp.
void lass::io::ProxyOStream::setFilter | ( | std::ostream * | destination, |
TMask | destinationMask ) |
Set filter on destination stream.
If destination stream does not exists, it throws an exception.
Definition at line 129 of file proxy_o_stream.cpp.
|
inline |
ProxyOStreamLock proxy stream for output on 'acceptAll' and distribute input.
This command will give command to a lock, as if the message mask is acceptAll. This has the same effect as (*this)(acceptAll) << x;
Definition at line 147 of file proxy_o_stream.h.
impl::ProxyOStreamLock lass::io::ProxyOStream::operator<< | ( | std::ostream &(* | x )(std::ostream &) | ) |
ProxyOStreamLock proxy stream for output on 'acceptAll' and distribute the std manipulator.
This command will give command to a lock, as if the message mask is acceptAll. This has the same effect as (*this)(acceptAll) << x;
Definition at line 152 of file proxy_o_stream.cpp.