1/* Copyright (C) 2010 The giomm Development Team 2 * 3 * This library is free software; you can redistribute it and/or 4 * modify it under the terms of the GNU Lesser General Public 5 * License as published by the Free Software Foundation; either 6 * version 2.1 of the License, or (at your option) any later version. 7 * 8 * This library is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public 14 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 17_CONFIGINCLUDE(giommconfig.h) 18 19#include <glibmm/object.h> 20#include <glibmm/arrayhandle.h> 21 22_DEFS(giomm,gio) 23_PINCLUDE(glibmm/private/object_p.h) 24 25namespace Gio 26{ 27 28/** UnixFDList - An object containing a set of UNIX file descriptors. 29 * A UnixFDList contains a list of file descriptors. It owns the file 30 * descriptors that it contains, closing them when finalized. 31 * 32 * It may be wrapped in a UnixFDMessage and sent over a Socket in the 33 * G_SOCKET_ADDRESS_UNIX family by using Gio::Socket::send() and received 34 * using Gio::Socket::receive(). 35 * 36 * @ingroup NetworkIO 37 * @newin{2,28} 38 */ 39class GIOMM_API UnixFDList : public Glib::Object 40{ 41 _CLASS_GOBJECT(UnixFDList, GUnixFDList, G_UNIX_FD_LIST, Glib::Object, GObject, , , GIOMM_API) 42 _GTKMMPROC_WIN32_NO_WRAP 43 44protected: 45 _CTOR_DEFAULT 46 _IGNORE(g_unix_fd_list_new) 47 48 explicit UnixFDList(const Glib::ArrayHandle<int>& fds); 49 50 explicit UnixFDList(const Glib::ArrayHandle<int>& fds, int n_fds); 51 _IGNORE(g_unix_fd_list_new_from_array) 52 53public: 54 _WRAP_METHOD_DOCS_ONLY(g_unix_fd_list_new) 55 _WRAP_CREATE() 56 57 /** Creates a new UnixFDList containing the file descriptors given in @a 58 * fds. The file descriptors become the property of the new list and may no 59 * longer be used by the caller. The array itself is owned by the caller. 60 * 61 * Each file descriptor in the array should be set to close-on-exec. 62 * @param fds The list of file descriptors to use for creation. 63 * @return A new UnixFDList. 64 */ 65 _WRAP_CREATE(const Glib::ArrayHandle<int>& fds) 66 67 _WRAP_METHOD_DOCS_ONLY(g_unix_fd_list_new_from_array) 68 _WRAP_CREATE(const Glib::ArrayHandle<int>& fds, int n_fds) 69 70 _WRAP_METHOD(int get_length() const, g_unix_fd_list_get_length) 71 _WRAP_METHOD(int get(int index) const, g_unix_fd_list_get, errthrow) 72 73 /** Returns the array of file descriptors that is contained in this object. 74 * 75 * After this call, the descriptors remain the property of the list. The 76 * caller must not close them. The array is valid only until list is changed 77 * in any way. 78 * @return The list of file descriptors. 79 * 80 * @newin{2,28} 81 */ 82 const Glib::ArrayHandle<int> peek_fds() const; 83 _IGNORE(g_unix_fd_list_peek_fds) 84 85 /** Returns the array of file descriptors that is contained in this object. 86 * 87 * After this call, the descriptors are no longer contained in the list. 88 * Further calls will return an empty list (unless more descriptors have 89 * been added). 90 * 91 * The caller is responsible for closing all of the file descriptors. The 92 * file descriptors in the array are set to close-on-exec. 93 * @return The list of file descriptors. 94 * 95 * @newin{2,28} 96 */ 97 Glib::ArrayHandle<int> steal_fds(); 98 _IGNORE(g_unix_fd_list_steal_fds) 99 100 _WRAP_METHOD_DOCS_ONLY(g_unix_fd_list_append) 101 ///@throw Glib::Error. 102 _WRAP_METHOD(int append(int fd), g_unix_fd_list_append, errthrow) 103}; 104 105} // namespace Gio 106