Panda3D
panda
src
downloader
multiplexStreamBuf.h
Go to the documentation of this file.
1
/**
2
* PANDA 3D SOFTWARE
3
* Copyright (c) Carnegie Mellon University. All rights reserved.
4
*
5
* All use of this software is subject to the terms of the revised BSD
6
* license. You should have received a copy of this license along
7
* with this source code in a file named "LICENSE."
8
*
9
* @file multiplexStreamBuf.h
10
* @author drose
11
* @date 2000-11-27
12
*/
13
14
#ifndef MULTIPLEXSTREAMBUF_H
15
#define MULTIPLEXSTREAMBUF_H
16
17
#include "
pandabase.h
"
18
19
#include "
pvector.h
"
20
#include "
mutexImpl.h
"
21
#include <stdio.h>
22
23
/**
24
* Used by MultiplexStream to implement an ostream that sends what is written
25
* to it to any number of additional sources, like other ostreams.
26
*/
27
class
EXPCL_PANDA_DOWNLOADER
MultiplexStreamBuf
:
public
std::streambuf {
28
public
:
29
MultiplexStreamBuf
();
30
virtual
~
MultiplexStreamBuf
();
31
32
enum
BufferType {
33
BT_none,
34
BT_line,
35
};
36
37
enum
OutputType {
38
OT_ostream,
39
OT_stdio,
40
OT_system_debug,
41
};
42
43
void
add_output(BufferType buffer_type, OutputType output_type,
44
std::ostream *out =
nullptr
,
45
FILE *fout =
nullptr
,
46
bool
owns_obj =
false
);
47
48
void
flush();
49
50
protected
:
51
virtual
int
overflow(
int
c);
52
virtual
int
sync();
53
54
private
:
55
void
write_chars(
const
char
*start,
int
length,
bool
flush);
56
57
58
class
Output {
59
public
:
60
void
close();
61
void
write_string(
const
std::string &str);
62
63
BufferType _buffer_type;
64
OutputType _output_type;
65
std::ostream *_out;
66
FILE *_fout;
67
bool
_owns_obj;
68
};
69
70
typedef
pvector<Output>
Outputs
;
71
Outputs
_outputs;
72
73
MutexImpl
_lock;
74
std::string _line_buffer;
75
};
76
77
#include "
multiplexStreamBuf.I
"
78
79
#endif
pvector< Output >
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
MultiplexStreamBuf
Used by MultiplexStream to implement an ostream that sends what is written to it to any number of add...
Definition:
multiplexStreamBuf.h:27
mutexImpl.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
MutexDummyImpl
A fake mutex implementation for single-threaded applications that don't need any synchronization cont...
Definition:
mutexDummyImpl.h:24
multiplexStreamBuf.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Generated on Mon Sep 14 2020 15:06:48 for Panda3D by
1.8.20