Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

FileHandle_t.h

Go to the documentation of this file.
00001 /****************** <VPR heading BEGIN do not edit this line> *****************
00002  *
00003  * VR Juggler Portable Runtime
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Patrick Hartling, Kevin Meinert, Carolina Cruz-Neira
00007  *
00008  * -----------------------------------------------------------------
00009  * File:          $RCSfile: FileHandle_t.h,v $
00010  * Date modified: $Date: 2003/11/05 21:13:22 $
00011  * Version:       $Revision: 1.21 $
00012  * -----------------------------------------------------------------
00013  *
00014  ****************** <VPR heading END do not edit this line> ******************/
00015 
00016 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00017  *
00018  * VR Juggler is (C) Copyright 1998-2003 by Iowa State University
00019  *
00020  * Original Authors:
00021  *   Allen Bierbaum, Christopher Just,
00022  *   Patrick Hartling, Kevin Meinert,
00023  *   Carolina Cruz-Neira, Albert Baker
00024  *
00025  * This library is free software; you can redistribute it and/or
00026  * modify it under the terms of the GNU Library General Public
00027  * License as published by the Free Software Foundation; either
00028  * version 2 of the License, or (at your option) any later version.
00029  *
00030  * This library is distributed in the hope that it will be useful,
00031  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00032  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00033  * Library General Public License for more details.
00034  *
00035  * You should have received a copy of the GNU Library General Public
00036  * License along with this library; if not, write to the
00037  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00038  * Boston, MA 02111-1307, USA.
00039  *
00040  *************** <auto-copyright.pl END do not edit this line> ***************/
00041 
00042 #ifndef _VPR_FILE_HANDLE_BRIDGE_H_
00043 #define _VPR_FILE_HANDLE_BRIDGE_H_
00044 
00045 #include <vpr/vprConfig.h>
00046 
00047 #include <string>
00048 #include <vector>
00049 
00050 #include <vpr/IO/BlockIO.h>
00051 #include <vpr/Util/Interval.h>
00052 #include <vpr/Util/ReturnStatus.h>
00053 
00054 
00055 namespace vpr
00056 {
00057 
00062 template<class RealFileHandleImpl>
00063 class FileHandle_t : public BlockIO
00064 {
00065 public:
00076    FileHandle_t(const std::string& file_name)
00077       : BlockIO(file_name), mOpenMode(READ_WRITE), mHandleImpl(file_name)
00078    {
00079       /* Do nothing. */ ;
00080    }
00081 
00088    virtual ~FileHandle_t()
00089    {
00090       /* Do nothing. */ ;
00091    }
00092 
00102    virtual const std::string& getName() const
00103    {
00104       return mHandleImpl.getName();
00105    }
00106 
00120    virtual vpr::ReturnStatus open()
00121    {
00122       return mHandleImpl.open();
00123    }
00124 
00138    virtual vpr::ReturnStatus close()
00139    {
00140       return mHandleImpl.close();
00141    }
00142 
00154    virtual vpr::ReturnStatus setBlocking(bool blocking)
00155    {
00156       return mHandleImpl.setBlocking(blocking);
00157    }
00158 
00167    bool isBlocking() const
00168    {
00169       return mHandleImpl.isBlocking();
00170    }
00171 
00179    virtual IOSys::Handle getHandle() const
00180    {
00181       return mHandleImpl.getHandle();
00182    }
00183 
00184    // ========================================================================
00185    // vpr::FileHandle API extensions.
00186    // ========================================================================
00187 
00196    void setOpenReadOnly()
00197    {
00198       mHandleImpl.setOpenReadOnly();
00199    }
00200 
00210    void setOpenWriteOnly()
00211    {
00212       mHandleImpl.setOpenWriteOnly();
00213    }
00214 
00224    void setOpenReadWrite()
00225    {
00226       mHandleImpl.setOpenReadWrite();
00227    }
00228 
00243    vpr::ReturnStatus setAppend(bool flag)
00244    {
00245       return mHandleImpl.setAppend(flag);
00246    }
00247 
00263    vpr::ReturnStatus setSynchronousWrite(bool flag)
00264    {
00265       return mHandleImpl.setSynchronousWrite(flag);
00266    }
00267 
00278    bool isReadOnly() const
00279    {
00280       return mHandleImpl.isReadOnly();
00281    }
00282 
00293    bool isWriteOnly() const
00294    {
00295       return mHandleImpl.isWriteOnly();
00296    }
00297 
00308    bool isReadWrite() const
00309    {
00310       return mHandleImpl.isReadWrite();;
00311    }
00312 
00313 protected:
00341    vpr::ReturnStatus read_i(void* buffer, const vpr::Uint32 length,
00342                             vpr::Uint32& bytes_read,
00343                             const vpr::Interval timeout = vpr::Interval::NoTimeout)
00344    {
00345       return mHandleImpl.read_i(buffer, length, bytes_read, timeout);
00346    }
00347 
00372    vpr::ReturnStatus readn_i(void* buffer, const vpr::Uint32 length,
00373                              vpr::Uint32& bytes_read,
00374                              const vpr::Interval timeout = vpr::Interval::NoTimeout)
00375    {
00376       return mHandleImpl.readn_i(buffer, length, bytes_read, timeout);
00377    }
00378 
00404    vpr::ReturnStatus write_i(const void* buffer, const vpr::Uint32 length,
00405                              vpr::Uint32& bytes_written,
00406                              const vpr::Interval timeout = vpr::Interval::NoTimeout)
00407    {
00408       return mHandleImpl.write_i(buffer, length, bytes_written, timeout);
00409    }
00410 
00412    RealFileHandleImpl mHandleImpl;
00413 };
00414 
00415 } // End of vpr namespace
00416 
00417 
00418 #endif  /* _VPR_FILE_HANDLE_H_ */

Generated on Sun May 2 14:43:01 2004 for VR Juggler Portable Runtime by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002