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

phPrint.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission : 
00003         Realtime Vision Processing System
00004 
00005     Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008 
00009     This file is part of Phission.
00010 
00011     Phission is free software; you can redistribute it and/or modify
00012     it under the terms of the GNU Lesser General Public License as published by
00013     the Free Software Foundation; either version 2 of the License, or
00014     (at your option) any later version.
00015 
00016     Phission is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU Lesser General Public License for more details.
00020 
00021     You should have received a copy of the GNU Lesser General Public License
00022     along with Phission; if not, write to the Free Software
00023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025  ---------------------------------------------------------------------------*/
00026 #ifndef _PHPRINT_H
00027 #define _PHPRINT_H
00028 
00029 #include <phStandard.h>
00030 
00036 /* ------------------------------------------------------------------------ */
00037 #ifndef phPRINT_THREAD_ID
00038 
00047     #define phPRINT_THREAD_ID 1
00048 #endif
00049 #ifndef phNO_FUNCTION_VARIABLE
00050 
00061     #define phNO_FUNCTION_VARIABLE 0
00062 #endif
00063 #ifndef phDONT_PRINT_ERRORS
00064 
00075     #define phDONT_PRINT_ERRORS 0
00076 #endif
00077 
00079 /* ------------------------------------------------------------------------- */
00080 #define __PHILE__ __FILE__
00081 //#define __PHILE__ ""
00082 
00083 /* ------------------------------------------------------------------------- */
00093 #if defined(_DEBUG) && 0
00094     #if phNO_FUNCTION_VARIABLE
00095         #define DEBUG_PRINT(fmt, ...) \
00096         { \
00097             phPRINT( "(pid:%d %s:%d)\t" fmt, \
00098                     phProcessId(),__PHILE__, __LINE__, \
00099                     ## __VA_ARGS__); \
00100         }
00101     #else /* #if phNO_FUNCTION_VARIABLE */
00102         #define DEBUG_PRINT(fmt, ...) \
00103         { \
00104             phPRINT( "(pid:%d %s:%d @ %s)\t" fmt, \
00105                     phProcessId(),__PHILE__, __LINE__,function, \
00106                     ## __VA_ARGS__ ); \
00107         }
00108     #endif
00109 #else
00110     #define DEBUG_PRINT(fmt, ...);
00111 #endif
00112 
00113 /* ------------------------------------------------------------------------- */
00120 #define phPRINT(fmt,...) \
00121 {\
00122     /*fprintf(stderr, fmt, ## __VA_ARGS__); */\
00123     printf( fmt, ## __VA_ARGS__); \
00124 }
00125 
00126 /* ------------------------------------------------------------------------- */
00133 #define phPRINT_ERROR(fmt,...) \
00134 {\
00135     /*fprintf(stderr, fmt, ## __VA_ARGS__); */\
00136     printf( fmt, ## __VA_ARGS__); \
00137 }
00138 
00139 /* ------------------------------------------------------------------------- */
00140 #if phPRINT_THREAD_ID
00141     /* --------------------------------------------------------------------- */
00153     #if phNO_FUNCTION_VARIABLE
00154         #define phPROGRESS(fmt,...) \
00155         {\
00156             phPRINT( "(pid:%llu|thread:%llu %s:%d)\t" fmt,\
00157                     (long long unsigned int)phProcessId(),\
00158                     (long long unsigned int)phGetCurrentThreadId(), \
00159                     __PHILE__,__LINE__, \
00160                     ## __VA_ARGS__); \
00161         }
00162     #else
00163         #define phPROGRESS(fmt,...) \
00164         {\
00165             phPRINT( "(pid:%llu|thread:%llu %s:%d @ %s)\t" fmt,\
00166                     (long long unsigned int)phProcessId(),\
00167                     (long long unsigned int)phGetCurrentThreadId(), \
00168                     __PHILE__,__LINE__,function, \
00169                     ## __VA_ARGS__); \
00170         }
00171     #endif /* #if phNO_FUNCTION_VARIABLE */
00172 
00173     /* --------------------------------------------------------------------- */
00192     #if phDONT_PRINT_ERRORS
00193         #define phERROR_PRINT(pmsg,fmt,...)
00194         #define phWARNING_PRINT(fmt,...)
00195     #elif phNO_FUNCTION_VARIABLE
00196         #define phERROR_PRINT(pmsg,fmt,...) \
00197         {\
00198             if (((void *)pmsg) != NULL) \
00199             {   \
00200                 phError(pmsg); \
00201                 phPRINT_ERROR(" ^\n  \\--<( error belongs to following message )>--\\\n"); \
00202                 phPRINT_ERROR("                                               \\/\n"); \
00203             } \
00204             phPRINT_ERROR( "(pid:%llu|thread:%llu %s:%d)\t" fmt, \
00205                     (long long unsigned int)phProcessId(),\
00206                     (long long unsigned int)phGetCurrentThreadId(), \
00207                     __PHILE__,__LINE__,\
00208                     ## __VA_ARGS__); \
00209         }
00210         #define phWARNING_PRINT(fmt,...) \
00211         {\
00212             phPRINT( "(pid:%llu|thread:%llu %s:%d) *** WARNING ***\t" \
00213                     fmt, \
00214                     (long long unsigned int)phProcessId(),\
00215                     (long long unsigned int)phGetCurrentThreadId(), \
00216                     __PHILE__,__LINE__,\
00217                     ## __VA_ARGS__); \
00218         }
00219     #else
00220         #define phERROR_PRINT(pmsg,fmt,...) \
00221         {\
00222             if (((void *)pmsg) != NULL) \
00223             {   \
00224                 phError(pmsg); \
00225                 phPRINT_ERROR(" ^\n  \\--<( error belongs to following message )>--\\\n"); \
00226                 phPRINT_ERROR("                                               \\/\n"); \
00227             } \
00228             phPRINT_ERROR( "(pid:%llu|thread:%llu %s:%d @ %s)\t" fmt, \
00229                     (long long unsigned int)phProcessId(),\
00230                     (long long unsigned int)phGetCurrentThreadId(), \
00231                     __PHILE__,__LINE__,function, \
00232                     ## __VA_ARGS__); \
00233         }
00234         #define phWARNING_PRINT(fmt,...) \
00235         {\
00236             phPRINT( "(pid:%llu|thread:%llu %s:%d @ %s) *** WARNING ***\t" \
00237                     fmt, \
00238                     (long long unsigned int)phProcessId(),\
00239                     (long long unsigned int)phGetCurrentThreadId(), \
00240                     __PHILE__,__LINE__,function, \
00241                     ## __VA_ARGS__); \
00242         }
00243     #endif /* #if phNO_FUNCTION_VARIABLE */
00244 /* ------------------------------------------------------------------------- */
00245 #else /* phPRINT_THREAD_ID */
00246 /* ------------------------------------------------------------------------- */
00247     #if phNO_FUNCTION_VARIABLE
00248         #define phPROGRESS(fmt,...) \
00249         {\
00250             phPRINT( "(pid:%llu %s:%d)\t" fmt,\
00251                     (long long unsigned int)phProcessId(),\
00252                     __PHILE__,__LINE__,\
00253                     ## __VA_ARGS__); \
00254         }
00255     #else
00256         #define phPROGRESS(fmt,...) \
00257         {\
00258             phPRINT( "(pid:%llu %s:%d @ %s)\t" fmt,\
00259                     (long long unsigned int)phProcessId(),\
00260                     __PHILE__,__LINE__,function, \
00261                     ## __VA_ARGS__); \
00262         }
00263     #endif /* #if phNO_FUNCTION_VARIABLE */
00264 
00265     /* --------------------------------------------------------------------- */
00266     #if phDONT_PRINT_ERRORS
00267         #define phERROR_PRINT(pmsg,fmt,...)
00268         #define phWARNING_PRINT(fmt,...)
00269     #elif phNO_FUNCTION_VARIABLE
00270         #define phERROR_PRINT(pmsg,fmt,...) \
00271         {\
00272             phPRINT_ERROR( "(pid:%llu %s:%d)\t" fmt, \
00273                     (long long unsigned int)phProcessId(),\
00274                     __PHILE__,__LINE__,\
00275                     ## __VA_ARGS__); \
00276             if (((void *)pmsg) != NULL)  phError(pmsg); \
00277         }
00278         #define phWARNING_PRINT(fmt,...) \
00279         {\
00280             phPRINT( "(pid:%llu %s:%d) *** WARNING ***\t" fmt, \
00281                     (long long unsigned int)phProcessId(),\
00282                     __PHILE__,__LINE__,\
00283                     ## __VA_ARGS__); \
00284         }
00285     #else 
00286         #define phERROR_PRINT(pmsg,fmt,...) \
00287         {\
00288             phPRINT_ERROR( "(pid:%llu %s:%d @ %s)\t" fmt, \
00289                     (long long unsigned int)phProcessId(),\
00290                     __PHILE__,__LINE__,function, \
00291                     ## __VA_ARGS__); \
00292             if (((void *)pmsg) != NULL)  phError(pmsg); \
00293         }
00294         #define phWARNING_PRINT(fmt,...) \
00295         {\
00296             phPRINT( "(pid:%llu %s:%d @ %s) *** WARNING ***\t" fmt, \
00297                     (long long unsigned int)phProcessId(),\
00298                     __PHILE__,__LINE__,function, \
00299                     ## __VA_ARGS__); \
00300         }
00301     #endif /* #if phNO_FUNCTION_VARIABLE */
00302 #endif /* phPRINT_THREAD_ID */
00303 
00304 /* ------------------------------------------------------------------------- */
00305 #define phERR_PRINT(fmt,...) phERROR_PRINT(NULL,fmt, ##__VA_ARGS__ );
00306 #define phWARN(fmt,...) phWARNING_PRINT(fmt, ##__VA_ARGS__ );
00307  /* end \addtogroup PrintingMacros */
00309 
00310 /* ------------------------------------------------------------------------- */
00311 #if !phNO_FUNCTION_VARIABLE
00312 
00321 #define phFUNCTION(name) \
00322     const char *function = name; \
00323     int rc = 0; \
00324 
00325 #else /* #if !phNO_FUNCTION_VARIABLE */
00326 #define phFUNCTION(name) \
00327     int rc = 0; \
00328 
00329 #endif
00330 
00331 #endif /* _PHPRINT_H */




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:02 2007 for phission by  doxygen 1.4.4