cisst-saw
Loading...
Searching...
No Matches
cmnMultiplexerStreambufProxy.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5
6 Author(s): Ofri Sadowsky
7 Created on: 2002-05-20
8
9 (C) Copyright 2002-2007 Johns Hopkins University (JHU), All Rights
10 Reserved.
11
12--- begin cisst license - do not edit ---
13
14This software is provided "as is" under an open source license, with
15no warranty. The complete license can be found in license.txt and
16http://www.cisst.org/cisst/license.txt.
17
18--- end cisst license ---
19
20*/
21
22
26#pragma once
27
28#ifndef _cmnMultiplexerStreambufProxy_h
29#define _cmnMultiplexerStreambufProxy_h
30
33
34#include <list>
35#include <algorithm>
36
86template<class _element, class _trait>
87class cmnMultiplexerStreambufProxy : public std::basic_streambuf<_element, _trait>
88{
89private:
92 cmnMultiplexerStreambufProxy(const cmnMultiplexerStreambufProxy<_element, _trait> & other);
93
94 public:
95
97 typedef typename std::basic_streambuf<_element, _trait>::int_type int_type;
98
101 : OutputChannel(output), LogLevel(level)
102 {}
103
105 cmnLogLevel GetLOD(void) const {
106 return LogLevel;
107 }
108
110 void SetLOD(cmnLogLevel level) {
111 LogLevel = level;
112 }
113
115 ChannelType * GetOutput(void) const {
116 return OutputChannel;
117 }
118
119 // Here we override the basic_streambuf methods for multiplexing.
120 // This part is declared 'protected' following the declarations of
121 // basic_streambuf. See basic_streambuf documentation for more
122 // details.
123 protected:
124
126 virtual std::streamsize xsputn(const _element * s, std::streamsize n);
127
129 virtual int sync(void);
130
135 virtual int_type overflow(int_type c = _trait::eof());
136
137
138 private:
139 ChannelType * OutputChannel;
140 cmnLogLevel LogLevel;
141
142};
143
144
145//********************************
146// Template method implementation
147//********************************
148
149
151template <class _element, class _trait>
152std::streamsize cmnMultiplexerStreambufProxy<_element, _trait>::xsputn(const _element *s, std::streamsize n)
153{
154 return OutputChannel->xsputn(s, n, LogLevel);
155}
156
157
159template <class _element, class _trait>
161{
162 return OutputChannel->sync();
163}
164
165
170template<class _element, class _trait>
173{
174 return OutputChannel->overflow(c, LogLevel);
175}
176
177
178#endif // _cmnMultiplexerStreambufProxy_h
A Streambuffer class that allows output to multiple streambuf objects for Level of Detail information...
Definition cmnLODMultiplexerStreambuf.h:109
virtual int_type overflow(int_type c=_trait::eof())
Definition cmnMultiplexerStreambufProxy.h:172
cmnMultiplexerStreambufProxy(ChannelType *output, cmnLogLevel level)
Definition cmnMultiplexerStreambufProxy.h:100
virtual std::streamsize xsputn(const _element *s, std::streamsize n)
Definition cmnMultiplexerStreambufProxy.h:152
virtual int sync(void)
Definition cmnMultiplexerStreambufProxy.h:160
cmnLogLevel GetLOD(void) const
Definition cmnMultiplexerStreambufProxy.h:105
ChannelType * GetOutput(void) const
Definition cmnMultiplexerStreambufProxy.h:115
std::basic_streambuf< _element, _trait >::int_type int_type
Definition cmnMultiplexerStreambufProxy.h:97
cmnLODMultiplexerStreambuf< _element, _trait > ChannelType
Definition cmnMultiplexerStreambufProxy.h:96
void SetLOD(cmnLogLevel level)
Definition cmnMultiplexerStreambufProxy.h:110
Type Definitions for dynamic control of output messages.
short cmnLogLevel
Definition cmnLogLoD.h:55
Portability across compilers and operating systems tools.