Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

SIO_functions.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 // CVS $Id: SIO_functions.h,v 1.5 2006/12/06 19:09:18 hvogt Exp $
00003 // ----------------------------------------------------------------------------
00004 // => Primitive functions for reading/writing SIO streams         
00005 // ----------------------------------------------------------------------------
00006 //
00007 // General Description:
00008 //
00009 // SIO_funtions provides the primitive functions for reading from/writing to
00010 // SIO streams.
00011 //
00012 // ----------------------------------------------------------------------------
00013 
00014 #ifndef SIO_FUNCTIONS_H
00015 #define SIO_FUNCTIONS_H 1
00016 
00017 #define SIO_LEN_SB        1
00018 #define SIO_LEN_DB        2
00019 #define SIO_LEN_QB        4
00020 #define SIO_LEN_OB        8
00021 
00022 // ----------------------------------------------------------------------------
00023 // Deal with declarations for 64 bit integers.  This really amounts to "who is
00024 // ANSI compiant?"  ANSI defines "long long" as the declaration for 64 bit
00025 // integers.  M$ hasn't caught up yet and still requires __int64.
00026 //
00027 // Branch on flag provided by compiler:
00028 //
00029 // OS            CPU           Macro         Provided by   Declaration
00030 // ------------  ------------  ------------  ------------  -----------
00031 // AIX           PPC(?)        _AIX          GNU compiler  long long
00032 // OSF1          Alpha         __alpha__     GNU compiler  long long
00033 // Linux         x86           __i386__      GNU compiler  long long
00034 // Linux         Opteron       _LP64         GNU compiler  long long
00035 // Linux         Itanium       _LP64         GNU compiler  long long
00036 // SunOS         Sparc         __sparc__     GNU compiler  long long
00037 // Windows/NT    Alpha         _M_ALPHA      VC  compiler  __int64
00038 // Windows/NT    x86           _M_IX86       VC  compiler  __int64
00039 // Windows/NT    MIPS          _M_MRX000     VC  compiler  __int64
00040 // Windows/NT    PPC           _M_PPC        VC  compiler  __int64
00041 // ----------------------------------------------------------------------------
00042 #if defined(_AIX)      ||  defined(__alpha__) || defined(__i386__)  || defined(__sparc__) || defined(__APPLE_CC__) || defined(_LP64)
00043 
00044 // fg: gcc complains about long long - what to do about it ?
00045 // warning: ANSI C++ does not support `long long'
00046  #define SIO_64BITINT   long long
00047 // #define SIO_64BITINT   long
00048 #endif
00049 
00050 #if defined(_M_ALPHA)  || defined(_M_IX86)   || defined(_M_PPC)
00051  #define SIO_64BITINT   __int64
00052 #endif
00053 
00054 // ----------------------------------------------------------------------------
00055 // Deal with pointer length.  Currently, the only problem is alpha which uses
00056 // 64 bit pointers.                                                          
00057 //                                                              
00058 // OS            CPU           Macro         Provided by   Pointer size
00059 // ------------  ------------  ------------  ------------  -----------
00060 // AIX           PPC(?)        _AIX          GNU compiler  4 bytes
00061 // OSF1          Alpha         __alpha__     GNU compiler  8 bytes
00062 // Linux         x86           __i386__      GNU compiler  4 bytes
00063 // Linux         Opteron       _LP64    _    GNU compiler  8 bytes
00064 // Linux         Itanium       _LP64         GNU compiler  8 bytes
00065 // SunOS         Sparc         __sparc__     GNU compiler  4 bytes
00066 // Windows/NT    Alpha         _M_ALPHA      VC  compiler  8 bytes
00067 // Windows/NT    x86           _M_IX86       VC  compiler  4 bytes
00068 // Windows/NT    MIPS          _M_MRX000     VC  compiler  ? bytes
00069 // Windows/NT    PPC           _M_PPC        VC  compiler  4 bytes
00070 // ----------------------------------------------------------------------------
00071 #if defined(__alpha__) || defined(_M_ALPHA) || defined(_LP64)
00072  #define SIO_POINTER_DECL   size_t
00073 #endif
00074 
00075 #if defined(_AIX)      || defined(__i386__)  || defined(__sparc__) || defined(_M_IX86) || defined(_M_PPC) || defined(__APPLE_CC__)
00076  #define SIO_POINTER_DECL   unsigned int
00077 #endif
00078 
00079 //
00080 // Take the drudgery out of error handling.
00081 //
00082 #define SIO_DATA( rec, pnt, cnt ) status = SIO_functions::data( (rec), (pnt), (cnt) ); if( !(status & 1) ) return status;
00083 
00084 #define SIO_PNTR( rec, pnt )   status = SIO_functions::pointer_to( (rec), (SIO_POINTER_DECL *)(pnt) );   if( !(status & 1) )       return status;
00085 
00086 #define SIO_PTAG( rec, pnt )   status = SIO_functions::pointed_at( (rec), (SIO_POINTER_DECL *)(pnt) );   if( !(status & 1) )       return status;
00087 
00088 //
00089 // This turns up far too often to be ignored.
00090 //
00091 #define UCHR_CAST(pntr)    (reinterpret_cast<unsigned char*>((pntr)))
00092 
00093 class SIO_stream;
00094 
00095 class SIO_functions
00096 {
00097 public:
00098 
00099     static unsigned int data( SIO_stream*,          char*,         const int );
00100     static unsigned int data( SIO_stream*, unsigned char*,         const int );
00101     static unsigned int data( SIO_stream*,          short*,        const int );
00102     static unsigned int data( SIO_stream*, unsigned short*,        const int );
00103     static unsigned int data( SIO_stream*,          int*,          const int );
00104     static unsigned int data( SIO_stream*, unsigned int*,          const int );
00105     static unsigned int data( SIO_stream*,          SIO_64BITINT*, const int );
00106     static unsigned int data( SIO_stream*, unsigned SIO_64BITINT*, const int );
00107     static unsigned int data( SIO_stream*,          float*,        const int );
00108     static unsigned int data( SIO_stream*,          double*,       const int );
00109 
00110     static unsigned int pointed_at( SIO_stream*, SIO_POINTER_DECL* );
00111     static unsigned int pointer_to( SIO_stream*, SIO_POINTER_DECL* );
00112 
00113     static bool validateName( const char* );
00114 
00115 private:
00116 
00117     static void         copy( unsigned char*, unsigned char*, 
00118                               const int,      const int      );
00119     static unsigned int xfer( SIO_stream*,    const int, 
00120                               const int,      unsigned char* );
00121 
00122     friend class SIO_stream;              // Direct access to copy
00123     friend class SIO_record;              // Direct access to copy
00124 }; 
00125 
00126 #endif

Generated on Sun Jun 3 06:32:01 2007 for A TPC Tracking Environment by  doxygen 1.3.9.1