library of assembled shared sources |
http://lass.cocamware.com |
#include <proxy_o_stream.h>
Data Structures | |
class | Lock |
Public Types | |
typedef unsigned | TMask |
Public Member Functions | |
ProxyOStream (std::ostream *iDestination=&std::cout, TMask iFilterMask=acceptAll) | |
Construct a proxy with a destination, and set a filter for it. | |
void | add (std::ostream *iDestination, TMask iFilterMask=acceptAll) |
Add a std::ostream to the list of destination streams. | |
void | remove (std::ostream *iDestination) |
Remove a std::ostream from the list of destination streams. | |
const TMask | filter (std::ostream *iDestination) const |
Return accept mask on destination stream. | |
void | setFilter (std::ostream *iDestination, TMask iFilterMask) |
Set filter on destination stream. | |
Lock | operator() (TMask iFilterMask=acceptAll) |
template<typename T > | |
Lock | operator<< (const T &iIn) |
Lock proxy stream for output on 'acceptAll' and distribute input. | |
Lock | operator<< (std::ostream &(*iIn)(std::ostream &)) |
Lock proxy stream for output on 'acceptAll' and distribute the std manipulator. | |
void | flush () |
flush all destination streams. | |
Static Public Attributes | |
static const TMask | acceptAll = static_cast<TMask>(-1) |
Private Types | |
typedef std::map< std::ostream *, TMask > | TDestinations |
Private Attributes | |
TDestinations | destinations_ |
Friends | |
class | Lock |
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 94 of file proxy_o_stream.h.
typedef unsigned lass::io::ProxyOStream::TMask |
Definition at line 98 of file proxy_o_stream.h.
typedef std::map<std::ostream*, TMask> lass::io::ProxyOStream::TDestinations [private] |
Definition at line 220 of file proxy_o_stream.h.
lass::io::ProxyOStream::ProxyOStream | ( | std::ostream * | iDestination = &std::cout , |
|
TMask | iMessageMask = 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.
Add a std::ostream to the list of destination streams.
Definition at line 76 of file proxy_o_stream.cpp.
References destinations_, and LASS_WARNING.
Referenced by lass::io::Logger::subscribeTo().
void lass::io::ProxyOStream::remove | ( | std::ostream * | iDestination | ) |
Remove a std::ostream from the list of destination streams.
Definition at line 97 of file proxy_o_stream.cpp.
References destinations_, and LASS_WARNING.
Referenced by lass::io::Logger::unsubscribeTo(), and lass::io::Logger::~Logger().
const ProxyOStream::TMask lass::io::ProxyOStream::filter | ( | std::ostream * | iDestination | ) | const |
Return accept mask on destination stream.
If destination stream does not exists in proxy, it throws an exception.
Definition at line 116 of file proxy_o_stream.cpp.
References destinations_, and LASS_THROW.
void lass::io::ProxyOStream::setFilter | ( | std::ostream * | iDestination, | |
TMask | iFilterMask | |||
) |
Set filter on destination stream.
If destination stream does not exists, it throws an exception.
Definition at line 133 of file proxy_o_stream.cpp.
References destinations_, and LASS_THROW.
ProxyOStream::Lock lass::io::ProxyOStream::operator() | ( | TMask | iFilterMask = acceptAll |
) |
Lock lass::io::ProxyOStream::operator<< | ( | const T & | iIn | ) | [inline] |
Lock 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) << iIn;
Definition at line 196 of file proxy_o_stream.h.
Lock lass::io::ProxyOStream::operator<< | ( | std::ostream &(*)(std::ostream &) | iIn | ) | [inline] |
Lock 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) << iIn;
Definition at line 207 of file proxy_o_stream.h.
void lass::io::ProxyOStream::flush | ( | ) |
flush all destination streams.
Definition at line 156 of file proxy_o_stream.cpp.
References destinations_.
friend class Lock [friend] |
const TMask lass::io::ProxyOStream::acceptAll = static_cast<TMask>(-1) [static] |
Definition at line 99 of file proxy_o_stream.h.
Definition at line 222 of file proxy_o_stream.h.
Referenced by add(), filter(), flush(), remove(), and setFilter().
Generated on Mon Nov 10 14:22:09 2008 for Library of Assembled Shared Sources by 1.5.7.1 |