paludis  Version 2.6.0
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 
35 namespace paludis
36 {
38  public OutputManager
39  {
40  private:
42 
43  public:
45  const int pipe_read_fd,
46  const int pipe_write_fd,
47  const CreateOutputManagerInfo &);
49 
50  virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
51  virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
52 
53  virtual void succeeded();
54  virtual void ignore_succeeded();
55  virtual void flush();
56  virtual bool want_to_flush() const;
57  virtual void nothing_more_to_come();
58  virtual void message(const MessageType, const std::string &);
59  };
60 
62  {
63  private:
65 
66  std::string _pipe_command_handler(const std::string &);
67  void _copy_thread();
68 
69  public:
71  const Environment * const,
72  const std::function<void (const std::shared_ptr<OutputManager> &)> &);
73 
74  ~IPCInputManager();
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 
95  {
96  private:
98 
99  public:
101  const Environment * const,
102  const std::shared_ptr<const PackageID> &,
103  const OutputExclusivity,
104  const ClientOutputFeatures &
105  );
106 
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: pimp.hh:51
Definition: about_metadata-fwd.hh:23
Definition: ipc_output_manager.hh:37
Definition: ipc_output_manager.hh:94
Definition: output_manager.hh:29
Definition: ipc_output_manager.hh:61
OutputExclusivity
Definition: create_output_manager_info-fwd.hh:14
Definition: environment.hh:200
Definition: action.hh:268
Definition: options-fwd.hh:34
MessageType
Definition: output_manager-fwd.hh:13
Definition: create_output_manager_info.hh:43
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59