Last change
on this file was
7623,
checked in by westram, 13 years ago
|
- merge from dev [7450] [7452] [7456] [7457] [7458] [7459] [7460] [7461] [7464] [7465] [7466] [7467] [7468] [7469] [7482]
- tweaked compiler options
- activated -Weffc++
- postfilter warnings where Scott Meyers' advices are too general.
- base classes should not always have virtual destructors, since that renders tiny classes useless and
- members should not always be initialized via initialization list, since that often violates the DRY principle
- fix gcc's inability to detect that Noncopyable implements a private copy-ctor and op=
- this slows down complete ARB recompilation by ~5%
- added -Wold-style-cast (inactive)
- removed -Wno-non-template-friend added in [7447]
- postcompile.pl
- added option —original to show unmodified compiler output
- declared op= for classes which had a copy-ctor
- moved op= macros to arbtools.h
- derived classes containing pointers from Noncopyable (use Noncopyable virtually) or
- made them copyable if needed (awt_mask_item, KnownDB, Code, AWT_registered_itemtype, GEN_gene, PosGene, PartialSequence, PlugIn, Range, Convaln_exception)
- other related changes
- mask destruction working now
|
File size:
1.7 KB
|
Line | |
---|
1 | // ================================================================ // |
---|
2 | // // |
---|
3 | // File : SuppressOutput.h // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Coded by Ralf Westram (coder@reallysoft.de) in November 2010 // |
---|
7 | // Institute of Microbiology (Technical University Munich) // |
---|
8 | // http://www.arb-home.de/ // |
---|
9 | // // |
---|
10 | // ================================================================ // |
---|
11 | |
---|
12 | #ifndef SUPPRESSOUTPUT_H |
---|
13 | #define SUPPRESSOUTPUT_H |
---|
14 | |
---|
15 | #ifndef _GLIBCXX_CSTDIO |
---|
16 | #include <cstdio> |
---|
17 | #endif |
---|
18 | #ifndef ARBTOOLS_H |
---|
19 | #include "arbtools.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | |
---|
23 | class SuppressOutput : virtual Noncopyable { |
---|
24 | // temporarily redirect stdout and stderr to /dev/null |
---|
25 | FILE *devnull; |
---|
26 | FILE *org_stdout; |
---|
27 | FILE *org_stderr; |
---|
28 | |
---|
29 | void flush() { |
---|
30 | fflush(stdout); |
---|
31 | fflush(stderr); |
---|
32 | } |
---|
33 | |
---|
34 | public: |
---|
35 | void suppress() { |
---|
36 | if (stdout != devnull) { |
---|
37 | flush(); |
---|
38 | stdout = devnull; |
---|
39 | stderr = devnull; |
---|
40 | } |
---|
41 | } |
---|
42 | void dont_suppress() { |
---|
43 | if (stdout == devnull) { |
---|
44 | flush(); |
---|
45 | stdout = org_stdout; |
---|
46 | stderr = org_stderr; |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | SuppressOutput() |
---|
51 | : devnull(fopen("/dev/null", "w")) |
---|
52 | , org_stdout(stdout) |
---|
53 | , org_stderr(stderr) |
---|
54 | { |
---|
55 | suppress(); |
---|
56 | } |
---|
57 | ~SuppressOutput() { |
---|
58 | dont_suppress(); |
---|
59 | fclose(devnull); |
---|
60 | } |
---|
61 | }; |
---|
62 | |
---|
63 | #else |
---|
64 | #error SuppressOutput.h included twice |
---|
65 | #endif // SUPPRESSOUTPUT_H |
---|
Note: See
TracBrowser
for help on using the repository browser.