00001 00002 // 00003 // This file is part of the MADELINE 2 program 00004 // written by Edward H. Trager and Ritu Khanna 00005 // Copyright (c) 2005 by the 00006 // Regents of the University of Michigan. 00007 // All Rights Reserved. 00008 // 00009 // The latest version of this program is available from: 00010 // 00011 // http://eyegene.ophthy.med.umich.edu/madeline/ 00012 // 00013 // Released under the GNU General Public License. 00014 // A copy of the GPL is included in the distribution 00015 // package of this software, or see: 00016 // 00017 // http://www.gnu.org/copyleft/ 00018 // 00019 // ... for licensing details. 00020 // 00022 // 00023 // 2005.03.14.ET -- Originally written as Warning class 00024 // 2006.12.18.ET -- Reimplemented as Message base class 00025 00026 // 00027 // Message.h 00028 // 00029 00030 00031 #ifndef MESSAGE_INCLUDED 00032 #define MESSAGE_INCLUDED 00033 00034 #include <iostream> 00035 #include <libintl.h> 00036 #include <locale.h> 00037 #include <stdio.h> 00038 #include <stdarg.h> 00039 #include "BufferSizes.h" 00040 #include <string> 00041 00042 // Loader class: 00043 class MessageInitializer; 00044 00045 class Message{ 00046 00047 friend class MessageInitializer; 00048 00049 private: 00050 00051 static const char *_defaultSalutation; 00052 00053 // initialize: 00054 static void _initialize( void ); 00055 00056 protected: 00057 00058 const char *_salutation; 00059 const char *_methodName; 00060 char _message[GENERAL_STRING_BUFFER_SIZE]; 00061 bool _truncated; 00062 00063 public: 00064 00065 // Constructors: 00066 Message(){}; 00067 Message(const char *const methodName, const char *format,...); 00068 00069 // print: 00070 void print(void); 00071 00072 // get: 00073 std::string get(void) const; 00074 }; 00075 00076 // 00077 // MessageInitializer loader class: 00078 // 00079 class MessageInitializer{ 00080 00081 static MessageInitializer messageInitializer; 00082 MessageInitializer(){ 00083 Message::_initialize(); 00084 } 00085 00086 }; 00087 00088 #endif 00089