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

/ray/src/lib/message/test_message.cc

Go to the documentation of this file.
00001 /*
00002  * lib/message/test_message.cc
00003  * 
00004  * Test message handling system. 
00005  * 
00006  * Copyright (c) 2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 
00007  * 
00008  * This file may be distributed and/or modified under the terms of the 
00009  * GNU General Public License version 2 as published by the Free Software 
00010  * Foundation. (See COPYING.GPL for details.)
00011  * 
00012  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014  * 
00015  */
00016 
00017 // This should be enough for just reporting messages: 
00018 #include "message.h"
00019 
00020 enum MyDebugMessageType
00021 {
00022     DM_NotDisplayed=0x00000010,
00023     DM_Displayed=   0x00000020,
00024 };
00025 
00026 // For convenience...
00027 inline Message::Type operator|(Message::Type a,MyDebugMessageType b)
00028     {  return((Message::Type)(int(a)|int(b)));  }
00029 
00030 
00031 static int ReportSomeMessages()
00032 {
00033     Error("this is an error     ( <-- test of message system )");
00034     Warning("And this is a warning. You have been warned...");
00035     Debug(DM_NotDisplayed,"This message should NOT be displayed.");
00036     Debug(DM_Displayed,"This message SHOULD be displayed.");
00037     
00038     // We should as well test errors with locations but that would 
00039     // require to set up a location archive, and so on...
00040 }
00041 
00042 
00043 // This is needed for the handler and manager: 
00044 #include "manager.h"
00045 #include "handler_console.h"
00046 
00047 #include <stdio.h>
00048 
00049 
00050 int main()
00051 {
00052     fprintf(stderr,"TESTING message system...\n");
00053     
00054     {
00055         fprintf(stderr,"Initializing message manager: ");
00056         MessageManager::init();
00057         fprintf(stderr,"Done\n");
00058         
00059         fprintf(stderr,"Initializing message handler: ");
00060         MessageHandler_Console cons_hdl(
00061             Message::MTAllNonDebug | DM_Displayed,
00062             /*use_color=*/1);
00063         fprintf(stderr,"Done\n");
00064         
00065         // Let's play...
00066         ReportSomeMessages();
00067         
00068         fprintf(stderr,"Cleanup message manager: ");
00069         MessageManager::cleanup();
00070         fprintf(stderr,"Done\n");
00071     }
00072     
00073     return(0);
00074 }

Generated on Sat Feb 19 22:33:45 2005 for Ray by doxygen 1.3.5