4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief FileHandle inline non-template implementation
27 //#include "FileHandle.ih"
30 #include "../Utils/senfassert.hh"
32 #include "../Utils/Exception.hh"
34 #define prefix_ inline
35 ///////////////////////////////cci.p///////////////////////////////////////
37 ///////////////////////////////////////////////////////////////////////////
40 prefix_ senf::FileBody::FileBody(int fd)
44 prefix_ senf::FileHandle senf::FileBody::handle()
46 return FileHandle(ptr(this));
49 prefix_ int senf::FileBody::fd()
55 prefix_ void senf::FileBody::fd(int fd)
60 prefix_ bool senf::FileBody::eof()
66 prefix_ bool senf::FileBody::valid()
69 return fd_!=-1 && v_valid();
72 prefix_ bool senf::FileBody::readable()
75 return pollCheck(fd(),true);
78 prefix_ void senf::FileBody::waitReadable()
81 pollCheck(fd(),true,true);
84 prefix_ bool senf::FileBody::writeable()
87 return pollCheck(fd(),false);
90 prefix_ void senf::FileBody::waitWriteable()
93 pollCheck(fd(),false,true);
96 ///////////////////////////////////////////////////////////////////////////
99 prefix_ senf::FileBody & senf::FileHandle::body()
105 prefix_ senf::FileBody const & senf::FileHandle::body()
112 prefix_ void senf::FileHandle::close()
117 prefix_ void senf::FileHandle::terminate()
122 prefix_ bool senf::FileHandle::readable()
125 return body().readable();
128 prefix_ void senf::FileHandle::waitReadable()
131 body().waitReadable();
134 prefix_ bool senf::FileHandle::writeable()
137 return body().writeable();
140 prefix_ void senf::FileHandle::waitWriteable()
143 body().waitWriteable();
146 prefix_ bool senf::FileHandle::blocking()
149 return body().blocking();
152 prefix_ void senf::FileHandle::blocking(bool status)
154 body().blocking(status);
157 prefix_ bool senf::FileHandle::eof()
163 prefix_ bool senf::FileHandle::valid()
166 return body_ && body().valid();
169 prefix_ bool senf::FileHandle::boolean_test()
172 return valid() && !eof();
175 prefix_ int senf::FileHandle::fd()
181 prefix_ senf::FileHandle::FileHandle()
185 prefix_ senf::FileHandle::~FileHandle()
187 if (body_ && ! body().is_shared())
188 body().destroyClose();
191 prefix_ senf::FileHandle::FileHandle(std::auto_ptr<FileBody> body)
192 : body_(body.release())
195 prefix_ senf::FileHandle::FileHandle(FileBody::ptr body)
199 prefix_ senf::FileBody & senf::FileHandle::body(FileHandle & handle)
201 return handle.body();
204 prefix_ senf::FileBody const &
205 senf::FileHandle::body(FileHandle const & handle)
207 return handle.body();
210 prefix_ void senf::FileHandle::fd(int fd)
215 prefix_ senf::FileHandle::FileHandle
216 senf::FileHandle::cast_static(FileHandle handle)
221 prefix_ senf::FileHandle
222 senf::FileHandle::cast_dynamic(FileHandle handle)
227 prefix_ int senf::retrieve_filehandle(FileHandle handle)
232 ///////////////////////////////cci.e///////////////////////////////////////
239 // c-file-style: "senf"
240 // indent-tabs-mode: nil
241 // ispell-local-dictionary: "american"
242 // compile-command: "scons -u test"
243 // comment-column: 40