Geant4 Cross Reference |
1 #ifndef statusMessageReporting_h_included 1 #ifndef statusMessageReporting_h_included 2 #define statusMessageReporting_h_included 2 #define statusMessageReporting_h_included 3 3 4 #include <stdio.h> 4 #include <stdio.h> 5 #include <stdarg.h> 5 #include <stdarg.h> 6 6 7 #ifdef WIN32 7 #ifdef WIN32 8 #define __func__ __FUNCTION__ 8 #define __func__ __FUNCTION__ 9 #endif 9 #endif 10 10 11 #if defined __cplusplus 11 #if defined __cplusplus 12 extern "C" { 12 extern "C" { 13 namespace GIDI { 13 namespace GIDI { 14 #endif 14 #endif 15 15 16 #define smr_unknownID 0 16 #define smr_unknownID 0 17 #define smr_tooManyIDs 1 17 #define smr_tooManyIDs 1 18 #define smr_invalidID 2 18 #define smr_invalidID 2 19 #define smr_errnoID 3 19 #define smr_errnoID 3 20 #define smr_smrID 4 20 #define smr_smrID 4 21 21 22 #define smr_maximumNumberOfRegisteredLibraries 22 #define smr_maximumNumberOfRegisteredLibraries 128 23 #define smr_maximumFileNameSize 1024 23 #define smr_maximumFileNameSize 1024 24 #define smr_codeNULL 0 24 #define smr_codeNULL 0 25 #define smr_codeFileIO -1 25 #define smr_codeFileIO -1 26 #define smr_codeMemoryAllocating -2 26 #define smr_codeMemoryAllocating -2 27 enum smr_status { smr_status_Ok = 0, smr_statu 27 enum smr_status { smr_status_Ok = 0, smr_status_Info, smr_status_Warning, smr_status_Error }; 28 typedef char *(*smr_userInterface)( void *user 28 typedef char *(*smr_userInterface)( void *userData ); 29 29 30 typedef struct statusMessageReport { 30 typedef struct statusMessageReport { 31 struct statusMessageReport *next; 31 struct statusMessageReport *next; 32 enum smr_status status; 32 enum smr_status status; 33 int libraryID; 33 int libraryID; 34 int code; 34 int code; 35 int line; 35 int line; 36 char fileName[smr_maximumFileNameSize+1]; 36 char fileName[smr_maximumFileNameSize+1]; /* Do not free this. */ 37 char function[smr_maximumFileNameSize+1]; 37 char function[smr_maximumFileNameSize+1]; /* Do not free this. */ 38 char *message; 38 char *message; /* User must free this when done. Should use smr_release. */ 39 } statusMessageReport; 39 } statusMessageReport; 40 40 41 typedef struct statusMessageReporting { 41 typedef struct statusMessageReporting { 42 enum smr_status verbosity; 42 enum smr_status verbosity; 43 int append; 43 int append; /* If 0, only one report allowed, else add to next list. */ 44 statusMessageReport report; 44 statusMessageReport report; 45 } statusMessageReporting; 45 } statusMessageReporting; 46 46 47 int smr_setup( void ); 47 int smr_setup( void ); 48 int smr_cleanup( void ); 48 int smr_cleanup( void ); 49 49 50 int smr_registerLibrary( char const *libraryNa 50 int smr_registerLibrary( char const *libraryName ); 51 int smr_numberOfRegisteredLibraries( void ); 51 int smr_numberOfRegisteredLibraries( void ); 52 char const *smr_getRegisteredLibrariesName( in 52 char const *smr_getRegisteredLibrariesName( int ID ); 53 53 54 statusMessageReporting *smr_new( statusMessage 54 statusMessageReporting *smr_new( statusMessageReporting *smr, enum smr_status verbosity, int append ); 55 int smr_initialize( statusMessageReporting *sm 55 int smr_initialize( statusMessageReporting *smr, enum smr_status verbosity, int append ); 56 void smr_release( statusMessageReporting *smr 56 void smr_release( statusMessageReporting *smr ); 57 void *smr_free( statusMessageReporting **smr ) 57 void *smr_free( statusMessageReporting **smr ); 58 statusMessageReporting *smr_clone( statusMessa 58 statusMessageReporting *smr_clone( statusMessageReporting *smr ); 59 59 60 int smr_setReportInfo( statusMessageReporting 60 int smr_setReportInfo( statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, ... ); 61 int smr_vsetReportInfo( statusMessageReporting 61 int smr_vsetReportInfo( statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, va_list *args ); 62 int smr_setReportWarning( statusMessageReport 62 int smr_setReportWarning( statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, ... ); 63 int smr_vsetReportWarning( statusMessageReport 63 int smr_vsetReportWarning( statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, va_list *args ); 64 int smr_setReportError( statusMessageReportin 64 int smr_setReportError( statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, ... ); 65 int smr_vsetReportError( statusMessageReportin 65 int smr_vsetReportError( statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, va_list *args ); 66 66 67 enum smr_status smr_highestStatus( statusMessa 67 enum smr_status smr_highestStatus( statusMessageReporting *smr ); 68 int smr_isOk( statusMessageReporting *smr ); 68 int smr_isOk( statusMessageReporting *smr ); 69 int smr_isInfo( statusMessageReporting *smr ); 69 int smr_isInfo( statusMessageReporting *smr ); 70 int smr_isWarning( statusMessageReporting *smr 70 int smr_isWarning( statusMessageReporting *smr ); 71 int smr_isError( statusMessageReporting *smr ) 71 int smr_isError( statusMessageReporting *smr ); 72 int smr_isWarningOrError( statusMessageReporti 72 int smr_isWarningOrError( statusMessageReporting *smr ); 73 73 74 int smr_isReportOk( statusMessageReport *repor 74 int smr_isReportOk( statusMessageReport *report ); 75 int smr_isReportInfo( statusMessageReport *rep 75 int smr_isReportInfo( statusMessageReport *report ); 76 int smr_isReportWarning( statusMessageReport * 76 int smr_isReportWarning( statusMessageReport *report ); 77 int smr_isReportError( statusMessageReport *re 77 int smr_isReportError( statusMessageReport *report ); 78 int smr_isReportWarningOrError( statusMessageR 78 int smr_isReportWarningOrError( statusMessageReport *report ); 79 79 80 int smr_numberOfReports( statusMessageReportin 80 int smr_numberOfReports( statusMessageReporting *smr ); 81 statusMessageReport *smr_firstReport( statusMe 81 statusMessageReport *smr_firstReport( statusMessageReporting *smr ); 82 statusMessageReport *smr_nextReport( statusMes 82 statusMessageReport *smr_nextReport( statusMessageReport *report ); 83 83 84 enum smr_status smr_getVerbosity( statusMessag 84 enum smr_status smr_getVerbosity( statusMessageReporting *smr ); 85 int smr_getAppend( statusMessageReporting *smr 85 int smr_getAppend( statusMessageReporting *smr ); 86 86 87 int smr_getLibraryID( statusMessageReport *rep 87 int smr_getLibraryID( statusMessageReport *report ); 88 int smr_getCode( statusMessageReport *report ) 88 int smr_getCode( statusMessageReport *report ); 89 int smr_getLine( statusMessageReport *report ) 89 int smr_getLine( statusMessageReport *report ); 90 char const *smr_getFile( statusMessageReport * 90 char const *smr_getFile( statusMessageReport *report ); 91 char const *smr_getFunction( statusMessageRepo 91 char const *smr_getFunction( statusMessageReport *report ); 92 char const *smr_getMessage( statusMessageRepor 92 char const *smr_getMessage( statusMessageReport *report ); 93 char *smr_copyMessage( statusMessageReport *re 93 char *smr_copyMessage( statusMessageReport *report ); 94 char *smr_copyFullMessage( statusMessageReport 94 char *smr_copyFullMessage( statusMessageReport *report ); 95 void smr_print( statusMessageReporting *smr, i 95 void smr_print( statusMessageReporting *smr, int clear ); 96 void smr_write( statusMessageReporting *smr, F 96 void smr_write( statusMessageReporting *smr, FILE *f, int clear ); 97 void smr_reportPrint( statusMessageReport *rep 97 void smr_reportPrint( statusMessageReport *report ); 98 void smr_reportWrite( statusMessageReport *rep 98 void smr_reportWrite( statusMessageReport *report, FILE *f ); 99 99 100 char const *smr_statusToString( enum smr_statu 100 char const *smr_statusToString( enum smr_status status ); 101 101 102 char *smr_allocateFormatMessage( char const *f 102 char *smr_allocateFormatMessage( char const *fmt, ... ); 103 char *smr_vallocateFormatMessage( char const * 103 char *smr_vallocateFormatMessage( char const *fmt, va_list *args ); 104 104 105 void *smr_malloc( statusMessageReporting *smr, 105 void *smr_malloc( statusMessageReporting *smr, size_t size, int zero, char const *forItem, char const *file, int line, char const *function ); 106 void *smr_realloc( statusMessageReporting *smr 106 void *smr_realloc( statusMessageReporting *smr, void *pOld, size_t size, char const *forItem, char const *file, int line, char const *function ); 107 void *smr_freeMemory( void **p ); 107 void *smr_freeMemory( void **p ); 108 char *smr_allocateCopyString( statusMessageRep 108 char *smr_allocateCopyString( statusMessageReporting *smr, char const *s, char const *forItem, char const *file, int line, char const *function ); 109 char *smr_allocateCopyStringN( statusMessageRe 109 char *smr_allocateCopyStringN( statusMessageReporting *smr, char const *s, size_t n, char const *forItem, char const *file, int line, char const *function ); 110 110 111 #define smr_malloc2( smr, size, zero, forItem 111 #define smr_malloc2( smr, size, zero, forItem ) smr_malloc( smr, size, zero, forItem, __FILE__, __LINE__, __func__ ) 112 #define smr_realloc2( smr, old, size, forItem 112 #define smr_realloc2( smr, old, size, forItem ) smr_realloc( smr, old, size, forItem, __FILE__, __LINE__, __func__ ) 113 #define smr_allocateCopyString2( smr, s, forIt 113 #define smr_allocateCopyString2( smr, s, forItem ) smr_allocateCopyString( smr, s, forItem, __FILE__, __LINE__, __func__ ) 114 #define smr_allocateCopyStringN2( smr, s, n, f 114 #define smr_allocateCopyStringN2( smr, s, n, forItem ) smr_allocateCopyStringN( smr, s, n, forItem, __FILE__, __LINE__, __func__ ) 115 115 116 #define smr_setReportInfo2( smr, libraryID, co 116 #define smr_setReportInfo2( smr, libraryID, code, fmt, ... ) smr_setReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ ) 117 #define smr_setReportInfo2p( smr, libraryID, c 117 #define smr_setReportInfo2p( smr, libraryID, code, fmt ) smr_setReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt ) 118 #define smr_vsetReportInfo2( smr, libraryID, c 118 #define smr_vsetReportInfo2( smr, libraryID, code, fmt, args ) smr_vsetReportInfo( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args ) 119 #define smr_setReportWarning2( smr, libraryID, 119 #define smr_setReportWarning2( smr, libraryID, code, fmt, ... ) smr_setReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ ) 120 #define smr_setReportWarning2p( smr, libraryID 120 #define smr_setReportWarning2p( smr, libraryID, code, fmt ) smr_setReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt ) 121 #define smr_vsetReportWarning2( smr, libraryID 121 #define smr_vsetReportWarning2( smr, libraryID, code, fmt, args ) smr_vsetReportWarning( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args ) 122 #define smr_setReportError2( smr, libraryID, c 122 #define smr_setReportError2( smr, libraryID, code, fmt, ... ) smr_setReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ ) 123 #define smr_setReportError2p( smr, libraryID, 123 #define smr_setReportError2p( smr, libraryID, code, fmt ) smr_setReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt ) 124 #define smr_vsetReportError2( smr, libraryID, 124 #define smr_vsetReportError2( smr, libraryID, code, fmt, args ) smr_vsetReportError( smr, NULL, __FILE__, __LINE__, __func__, libraryID, code, fmt, args ) 125 125 126 #define smr_setReportInfo3( smr, userInterface 126 #define smr_setReportInfo3( smr, userInterface, libraryID, code, fmt, ... ) smr_setReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ ) 127 #define smr_setReportInfo3p( smr, userInterfac 127 #define smr_setReportInfo3p( smr, userInterface, libraryID, code, fmt ) smr_setReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt ) 128 #define smr_vsetReportInfo3( smr, userInterfac 128 #define smr_vsetReportInfo3( smr, userInterface, libraryID, code, fmt, args ) smr_vsetReportInfo( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args ) 129 #define smr_setReportWarning3( smr, userInterf 129 #define smr_setReportWarning3( smr, userInterface, libraryID, code, fmt, ... ) smr_setReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ ) 130 #define smr_setReportWarning3p( smr, userInter 130 #define smr_setReportWarning3p( smr, userInterface, libraryID, code, fmt ) smr_setReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt ) 131 #define smr_vsetReportWarning3( smr, userInter 131 #define smr_vsetReportWarning3( smr, userInterface, libraryID, code, fmt, args ) smr_vsetReportWarning( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args ) 132 #define smr_setReportError3( smr, userInterfac 132 #define smr_setReportError3( smr, userInterface, libraryID, code, fmt, ... ) smr_setReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, __VA_ARGS__ ) 133 #define smr_setReportError3p( smr, userInterfa 133 #define smr_setReportError3p( smr, userInterface, libraryID, code, fmt ) smr_setReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt ) 134 #define smr_vsetReportError3( smr, userInterfa 134 #define smr_vsetReportError3( smr, userInterface, libraryID, code, fmt, args ) smr_vsetReportError( smr, userInterface, __FILE__, __LINE__, __func__, libraryID, code, fmt, args ) 135 135 136 #if defined __cplusplus 136 #if defined __cplusplus 137 } 137 } 138 } 138 } 139 #endif 139 #endif 140 140 141 #endif /* End of statusMessageRep 141 #endif /* End of statusMessageReporting_h_included. */ 142 142