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

wefts_coffee_base.h

Go to the documentation of this file.
00001 /*
00002    wefts_coffee_base.h
00003    Abstract base class for cooperative file functions enlarged enviroment
00004 
00005    $Id: wefts_coffee_base.h,v 1.2 2003/12/17 17:57:18 jonnymind Exp $
00006 ---------------------------------------------
00007    Begin      : 2003-08-15 16:30
00008    Author     : Giancarlo Niccolai
00009 
00010    Last modified because:
00011 
00012 */
00013 
00014 /**************************************************************************
00015 *   This program is free software; you can redistribute it and/or modify  *
00016 *   it under the terms of the GNU Library General Public License as       *
00017 *   published by the Free Software Foundation; either version 2.1 of the  *
00018 *   License, or (at your option) any later version.                       *
00019 ***************************************************************************/
00020 
00021 
00022 #ifndef WT_COFFEE_BASE_H
00023 #define WT_COFFEE_BASE_H
00024 
00025 #include <wefts_cleanup.h>
00026 #include <string>
00027 
00043 namespace Wefts {
00044 
00050 #if defined(_MSC_VER) || defined(__BORLANDC__) 
00051 typedef unsigned __int64 file_size_t;
00052 #else
00053 typedef long long file_size_t;
00054 #endif
00055 
00057 typedef enum {
00058    /* The file shuold not be locked */
00059    LM_SHARED,
00060    /* The file shuold not be locked against writes, but read may occour */
00061    LM_SHARED_RO,
00062    /* The file shuold not be locked against both reads & writes */
00063    LM_EXCLUSIVE,
00064 } LockMode;
00065 
00066 
00068 typedef enum {
00070    OM_RO,
00072    OM_WO,
00074    OM_RW,
00079    OM_TRUNC_WO,
00084    OM_TRUNC_RW,
00086    OM_APPEND_WO,
00088    OM_APPEND_RW
00089 } OpenMode;
00090 
00109 typedef enum {
00111    CM_ARCHIVE,
00113    CM_SYSTEM,
00120    CM_EXECUTABLE,
00122    CM_PRIVATE,
00124    CM_PRIVATE_EX
00125 } CreateMode;
00126 
00127 
00142 typedef enum {
00144    CFF_DONE,
00147    CFF_WAITING,
00157    CFF_TIMEDOUT,
00158 
00164    CFF_SOFTERROR,
00165 
00169    CFF_HARDERROR,
00170 
00187    CFF_PROGERROR
00188 }CffStatus;
00189 
00191 typedef enum {
00192    SW_FROM_BEGIN=0,
00193    SW_FROM_CUR=1,
00194    SW_FROM_CURENT=1,
00195    SW_FROM_END=2
00196 } SeekWhence;
00197 
00219 class OSFileFuncBase {
00220 protected:
00231    OSFileFuncBase() {
00232       m_timeout = -1.0;
00233       m_osError = 0;
00234       m_status = CFF_DONE;
00235    }
00236 
00237    double m_timeout;
00238    CffStatus m_status;
00239    int m_osError;
00240 
00241 public:
00274    virtual inline CffStatus open(
00275       std::string filespec,             // the file name
00276       OpenMode openMode = OM_RO,        // open mode
00277       LockMode lockMode = LM_SHARED   // the file lock mode
00278       ) = 0;
00279 
00309    virtual inline CffStatus create(
00310       std::string filespec,               // the file name
00311       CreateMode cMode = CM_ARCHIVE,      // system atrribute
00312       LockMode lockMode = LM_EXCLUSIVE  // the file lock mode
00313       ) = 0;
00314 
00327    inline virtual void getDescriptor( void *data ) const = 0;
00328 
00341    inline virtual void setDescriptor( void *data ) = 0;
00342 
00343 
00345    inline CffStatus status() const { return m_status; }
00346 
00349    inline void status(const CffStatus st ) { m_status = st ; }
00350 
00359    inline int osError() const { return m_osError; }
00360 
00364    inline void osError( const int osError ) { m_osError = osError; }
00365 
00366 
00368    inline double timeout() const { return m_timeout; }
00369 
00377    inline void timeout( const double to ) { m_timeout = to; }
00378 
00379    /* Clears the timeout.
00380      All the operations on this class will be blocking.
00381    */
00382    inline void clearTimeout() { timeout( -1.0 ); }
00383 
00384    /* Set all operations on this class to be non-blocking.
00385      Functions will return immediately if the operation cannot be
00386      compelted without any wait.
00387    */
00388    inline void dontBlock() { timeout( 0.0 ); }
00389 
00403    virtual file_size_t read( void *buffer, const file_size_t len ) = 0;
00404 
00418    virtual file_size_t write( void *buffer, const file_size_t len ) = 0;
00419 
00427    virtual file_size_t seek(
00428       const file_size_t position,
00429       const SeekWhence swFrom= SW_FROM_BEGIN
00430       ) = 0;
00431 
00432    virtual CffStatus close()=0;
00433 
00434    inline virtual void setStdIn() = 0;
00435    inline virtual void setStdOut() = 0;
00436    inline virtual void setStdErr() = 0;
00437 
00438 };
00439 
00441 } // namespace
00442 
00443 #endif
00444 
00445 /* end of wefts_coffee_base.h */

Generated on Mon Dec 22 04:12:30 2003 for Wefts by doxygen1.2.18