FILE_IO.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    FILE_IO.h
00006  *
00007  *  FILE_IO.h,v 4.28 2005/10/28 16:14:52 ossama Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_FILE_IO_H
00014 #define ACE_FILE_IO_H
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "ace/FILE.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include "ace/FILE_Addr.h"
00024 
00025 // Used in the FILE_IO.h file...
00026 #include "ace/os_include/os_stdio.h"
00027 #include "ace/os_include/sys/os_uio.h"
00028 
00029 #if defined (ACE_HAS_STREAM_PIPES)
00030 #  include "ace/OS_NS_stropts.h"
00031 #endif /* ACE_HAS_STREAM_PIPES */
00032 
00033 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00034 
00035 // Forward decl.
00036 class ACE_Message_Block;
00037 class ACE_Time_Value;
00038 
00039 /**
00040  * @class ACE_FILE_IO
00041  *
00042  * @brief Read/Write operations on Files
00043  */
00044 class ACE_Export ACE_FILE_IO : public ACE_FILE
00045 {
00046 public:
00047   friend class ACE_FILE_Connector;
00048 
00049   // = Initialization method.
00050   /// Default constructor.
00051   ACE_FILE_IO (void);
00052 
00053   /// send upto <n> bytes in <buf>.
00054   ssize_t send (const void *buf, size_t n) const;
00055 
00056   /// Recv upto <n> bytes in <buf>.
00057   ssize_t recv (void *buf, size_t n) const;
00058 
00059   /// Send n bytes, keep trying until n are sent.
00060   ssize_t send_n (const void *buf, size_t n) const;
00061 
00062   /// Send all the <message_block>s chained through their <next> and
00063   /// <cont> pointers.  This call uses the underlying OS gather-write
00064   /// operation to reduce the domain-crossing penalty.
00065   ssize_t send_n (const ACE_Message_Block *message_block,
00066                   const ACE_Time_Value *timeout = 0,
00067                   size_t *bytes_transferred = 0);
00068 
00069   /// Recv n bytes, keep trying until n are received.
00070   ssize_t recv_n (void *buf, size_t n) const;
00071 
00072 #if defined (ACE_HAS_STREAM_PIPES)
00073   /// Send bytes via STREAM pipes.
00074   ssize_t send (const ACE_Str_Buf *cntl,
00075                 const ACE_Str_Buf *data,
00076                 int flags = 0) const;
00077 
00078   /// Recv bytes via STREAM pipes.
00079   ssize_t recv (ACE_Str_Buf *cntl,
00080                 ACE_Str_Buf *data,
00081                 int *flags) const;
00082 
00083   /// Send bytes via STREAM pipes using "band" mode.
00084   ssize_t send (const ACE_Str_Buf *cntl,
00085                 const ACE_Str_Buf *data,
00086                 int band,
00087                 int flags) const;
00088 
00089   /// Recv bytes via STREAM pipes using "band" mode.
00090   ssize_t recv (ACE_Str_Buf *cntl,
00091                 ACE_Str_Buf *data,
00092                 int *band,
00093                 int *flags) const;
00094 
00095 #endif /* ACE_HAS_STREAM_PIPES */
00096 
00097   /// Send iovecs via <::writev>.
00098   ssize_t send (const iovec iov[], int n) const;
00099 
00100   /// Recv iovecs via <::readv>.
00101   ssize_t recv (iovec iov[], int n) const;
00102 
00103   /**
00104    * Send N char *ptrs and int lengths.  Note that the char *'s
00105    * precede the ints (basically, an varargs version of writev).  The
00106    * count N is the *total* number of trailing arguments, *not* a
00107    * couple of the number of tuple pairs!
00108    */
00109   ssize_t send (size_t n, ...) const;
00110 
00111   /**
00112    * This is an interface to ::readv, that doesn't use the struct
00113    * iovec explicitly.  The ... can be passed as an arbitrary number
00114    * of (char *ptr, int len) tuples.  However, the count N is the
00115    * *total* number of trailing arguments, *not* a couple of the
00116    * number of tuple pairs!
00117    */
00118   ssize_t recv (size_t n, ...) const;
00119 
00120   /// Send <n> bytes via Win32 WriteFile using overlapped I/O.
00121   ssize_t send (const void *buf,
00122                 size_t n,
00123                 ACE_OVERLAPPED *overlapped) const;
00124 
00125   /// Recv <n> bytes via Win32 ReadFile using overlapped I/O.
00126   ssize_t recv (void *buf,
00127                 size_t n,
00128                 ACE_OVERLAPPED *overlapped) const;
00129 
00130   /// Send an <iovec> of size <n> to the file.
00131   ssize_t sendv (const iovec iov[],
00132                  int n) const;
00133 
00134   /**
00135    * Allows a client to read from a file without having to provide a
00136    * buffer to read.  This method determines how much data is in the
00137    * file, allocates a buffer of this size, reads in the data, and
00138    * returns the number of bytes read.  The caller is responsible for
00139    * deleting the member in the <iov_base> field of <io_vec> using
00140    * delete [] io_vec->iov_base.
00141    */
00142   ssize_t recvv (iovec *io_vec);
00143 
00144   /// Send an <iovec> of size <n> to the file.  Will block until all
00145   /// bytes are sent or an error occurs.
00146   ssize_t sendv_n (const iovec iov[],
00147                    int n) const;
00148 
00149   /// Receive an <iovec> of size <n> to the file.
00150   ssize_t recvv_n (iovec iov[],
00151                    int n) const;
00152 
00153   /// Dump the state of an object.
00154   void dump (void) const;
00155 
00156   /// Declare the dynamic allocation hooks.
00157   ACE_ALLOC_HOOK_DECLARE;
00158 
00159   // = Meta-type info
00160   typedef ACE_FILE_Addr PEER_ADDR;
00161 };
00162 
00163 ACE_END_VERSIONED_NAMESPACE_DECL
00164 
00165 #if defined (__ACE_INLINE__)
00166 #include "ace/FILE_IO.inl"
00167 #endif /* __ACE_INLINE__ */
00168 
00169 #include /**/ "ace/post.h"
00170 #endif /* ACE_FILE_IO_H */

Generated on Thu Nov 9 09:41:51 2006 for ACE by doxygen 1.3.6