Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Directories
  • File List
  • File Members

FileHandle.hh

Go to the documentation of this file.
00001 // $Id: FileHandle.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2006
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00057 #ifndef HH_SENF_Socket_FileHandle_
00058 #define HH_SENF_Socket_FileHandle_ 1
00059 
00060 // Custom includes
00061 #include <memory> // std::auto_ptr
00062 #include <senf/Utils/safe_bool.hh>
00063 #include <senf/Scheduler/ClockService.hh>
00064 
00065 //#include "FileHandle.mpp"
00066 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00067 #include "FileHandle.ih"
00068 
00069 namespace senf {
00070 
00072     //\{
00073 
00103     class FileHandle
00104         : public safe_bool<FileHandle>
00105     {
00106     public:
00107         //-////////////////////////////////////////////////////////////////////////
00108         // Types
00109 
00110         //-////////////////////////////////////////////////////////////////////////
00112         //\{
00113 
00114         FileHandle();
00115         ~FileHandle();
00116 
00117         // my default constructor
00118         // default copy constructor
00119         // default copy assignment
00120         // default destructor
00121 
00122         // no conversion constructors
00123 
00124         //\}
00125         //-////////////////////////////////////////////////////////////////////////
00126 
00127         void close();                
00128 
00129         void terminate();            
00130 
00131         bool readable() const;       
00132 
00133         bool waitReadable(senf::ClockService::clock_type timeout = -1) const;
00136 
00140         bool writeable() const;      
00141 
00142         bool waitWriteable(senf::ClockService::clock_type timeout = -1) const;
00145 
00149         bool oobReadable() const;    
00150 
00151         bool waitOOBReadable(senf::ClockService::clock_type timeout = -1) const;
00154 
00159         bool blocking() const;       
00160         void blocking(bool status);  
00161 
00162         bool eof() const;            
00163 
00171         bool valid() const;          
00172 
00175         bool boolean_test() const;  
00176 
00181         int fd() const;             
00182 
00183         static FileHandle cast_static(FileHandle handle);  
00184         static FileHandle cast_dynamic(FileHandle handle); 
00186     protected:
00187         explicit FileHandle(std::auto_ptr<FileBody> body);
00189 
00194         explicit FileHandle(FileBody::ptr body);
00195 
00196         FileBody & body();          
00197         FileBody const & body() const; 
00198         static FileBody & body(FileHandle & handle); 
00199         static FileBody const & body(FileHandle const & handle); 
00200 
00201 
00202         void fd(int fd);            
00203 
00204     private:
00205         FileBody::ptr body_;
00206 
00207         friend class FileBody;
00208     };
00209 
00218     int retrieve_filehandle(FileHandle handle);
00219 
00220     //\}
00221 
00222 }
00223 
00224 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00225 #include "FileHandle.cci"
00226 //#include "FileHandle.ct"
00227 //#include "FileHandle.cti"
00228 #endif
00229 
00230 
00231 // Local Variables:
00232 // mode: c++
00233 // fill-column: 100
00234 // c-file-style: "senf"
00235 // indent-tabs-mode: nil
00236 // ispell-local-dictionary: "american"
00237 // compile-command: "scons -u test"
00238 // comment-column: 40
00239 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research