paludis Version 3.0.2
The one true package mangler
output_manager.hh
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
5 *
6 * This file is part of the Paludis package manager. Paludis is free software;
7 * you can redistribute it and/or modify it under the terms of the GNU General
8 * Public License version 2, as published by the Free Software Foundation.
9 *
10 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef PALUDIS_GUARD_PALUDIS_OUTPUT_MANAGER_HH
21#define PALUDIS_GUARD_PALUDIS_OUTPUT_MANAGER_HH 1
22
23#include <paludis/output_manager-fwd.hh>
25#include <iosfwd>
26
27namespace paludis
28{
29 class PALUDIS_VISIBLE OutputManager
30 {
31 public:
32 OutputManager() = default;
33 virtual ~OutputManager() noexcept(false) = 0;
34
35 OutputManager(const OutputManager &) = delete;
36 OutputManager & operator= (const OutputManager &) = delete;
37
38 virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
39 virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
40
41 /**
42 * An out of band message that might want to be logged or handled
43 * in a special way.
44 *
45 * The caller must still also display the message to
46 * stdout_stream() as appropriate.
47 */
48 virtual void message(const MessageType, const std::string &) = 0;
49
50 /**
51 * Clients may call this method every few seconds when running
52 * multiple processes.
53 *
54 * This is used to display ongoing buffered messages without mixing
55 * output from multiple processes.
56 */
57 virtual void flush() = 0;
58
59 /**
60 * Do we want to flush?
61 *
62 * Provides a way for clients to avoid having to call flush() with
63 * a prefixed header when there's no output waiting.
64 */
65 virtual bool want_to_flush() const = 0;
66
67 /**
68 * Called if an action succeeds. This can be used to, for example,
69 * unlink the files behind a to-disk logged output manager.
70 *
71 * If an OutputManager is destroyed without having had this method
72 * called, it should assume failure. This might mean keeping rather
73 * than removing log files, for example.
74 *
75 * Further messages and output may occur even after a call to this
76 * method.
77 *
78 * Calls to this method are done by the caller, not by whatever
79 * carries out the action in question.
80 *
81 * If ignore_succeeded() has previously been called, does nothing.
82 */
83 virtual void succeeded() = 0;
84
85 /**
86 * Instructs the output manager to ignore future calls to
87 * succeeded().
88 *
89 * Typically this is used to force log files to be kept even if
90 * an error has occurred, if the error does not trigger the usual
91 * failure mechanisms.
92 *
93 * \since 0.59
94 */
95 virtual void ignore_succeeded() = 0;
96
97 /**
98 * May be called to indicate that no further output or messages
99 * will occur, allowing for files to be closed off etc.
100 *
101 * Summary messages are shown when the output manager is
102 * destructed, not when this method is called.
103 *
104 * If this method and succeeded are both to be called, succeeded
105 * must be called first.
106 */
107 virtual void nothing_more_to_come() = 0;
108 };
109}
110
111#endif
virtual void succeeded()=0
virtual void message(const MessageType, const std::string &)=0
virtual bool want_to_flush() const =0
virtual void nothing_more_to_come()=0
virtual void flush()=0
virtual void ignore_succeeded()=0
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24