メインページ   モジュール   クラス階層   アルファベット順一覧   構成   ファイル一覧   構成メンバ   ファイルメンバ   関連ページ  

Tglobals.h

解説を見る。
00001 // =====================================================================
00002 //  $Id: Tglobals.h,v 1.2 2003/07/30 16:21:21 goiwai Exp $
00003 //  $Name: CLDAQ-1-07-00 $
00004 //
00005 //  $Log: Tglobals.h,v $
00006 //  Revision 1.2  2003/07/30 16:21:21  goiwai
00007 //  ファイルにコミットログをつけることにしました.
00008 //
00009 // =====================================================================
00010 #ifndef __TGLOBALS_H
00011 #define __TGLOBALS_H
00012 
00013 #include <pthread.h>
00014 
00015 #include <X11/Xlib.h>
00016 #include <X11/Xutil.h>
00017 #include <X11/Xatom.h>
00018 #include <X11/cursorfont.h>
00019 #include <X11/keysym.h>
00020 #include <X11/xpm.h>
00021 
00022 #include <stdio.h>
00023 #include <string.h>
00024 #include <fstream>
00025 #include <stdlib.h>
00026 #include <time.h>
00027 #include <sys/types.h>
00028 #include <sys/stat.h>
00029 #include <sys/un.h>
00030 #include <fcntl.h>
00031 #include <sys/time.h>
00032 #include <sys/times.h>
00033 #include <errno.h>
00034 #include <math.h>
00035 #include <sys/socket.h>
00036 #include <netinet/in.h>
00037 #include <arpa/inet.h>
00038 #include <netdb.h>
00039 #include <signal.h>
00040 #include <sys/ioctl.h>
00041 #include <sys/ipc.h>
00042 #include <sys/sem.h>
00043 #include <sys/shm.h>
00044 #include <sys/wait.h>
00045 #include <termios.h>
00046 #include <sys/mman.h>
00047 #include <term.h>
00048 #include <ncurses.h>
00049 #include <unistd.h>
00050 #include <limits.h>
00051 #include <values.h>
00052 
00053 #ifdef __CLDAQ_ZLIB_USE
00054 #include <zlib.h>
00055 #endif
00056 
00057 #include <linux/param.h>
00058 
00059 #ifndef __USE_BSD
00060 typedef __caddr_t caddr_t;
00061 #endif
00062 
00063 #if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
00064 // see <sys/sem.h>
00065 #else
00066 // if defer to X/OPEN design
00067 union semun {
00068   int val;                    // value for SETVAL
00069   struct semid_ds* buf;       // buffer for IPC_STAT, IPC_SET
00070   unsigned short int* array;  // array for GETALL, SETALL
00071   struct seminfo* __buf;      // buffer for IPC_INFO
00072 };
00073 #endif
00074 
00075 #include "Ttypes.h"
00076 
00077 extern Tchar** environ;
00078 
00079 static const Tint _digits = 6;
00080 static const Tsize_t _buflen = 64;
00081 static const Tsize_t _precision = 6;
00082 
00083 inline static Tstring itostr( Tint i, Tint digits = _digits )
00084 {
00085   static const Tsize_t buflen = _buflen;
00086   static Tchar buf[ buflen ];
00087   Tostrstream os( buf, buflen );
00088 
00089   if ( i >= 0 ) {
00090     os << setfill( '0' ) << setiosflags( Tios::right ) << setw( digits );
00091     os << i << Tends;
00092     Tstring s = os.str();
00093     return( s );
00094   } else {
00095     os << i << Tends;
00096     Tstring s = os.str();
00097     Tint nzero = digits - s.size();
00098     if ( nzero > 0 ) {
00099       s.insert( 1, nzero, '0' );
00100     }
00101     return( s );
00102   }
00103 }
00104 
00105 inline static Tstring ltostr( Tlong l, Tint digits = _digits )
00106 {
00107   static const Tsize_t buflen = _buflen;
00108   static Tchar buf[ buflen ];
00109   Tostrstream os( buf, buflen );
00110 
00111   if ( l >= 0 ) {
00112     os << setfill( '0' ) << setiosflags( Tios::right ) << setw( digits );
00113     os << l << Tends;
00114     Tstring s = os.str();
00115     return( s );
00116   } else {
00117     os << l << Tends;
00118     Tstring s = os.str();
00119     Tint nzero = digits - s.size();
00120     if ( nzero > 0 ) {
00121       s.insert( 1, nzero, '0' );
00122     }
00123     return( s );
00124   }
00125 }
00126 
00127 inline static Tstring ultostr( TUlong ul, Tint digits = _digits )
00128 {
00129   static const Tsize_t buflen = _buflen;
00130   static Tchar buf[ buflen ];
00131   Tostrstream os( buf, buflen );
00132 
00133   if ( ul >= 0 ) {
00134     os << setfill( '0' ) << setiosflags( Tios::right ) << setw( digits );
00135     os << ul << Tends;
00136     Tstring s = os.str();
00137     return( s );
00138   } else {
00139     os << ul << Tends;
00140     Tstring s = os.str();
00141     Tint nzero = digits - s.size();
00142     if ( nzero > 0 ) {
00143       s.insert( 1, nzero, '0' );
00144     }
00145     return( s );
00146   }
00147 }
00148 
00149 inline static Tstring dtostr( Tdouble d, Tint precision = _precision )
00150 {
00151   static const Tsize_t buflen = _buflen;
00152   static Tchar buf[ buflen ];
00153   Tostrstream os( buf, buflen );
00154 
00155   os << setprecision( precision ) << d << Tends;
00156   Tstring s = os.str();
00157   return( s );
00158 }
00159 
00160 inline static Tstring ftostr( Tfloat f, Tint precision = _precision )
00161 {
00162   return( dtostr( (Tdouble)f, precision ) );
00163 }
00164 
00165 inline static Tbool isexist( const Tstring& filename )
00166 {
00167   if ( access( filename.c_str(), F_OK ) == 0 ) {
00168     return( Ttrue );
00169   } else {
00170     return( Tfalse );
00171   }
00172 }
00173 
00174 inline static Tvoid showbit( Tint bit )
00175 {
00176   Tint nbit = Tsizeof( bit ) * 8;
00177   for ( Tint i = nbit; i > 0; i -- ) {
00178     Tcout << ( ( bit >> i - 1 ) & 0x01 );
00179   }
00180   Tcout << Tendl;
00181   return;
00182 }
00183 
00184 #endif

CLDAQ - a Class Library for Data AcQuisition (Version 1.7.0)
Go IWAI <goiwai@users.sourceforge.jp>