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::FileBody::~FileBody()
55 prefix_ void senf::FileBody::close()
63 prefix_ void senf::FileBody::terminate()
71 prefix_ senf::FileHandle senf::FileBody::handle()
73 return FileHandle(ptr(this));
76 prefix_ int senf::FileBody::fd()
82 prefix_ void senf::FileBody::fd(int fd)
87 prefix_ bool senf::FileBody::eof()
93 prefix_ bool senf::FileBody::valid()
96 return fd_!=-1 && v_valid();
99 prefix_ bool senf::FileBody::readable()
102 return pollCheck(fd(),true);
105 prefix_ void senf::FileBody::waitReadable()
108 pollCheck(fd(),true,true);
111 prefix_ bool senf::FileBody::writeable()
114 return pollCheck(fd(),false);
117 prefix_ void senf::FileBody::waitWriteable()
120 pollCheck(fd(),false,true);
123 ///////////////////////////////////////////////////////////////////////////
126 prefix_ void senf::FileHandle::close()
131 prefix_ void senf::FileHandle::terminate()
136 prefix_ bool senf::FileHandle::readable()
139 return body().readable();
142 prefix_ void senf::FileHandle::waitReadable()
145 body().waitReadable();
148 prefix_ bool senf::FileHandle::writeable()
151 return body().writeable();
154 prefix_ void senf::FileHandle::waitWriteable()
157 body().waitWriteable();
160 prefix_ bool senf::FileHandle::blocking()
163 return body().blocking();
166 prefix_ void senf::FileHandle::blocking(bool status)
168 body().blocking(status);
171 prefix_ bool senf::FileHandle::eof()
177 prefix_ bool senf::FileHandle::valid()
180 return body_ && body().valid();
183 prefix_ bool senf::FileHandle::boolean_test()
186 return valid() && !eof();
189 prefix_ int senf::FileHandle::fd()
195 prefix_ senf::FileHandle::FileHandle()
199 prefix_ senf::FileHandle::FileHandle(std::auto_ptr<FileBody> body)
200 : body_(body.release())
203 prefix_ senf::FileHandle::FileHandle(FileBody::ptr body)
207 prefix_ senf::FileBody & senf::FileHandle::body()
213 prefix_ senf::FileBody const & senf::FileHandle::body()
220 prefix_ senf::FileBody & senf::FileHandle::body(FileHandle & handle)
222 return handle.body();
225 prefix_ senf::FileBody const &
226 senf::FileHandle::body(FileHandle const & handle)
228 return handle.body();
231 prefix_ void senf::FileHandle::fd(int fd)
236 prefix_ senf::FileHandle::FileHandle
237 senf::FileHandle::cast_static(FileHandle handle)
242 prefix_ senf::FileHandle
243 senf::FileHandle::cast_dynamic(FileHandle handle)
248 prefix_ int senf::retrieve_filehandle(FileHandle handle)
253 ///////////////////////////////cci.e///////////////////////////////////////
260 // c-file-style: "senf"
261 // indent-tabs-mode: nil
262 // ispell-local-dictionary: "american"
263 // compile-command: "scons -u test"
264 // comment-column: 40