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

Tglobals.h

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

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