// $Id$ // // Copyright (C) 2006 // Fraunhofer Institute for Open Communication Systems (FOKUS) // // The contents of this file are subject to the Fraunhofer FOKUS Public License // Version 1.0 (the "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // http://senf.berlios.de/license.html // // The Fraunhofer FOKUS Public License Version 1.0 is based on, // but modifies the Mozilla Public License Version 1.1. // See the full license text for the amendments. // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the License. // // The Original Code is Fraunhofer FOKUS code. // // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. // (registered association), Hansastraße 27 c, 80686 Munich, Germany. // All Rights Reserved. // // Contributor(s): // Stefan Bund /** \file \brief FileHandle inline non-template implementation */ //#include "FileHandle.ih" // Custom includes #include #include #define prefix_ inline //-///////////////////////////////////////////////////////////////////////////////////////////////// //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::FileBody prefix_ senf::FileBody::FileBody(int fd) : fd_(fd) {} prefix_ senf::FileHandle senf::FileBody::handle() { return FileHandle(ptr(this)); } prefix_ int senf::FileBody::fd() const { return fd_; } prefix_ void senf::FileBody::fd(int fd) { fd_ = fd; } prefix_ bool senf::FileBody::eof() const { return v_eof(); } prefix_ bool senf::FileBody::valid() const { return fd_!=-1 && v_valid(); } prefix_ bool senf::FileBody::readable() const { return pollCheck(fd(),true,0); } prefix_ bool senf::FileBody::waitReadable(senf::ClockService::clock_type timeout) const { return pollCheck(fd(), true, (timeout==senf::ClockService::clock_type(-1)?-1:senf::ClockService::in_milliseconds(timeout)) ); } prefix_ bool senf::FileBody::writeable() const { return pollCheck(fd(),false,0); } prefix_ bool senf::FileBody::waitWriteable(senf::ClockService::clock_type timeout) const { return pollCheck(fd(), false, (timeout==senf::ClockService::clock_type(-1)?-1:senf::ClockService::in_milliseconds(timeout)) ); } prefix_ bool senf::FileBody::oobReadable() const { return pollCheck(fd(),true,0,true); } prefix_ bool senf::FileBody::waitOOBReadable(senf::ClockService::clock_type timeout) const { return pollCheck(fd(), true, (timeout==senf::ClockService::clock_type(-1)?-1:senf::ClockService::in_milliseconds(timeout)), true); } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::FileHandle prefix_ senf::FileBody & senf::FileHandle::body() { SENF_ASSERT(body_, "dereferencing in-valid() FileHandle"); return *body_; } prefix_ senf::FileBody const & senf::FileHandle::body() const { SENF_ASSERT(body_, "dereferencing in-valid() FileHandle"); return *body_; } prefix_ void senf::FileHandle::close() { body().close(); } prefix_ void senf::FileHandle::terminate() { body().terminate(); } prefix_ bool senf::FileHandle::readable() const { return body().readable(); } prefix_ bool senf::FileHandle::waitReadable(senf::ClockService::clock_type timeout) const { return body().waitReadable(timeout); } prefix_ bool senf::FileHandle::writeable() const { return body().writeable(); } prefix_ bool senf::FileHandle::waitWriteable(senf::ClockService::clock_type timeout) const { return body().waitWriteable(timeout); } prefix_ bool senf::FileHandle::oobReadable() const { return body().oobReadable(); } prefix_ bool senf::FileHandle::waitOOBReadable(senf::ClockService::clock_type timeout) const { return body().waitOOBReadable(timeout); } prefix_ bool senf::FileHandle::blocking() const { return body().blocking(); } prefix_ void senf::FileHandle::blocking(bool status) { body().blocking(status); } prefix_ bool senf::FileHandle::eof() const { return body().eof(); } prefix_ bool senf::FileHandle::valid() const { return body_ && body().valid(); } prefix_ bool senf::FileHandle::boolean_test() const { return valid() && !eof(); } prefix_ int senf::FileHandle::fd() const { return body().fd(); } prefix_ senf::FileHandle::FileHandle() : body_(0) {} prefix_ senf::FileHandle::~FileHandle() { if (body_ && ! body().is_shared()) body().destroyClose(); } prefix_ senf::FileHandle::FileHandle(std::auto_ptr body) : body_(body.release()) {} prefix_ senf::FileHandle::FileHandle(FileBody::ptr body) : body_(body) {} prefix_ senf::FileBody & senf::FileHandle::body(FileHandle & handle) { return handle.body(); } prefix_ senf::FileBody const & senf::FileHandle::body(FileHandle const & handle) { return handle.body(); } prefix_ void senf::FileHandle::fd(int fd) { body().fd(fd); } prefix_ senf::FileHandle senf::FileHandle::cast_static(FileHandle handle) { return handle; } prefix_ senf::FileHandle senf::FileHandle::cast_dynamic(FileHandle handle) { return handle; } prefix_ int senf::retrieve_filehandle(FileHandle handle) { return handle.fd(); } //-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // comment-column: 40 // End: