paludis Version 3.0.2
The one true package mangler
ipc_output_manager.hh
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 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_IPC_OUTPUT_MANAGER_HH
21#define PALUDIS_GUARD_PALUDIS_IPC_OUTPUT_MANAGER_HH 1
22
23#include <paludis/ipc_output_manager-fwd.hh>
25#include <paludis/util/pimp.hh>
26#include <paludis/output_manager.hh>
28#include <paludis/create_output_manager_info-fwd.hh>
30#include <paludis/action-fwd.hh>
31#include <memory>
32#include <functional>
33#include <string>
34
35namespace paludis
36{
37 class PALUDIS_VISIBLE IPCOutputManager :
38 public OutputManager
39 {
40 private:
42
43 public:
44 IPCOutputManager(
45 const int pipe_read_fd,
46 const int pipe_write_fd,
48 ~IPCOutputManager() noexcept(false) override;
49
50 std::ostream & stdout_stream() override PALUDIS_ATTRIBUTE((warn_unused_result));
51 std::ostream & stderr_stream() override PALUDIS_ATTRIBUTE((warn_unused_result));
52
53 void succeeded() override;
54 void ignore_succeeded() override;
55 void flush() override;
56 bool want_to_flush() const override;
57 void nothing_more_to_come() override;
58 void message(const MessageType, const std::string &) override;
59 };
60
61 class PALUDIS_VISIBLE IPCInputManager
62 {
63 private:
65
66 std::string _pipe_command_handler(const std::string &);
67 void _copy_thread();
68
69 public:
70 IPCInputManager(
71 const Environment * const,
72 const std::function<void (const std::shared_ptr<OutputManager> &)> &);
73
74 ~IPCInputManager() noexcept(false);
75
76 const std::function<std::string (const std::string &)> pipe_command_handler()
77 PALUDIS_ATTRIBUTE((warn_unused_result));
78
79 /**
80 * The underlying output manager.
81 *
82 * The underlying output manager is not constructed until the child
83 * process requests it, so a null pointer may be returned.
84 *
85 * Normally the output manager is destroyed when the
86 * IPCInputManager is destroyed, but keeping the shared pointer
87 * this method returns around for longer will also work, if, for
88 * example, any 'finished' messages are to be displayed later on.
89 */
90 const std::shared_ptr<OutputManager> underlying_output_manager_if_constructed() const
91 PALUDIS_ATTRIBUTE((warn_unused_result));
92 };
93
94 class PALUDIS_VISIBLE OutputManagerFromIPC
95 {
96 private:
98
99 public:
100 OutputManagerFromIPC(
101 const Environment * const,
102 const std::shared_ptr<const PackageID> &,
103 const OutputExclusivity,
104 const ClientOutputFeatures &
105 );
106
107 ~OutputManagerFromIPC() noexcept(false);
108
109 const std::shared_ptr<OutputManager> operator() (const Action &);
110
111 const std::shared_ptr<OutputManager> output_manager_if_constructed();
112
113 void construct_standard_if_unconstructed();
114 };
115
116 extern template class Pimp<IPCOutputManager>;
117 extern template class Pimp<IPCInputManager>;
118 extern template class Pimp<OutputManagerFromIPC>;
119
120}
121
122#endif
Definition action.hh:278
Definition create_output_manager_info.hh:48
Definition environment.hh:203
const std::shared_ptr< OutputManager > underlying_output_manager_if_constructed() const PALUDIS_ATTRIBUTE((warn_unused_result))
void message(const MessageType, const std::string &) override
void ignore_succeeded() override
bool want_to_flush() const override
void succeeded() override
void nothing_more_to_come() override
Definition pimp.hh:52
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24