paludis Version 3.0.2
The one true package mangler
channel.hh
Go to the documentation of this file.
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2006, 2007, 2010 Ciaran McCreesh
5 * Copyright (c) 2009 David Leverton
6 *
7 * This file is part of the Paludis package manager. Paludis is free software;
8 * you can redistribute it and/or modify it under the terms of the GNU General
9 * Public License version 2, as published by the Free Software Foundation.
10 *
11 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18 * Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef PALUDIS_GUARD_PALUDIS_UTIL_CHANNEL_HH
22#define PALUDIS_GUARD_PALUDIS_UTIL_CHANNEL_HH 1
23
25
26/** \file
27 * Declaration for the Channel class.
28 *
29 * \ingroup g_system
30 *
31 * \section Examples
32 *
33 * - None at this time.
34 */
35
36namespace paludis
37{
38 /**
39 * Wrapper around a read/write file descriptor pair, such as a pipe.
40 *
41 * \ingroup g_system
42 * \nosubgrouping
43 */
44 class PALUDIS_VISIBLE Channel
45 {
46 protected:
47 int _fds[2];
48
49 public:
50 ///\name Basic operations
51 ///\{
52
53 Channel() = default;
54
55 virtual ~Channel();
56
57 Channel(const Channel &) = delete;
58 Channel & operator= (const Channel &) = delete;
59
60 ///\}
61
62 ///\name File descriptors
63 ///\{
64
65 int read_fd() const PALUDIS_ATTRIBUTE((warn_unused_result))
66 {
67 return _fds[0];
68 }
69
70 int write_fd() const PALUDIS_ATTRIBUTE((warn_unused_result))
71 {
72 return _fds[1];
73 }
74
75 void clear_read_fd()
76 {
77 _fds[0] = -1;
78 }
79
80 void clear_write_fd()
81 {
82 _fds[1] = -1;
83 }
84
85 ///\}
86
87 };
88
89}
90
91#endif
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24