4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.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"
31 #include "../Utils/Exception.hh"
33 #define prefix_ inline
34 ///////////////////////////////cci.p///////////////////////////////////////
36 ///////////////////////////////////////////////////////////////////////////
39 prefix_ senf::FileBody::FileBody(int fd)
43 prefix_ senf::FileBody::~FileBody()
54 prefix_ void senf::FileBody::close()
62 prefix_ void senf::FileBody::terminate()
70 prefix_ senf::FileHandle senf::FileBody::handle()
72 return FileHandle(ptr(this));
75 prefix_ int senf::FileBody::fd()
81 prefix_ void senf::FileBody::fd(int fd)
86 prefix_ bool senf::FileBody::eof()
92 prefix_ bool senf::FileBody::valid()
95 return fd_!=-1 && v_valid();
98 prefix_ bool senf::FileBody::readable()
101 return pollCheck(fd(),true);
104 prefix_ void senf::FileBody::waitReadable()
107 pollCheck(fd(),true,true);
110 prefix_ bool senf::FileBody::writeable()
113 return pollCheck(fd(),false);
116 prefix_ void senf::FileBody::waitWriteable()
119 pollCheck(fd(),false,true);
122 ///////////////////////////////////////////////////////////////////////////
125 prefix_ void senf::FileHandle::close()
130 prefix_ void senf::FileHandle::terminate()
135 prefix_ bool senf::FileHandle::readable()
138 return body().readable();
141 prefix_ void senf::FileHandle::waitReadable()
144 body().waitReadable();
147 prefix_ bool senf::FileHandle::writeable()
150 return body().writeable();
153 prefix_ void senf::FileHandle::waitWriteable()
156 body().waitWriteable();
159 prefix_ bool senf::FileHandle::blocking()
162 return body().blocking();
165 prefix_ void senf::FileHandle::blocking(bool status)
167 body().blocking(status);
170 prefix_ bool senf::FileHandle::eof()
176 prefix_ bool senf::FileHandle::valid()
179 return body_ && body().valid();
182 prefix_ bool senf::FileHandle::boolean_test()
185 return valid() && !eof();
188 prefix_ int senf::FileHandle::fd()
194 prefix_ senf::FileHandle::FileHandle()
198 prefix_ senf::FileHandle::FileHandle(std::auto_ptr<FileBody> body)
199 : body_(body.release())
202 prefix_ senf::FileHandle::FileHandle(FileBody::ptr body)
206 prefix_ senf::FileBody & senf::FileHandle::body()
212 prefix_ senf::FileBody const & senf::FileHandle::body()
219 prefix_ senf::FileBody & senf::FileHandle::body(FileHandle & handle)
221 return handle.body();
224 prefix_ senf::FileBody const &
225 senf::FileHandle::body(FileHandle const & handle)
227 return handle.body();
230 prefix_ void senf::FileHandle::fd(int fd)
235 prefix_ senf::FileHandle::FileHandle
236 senf::FileHandle::cast_static(FileHandle handle)
241 prefix_ senf::FileHandle
242 senf::FileHandle::cast_dynamic(FileHandle handle)
247 prefix_ int senf::retrieve_filehandle(FileHandle handle)
252 ///////////////////////////////cci.e///////////////////////////////////////
259 // c-file-style: "senf"
260 // indent-tabs-mode: nil
261 // ispell-local-dictionary: "american"
262 // compile-command: "scons -u test"
263 // comment-column: 40