// $Id$ // // Copyright (C) 2006 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Definition of inline non-template functions //#include "FileHandle.ih" // Custom includes #include #include "Utils/Exception.hh" #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // satcom::lib::FileBody prefix_ satcom::lib::FileBody::FileBody(int fd) : fd_(fd) {} prefix_ satcom::lib::FileBody::~FileBody() { if (valid()) try { close(); } catch (...) { terminate(); } } prefix_ void satcom::lib::FileBody::close() { if (!valid()) throw SystemException(EBADF); v_close(); fd_ = -1; } prefix_ void satcom::lib::FileBody::terminate() { if (valid()) { v_terminate(); fd_ = -1; } } prefix_ int satcom::lib::FileBody::fd() const { return fd_; } prefix_ void satcom::lib::FileBody::fd(int fd) { fd_ = fd; } prefix_ bool satcom::lib::FileBody::eof() const { return v_eof(); } prefix_ bool satcom::lib::FileBody::valid() const { return fd_!=-1 && v_valid(); } prefix_ bool satcom::lib::FileBody::readable() const { return pollCheck(fd(),true); } prefix_ void satcom::lib::FileBody::waitReadable() const { pollCheck(fd(),true,true); } prefix_ bool satcom::lib::FileBody::writeable() const { return pollCheck(fd(),false); } prefix_ void satcom::lib::FileBody::waitWriteable() const { pollCheck(fd(),false,true); } /////////////////////////////////////////////////////////////////////////// // satcom::lib::FileHandle prefix_ void satcom::lib::FileHandle::close() { body().close(); } prefix_ void satcom::lib::FileHandle::terminate() { body().terminate(); } prefix_ bool satcom::lib::FileHandle::readable() const { return body().readable(); } prefix_ void satcom::lib::FileHandle::waitReadable() const { body().waitReadable(); } prefix_ bool satcom::lib::FileHandle::writeable() const { return body().writeable(); } prefix_ void satcom::lib::FileHandle::waitWriteable() const { body().waitWriteable(); } prefix_ bool satcom::lib::FileHandle::blocking() const { return body().blocking(); } prefix_ void satcom::lib::FileHandle::blocking(bool status) { body().blocking(status); } prefix_ bool satcom::lib::FileHandle::eof() const { return body().eof(); } prefix_ bool satcom::lib::FileHandle::valid() const { return body().valid(); } prefix_ satcom::lib::FileHandle::operator bool () const { return valid() && !eof(); } prefix_ bool satcom::lib::FileHandle::operator!() const { return ! (valid() && !eof()); } prefix_ int satcom::lib::FileHandle::fd() const { return body().fd(); } prefix_ satcom::lib::FileHandle::FileHandle(std::auto_ptr body) : body_(body.release()) {} prefix_ satcom::lib::FileBody & satcom::lib::FileHandle::body() { return *body_; } prefix_ satcom::lib::FileBody const & satcom::lib::FileHandle::body() const { return *body_; } prefix_ satcom::lib::FileBody & satcom::lib::FileHandle::body(FileHandle & handle) { return handle.body(); } prefix_ satcom::lib::FileBody const & satcom::lib::FileHandle::body(FileHandle const & handle) { return handle.body(); } prefix_ void satcom::lib::FileHandle::fd(int fd) { body().fd(fd); } prefix_ satcom::lib::FileHandle::FileHandle satcom::lib::FileHandle::cast_static(FileHandle handle) { return handle; } prefix_ satcom::lib::FileHandle satcom::lib::FileHandle::cast_dynamic(FileHandle handle) { return handle; } ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // c-file-style: "satcom" // End: