65 add(destination, destinationMask);
77 TDestinations::iterator i = findStream(destination);
78 if (i != destinations_.end())
80 i->mask = destinationMask;
84 Destination dest = { destination, destinationMask };
85 destinations_.push_back(dest);
98 TDestinations::iterator i = findStream(destination);
99 if (i == destinations_.end())
103 destinations_.erase(i);
113 for (TDestinations::const_iterator i = destinations_.begin(), end = destinations_.end(); i != end; ++i)
115 if (i->stream == destination)
120 LASS_THROW(
"Cannot return filter because std::ostream '" << destination <<
"' is not "
121 <<
"connected to the ProxyOStream '" <<
this <<
"' as destination.");
131 TDestinations::iterator i = findStream(destination);
132 if (i == destinations_.end())
134 LASS_THROW(
"Cannot set filter because std::ostream '" << destination <<
"' is not "
135 <<
"connected to the ProxyOStream '" <<
this <<
"' as destination.");
137 i->mask = destinationMask;
141impl::ProxyOStreamLock ProxyOStream::operator()( TMask messageMask )
143 impl::ProxyOStreamLock lock(
this, messageMask);
154 impl::ProxyOStreamLock result(
this, acceptAll);
164 for (TDestinations::iterator i = destinations_.begin(), end = destinations_.end(); i != end; ++i)
171ProxyOStream::TDestinations::iterator ProxyOStream::findStream(std::ostream* stream)
177 for (TDestinations::iterator i = destinations_.begin(), end = destinations_.end(); i != end; ++i)
179 if (i->stream == stream)
184 return destinations_.end();
195ProxyOStreamLock::ProxyOStreamLock(ProxyOStream* proxy, ProxyOStream::TMask messageMask):
197 messageMask_(messageMask)
201 proxy_->lock_.lock();
207ProxyOStreamLock::ProxyOStreamLock(ProxyOStreamLock&& other):
208 proxy_(other.proxy_),
209 messageMask_(other.messageMask_)
212 other.messageMask_ = 0;
222ProxyOStreamLock::~ProxyOStreamLock()
227 proxy_->lock_.unlock();
235ProxyOStreamLock& ProxyOStreamLock::operator<<(std::ostream& (*x) (std::ostream&))
239 for (ProxyOStream::TDestinations::iterator i = proxy_->destinations_.begin(), end = proxy_->destinations_.end(); i != end; ++i)
243 LASS_ENFORCE_STREAM(*(i->stream)) << x;
void add(std::ostream *destination, TMask filterMask=acceptAll)
Add a std::ostream to the list of destination streams.
TMask filter(std::ostream *destination) const
Return accept mask on destination stream.
void flush()
flush all destination streams.
void setFilter(std::ostream *destination, TMask filterMask)
Set filter on destination stream.
ProxyOStream(std::ostream *destination=&std::cout, TMask filterMask=acceptAll)
Construct a proxy with a destination, and set a filter for it.
void remove(std::ostream *destination)
Remove a std::ostream from the list of destination streams.
impl::ProxyOStreamLock operator<<(const T &x)
ProxyOStreamLock proxy stream for output on 'acceptAll' and distribute input.
bool checkMaskedSome(T a_bits, const T &a_mask)
Check the masked bits and return true if at least one is set.
streams, binary streams, vrmlstreams, ...
Library for Assembled Shared Sources.