channel.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2006, 2007 Ciaran McCreesh
00005  * Copyright (c) 2009 David Leverton
00006  *
00007  * This file is part of the Paludis package manager. Paludis is free software;
00008  * you can redistribute it and/or modify it under the terms of the GNU General
00009  * Public License version 2, as published by the Free Software Foundation.
00010  *
00011  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00012  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00014  * details.
00015  *
00016  * You should have received a copy of the GNU General Public License along with
00017  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00018  * Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 #ifndef PALUDIS_GUARD_PALUDIS_UTIL_CHANNEL_HH
00022 #define PALUDIS_GUARD_PALUDIS_UTIL_CHANNEL_HH 1
00023 
00024 #include <paludis/util/instantiation_policy.hh>
00025 
00026 /** \file
00027  * Declaration for the Channel class.
00028  *
00029  * \ingroup g_system
00030  *
00031  * \section Examples
00032  *
00033  * - None at this time.
00034  */
00035 
00036 namespace paludis
00037 {
00038     /**
00039      * Wrapper around a read/write file descriptor pair, such as a pipe.
00040      *
00041      * \ingroup g_system
00042      * \nosubgrouping
00043      */
00044     class PALUDIS_VISIBLE Channel :
00045         InstantiationPolicy<Channel, instantiation_method::NonCopyableTag>
00046     {
00047         protected:
00048             int _fds[2];
00049 
00050         public:
00051             ///\name Basic operations
00052             ///\{
00053 
00054             Channel();
00055 
00056             virtual ~Channel();
00057 
00058             ///\}
00059 
00060             ///\name File descriptors
00061             ///\{
00062 
00063             int read_fd() const PALUDIS_ATTRIBUTE((warn_unused_result))
00064             {
00065                 return _fds[0];
00066             }
00067 
00068             int write_fd() const PALUDIS_ATTRIBUTE((warn_unused_result))
00069             {
00070                 return _fds[1];
00071             }
00072 
00073             void clear_read_fd()
00074             {
00075                 _fds[0] = -1;
00076             }
00077 
00078             void clear_write_fd()
00079             {
00080                 _fds[1] = -1;
00081             }
00082 
00083             ///\}
00084 
00085     };
00086 
00087 }
00088 
00089 #endif

Generated on Mon Sep 21 10:36:08 2009 for paludis by  doxygen 1.5.4