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

/ray/src/lib/message/manager.h

Go to the documentation of this file.
00001 /*
00002  * lib/message/manager.h
00003  * 
00004  * Message handling "system" for errors, warnings and verbose messages. 
00005  * Header for message manager class. 
00006  * 
00007  * Copyright (c) 2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 
00008  * 
00009  * This file may be distributed and/or modified under the terms of the 
00010  * GNU General Public License version 2 as published by the Free Software 
00011  * Foundation. (See COPYING.GPL for details.)
00012  * 
00013  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00014  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00015  * 
00016  */
00017 
00018 #ifndef _LIB_MESSAGE_MANAGER_H_
00019 #define _LIB_MESSAGE_MANAGER_H_ 1
00020 
00042 #include <lib/sconfig.h>    /* MUST be first */
00043 
00044 #include <lib/tl/linkedlist.h>
00045 #include <lib/threads/mutex.h>
00046 #include <lib/threads/atomic.h>
00047 
00048 #include <lib/message/handler.h>
00049 
00050 // As defined in handler.h: 
00051 //class MessageHandler;
00052 
00067 class MessageManager  // not C++-safe
00068 {
00069     private:
00071         static MessageManager *manager;
00072         
00073     private:
00078         LinkedList<MessageHandler> hdl_list;
00081         RecursiveMutex main_mutex;
00082         
00086         AtomicInt type_mask;
00087         
00089         bool exit_on_fatal;
00090         
00092         inline bool _IsRequestedType(Message::Type t) const
00093             {  return(type_mask.val() & t);  }
00094         
00096         void _PostMessage(const Message &m);
00097         
00099         void _RecomputeMTMask();   // (NOT mutex-protected!)
00100         
00102         void _SelectMessageTypes(MessageHandler *hdl,Message::Type t);
00104         void _RegisterHandler(MessageHandler *hdl);
00106         void _UnregisterHandler(MessageHandler *hdl);
00107         
00109         MessageManager(const MessageManager &);
00110         void operator=(const MessageManager &);
00112         MessageManager();
00113     public:
00114         ~MessageManager();
00115         
00125         static void init();
00126         
00132         static void cleanup();
00133         
00141         static inline void PostMessage(const Message &m)
00142             {  return(manager->_PostMessage(m));  }
00143         
00151         static inline void DoExitOnFatal(bool yes_no)
00152             {  if(manager) manager->exit_on_fatal=yes_no;  }
00153         
00158         static inline void SelectMessageTypes(MessageHandler *hdl,
00159             Message::Type mask)
00160             {  manager->_SelectMessageTypes(hdl,mask);  }
00161         
00163         static inline bool IsRequestedType(Message::Type t)
00164             {  return(manager ? manager->_IsRequestedType(t) : 0);  }
00165         
00170         static inline void RegisterHandler(MessageHandler *hdl)
00171             {  manager->_RegisterHandler(hdl);  }
00172         
00177         static inline void UnregisterHandler(MessageHandler *hdl)
00178             {  manager->_UnregisterHandler(hdl);  }
00179 };
00180 
00181 #endif  /* _LIB_MESSAGE_MANAGER_H_ */
00182 

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