Geant4 Cross Reference |
>> 1 /* >> 2 # <<BEGIN-copyright>> >> 3 # Copyright (c) 2010, Lawrence Livermore National Security, LLC. >> 4 # Produced at the Lawrence Livermore National Laboratory >> 5 # Written by Bret R. Beck, beck6@llnl.gov. >> 6 # CODE-461393 >> 7 # All rights reserved. >> 8 # >> 9 # This file is part of GIDI. For details, see nuclear.llnl.gov. >> 10 # Please also read the "Additional BSD Notice" at nuclear.llnl.gov. >> 11 # >> 12 # Redistribution and use in source and binary forms, with or without modification, >> 13 # are permitted provided that the following conditions are met: >> 14 # >> 15 # 1) Redistributions of source code must retain the above copyright notice, >> 16 # this list of conditions and the disclaimer below. >> 17 # 2) Redistributions in binary form must reproduce the above copyright notice, >> 18 # this list of conditions and the disclaimer (as noted below) in the >> 19 # documentation and/or other materials provided with the distribution. >> 20 # 3) Neither the name of the LLNS/LLNL nor the names of its contributors may be >> 21 # used to endorse or promote products derived from this software without >> 22 # specific prior written permission. >> 23 # >> 24 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY >> 25 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES >> 26 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT >> 27 # SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR >> 28 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >> 29 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS >> 30 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED >> 31 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >> 32 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, >> 33 # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >> 34 # <<END-copyright>> >> 35 */ 1 #ifndef statusMessageReporting_h_included 36 #ifndef statusMessageReporting_h_included 2 #define statusMessageReporting_h_included 37 #define statusMessageReporting_h_included 3 38 4 #include <stdio.h> 39 #include <stdio.h> 5 #include <stdarg.h> 40 #include <stdarg.h> 6 41 7 #ifdef WIN32 << 8 #define __func__ __FUNCTION__ << 9 #endif << 10 << 11 #if defined __cplusplus 42 #if defined __cplusplus 12 extern "C" { << 13 namespace GIDI { 43 namespace GIDI { >> 44 extern "C" { 14 #endif 45 #endif 15 46 16 #define smr_unknownID 0 << 47 #define smr_maximumPackageNameSize 256 17 #define smr_tooManyIDs 1 << 48 enum smr_status { smr_status_Ok, smr_status_Info, smr_status_Error, smr_status_Fatal }; 18 #define smr_invalidID 2 << 49 typedef int (*smr_userInterface)( void *userData, char **smr ); 19 #define smr_errnoID 3 << 20 #define smr_smrID 4 << 21 << 22 #define smr_maximumNumberOfRegisteredLibraries << 23 #define smr_maximumFileNameSize 1024 << 24 #define smr_codeNULL 0 << 25 #define smr_codeFileIO -1 << 26 #define smr_codeMemoryAllocating -2 << 27 enum smr_status { smr_status_Ok = 0, smr_statu << 28 typedef char *(*smr_userInterface)( void *user << 29 50 30 typedef struct statusMessageReport { << 51 typedef struct statusMessageReporting { 31 struct statusMessageReport *next; << 32 enum smr_status status; 52 enum smr_status status; 33 int libraryID; << 53 char packageName[smr_maximumPackageNameSize]; /* Do not free this. */ 34 int code; << 35 int line; 54 int line; 36 char fileName[smr_maximumFileNameSize+1]; << 55 int code; 37 char function[smr_maximumFileNameSize+1]; << 38 char *message; 56 char *message; /* User must free this when done. Should use smr_release. */ 39 } statusMessageReport; << 40 << 41 typedef struct statusMessageReporting { << 42 enum smr_status verbosity; << 43 int append; << 44 statusMessageReport report; << 45 } statusMessageReporting; 57 } statusMessageReporting; 46 58 47 int smr_setup( void ); << 59 int smr_initialize( statusMessageReporting *smr ); 48 int smr_cleanup( void ); << 60 int smr_release( statusMessageReporting *smr ); 49 << 61 int smr_setMessageInfo( statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt, ... ); 50 int smr_registerLibrary( char const *libraryNa << 62 int smr_vsetMessageInfo( statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt, va_list *args ); 51 int smr_numberOfRegisteredLibraries( void ); << 63 int smr_setMessageError( statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt, ... ); 52 char const *smr_getRegisteredLibrariesName( in << 64 int smr_vsetMessageError( statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt, va_list *args ); 53 << 65 char *smr_allocateFormatMessage( const char *fmt, ... ); 54 statusMessageReporting *smr_new( statusMessage << 66 char *smr_vallocateFormatMessage( const char *fmt, va_list *args ); 55 int smr_initialize( statusMessageReporting *sm << 56 void smr_release( statusMessageReporting *smr << 57 void *smr_free( statusMessageReporting **smr ) << 58 statusMessageReporting *smr_clone( statusMessa << 59 << 60 int smr_setReportInfo( statusMessageReporting << 61 int smr_vsetReportInfo( statusMessageReporting << 62 int smr_setReportWarning( statusMessageReport << 63 int smr_vsetReportWarning( statusMessageReport << 64 int smr_setReportError( statusMessageReportin << 65 int smr_vsetReportError( statusMessageReportin << 66 << 67 enum smr_status smr_highestStatus( statusMessa << 68 int smr_isOk( statusMessageReporting *smr ); 67 int smr_isOk( statusMessageReporting *smr ); 69 int smr_isInfo( statusMessageReporting *smr ); 68 int smr_isInfo( statusMessageReporting *smr ); 70 int smr_isWarning( statusMessageReporting *smr << 71 int smr_isError( statusMessageReporting *smr ) 69 int smr_isError( statusMessageReporting *smr ); 72 int smr_isWarningOrError( statusMessageReporti << 70 int smr_isFatal( statusMessageReporting *smr ); 73 << 71 const char *smr_getMessage( statusMessageReporting *smr ); 74 int smr_isReportOk( statusMessageReport *repor << 72 char *smr_getFullMessage( statusMessageReporting *smr ); 75 int smr_isReportInfo( statusMessageReport *rep << 73 void smr_print( statusMessageReporting *smr, FILE *f, int clear ); 76 int smr_isReportWarning( statusMessageReport * << 77 int smr_isReportError( statusMessageReport *re << 78 int smr_isReportWarningOrError( statusMessageR << 79 << 80 int smr_numberOfReports( statusMessageReportin << 81 statusMessageReport *smr_firstReport( statusMe << 82 statusMessageReport *smr_nextReport( statusMes << 83 << 84 enum smr_status smr_getVerbosity( statusMessag << 85 int smr_getAppend( statusMessageReporting *smr << 86 << 87 int smr_getLibraryID( statusMessageReport *rep << 88 int smr_getCode( statusMessageReport *report ) << 89 int smr_getLine( statusMessageReport *report ) << 90 char const *smr_getFile( statusMessageReport * << 91 char const *smr_getFunction( statusMessageRepo << 92 char const *smr_getMessage( statusMessageRepor << 93 char *smr_copyMessage( statusMessageReport *re << 94 char *smr_copyFullMessage( statusMessageReport << 95 void smr_print( statusMessageReporting *smr, i << 96 void smr_write( statusMessageReporting *smr, F << 97 void smr_reportPrint( statusMessageReport *rep << 98 void smr_reportWrite( statusMessageReport *rep << 99 << 100 char const *smr_statusToString( enum smr_statu << 101 << 102 char *smr_allocateFormatMessage( char const *f << 103 char *smr_vallocateFormatMessage( char const * << 104 << 105 void *smr_malloc( statusMessageReporting *smr, << 106 void *smr_realloc( statusMessageReporting *smr << 107 void *smr_freeMemory( void **p ); << 108 char *smr_allocateCopyString( statusMessageRep << 109 char *smr_allocateCopyStringN( statusMessageRe << 110 << 111 #define smr_malloc2( smr, size, zero, forItem << 112 #define smr_realloc2( smr, old, size, forItem << 113 #define smr_allocateCopyString2( smr, s, forIt << 114 #define smr_allocateCopyStringN2( smr, s, n, f << 115 << 116 #define smr_setReportInfo2( smr, libraryID, co << 117 #define smr_setReportInfo2p( smr, libraryID, c << 118 #define smr_vsetReportInfo2( smr, libraryID, c << 119 #define smr_setReportWarning2( smr, libraryID, << 120 #define smr_setReportWarning2p( smr, libraryID << 121 #define smr_vsetReportWarning2( smr, libraryID << 122 #define smr_setReportError2( smr, libraryID, c << 123 #define smr_setReportError2p( smr, libraryID, << 124 #define smr_vsetReportError2( smr, libraryID, << 125 << 126 #define smr_setReportInfo3( smr, userInterface << 127 #define smr_setReportInfo3p( smr, userInterfac << 128 #define smr_vsetReportInfo3( smr, userInterfac << 129 #define smr_setReportWarning3( smr, userInterf << 130 #define smr_setReportWarning3p( smr, userInter << 131 #define smr_vsetReportWarning3( smr, userInter << 132 #define smr_setReportError3( smr, userInterfac << 133 #define smr_setReportError3p( smr, userInterfa << 134 #define smr_vsetReportError3( smr, userInterfa << 135 74 136 #if defined __cplusplus 75 #if defined __cplusplus 137 } 76 } 138 } 77 } 139 #endif 78 #endif 140 79 141 #endif /* End of statusMessageRep 80 #endif /* End of statusMessageReporting_h_included. */ 142 81