uerror.hpp

00001 /* ==================================================== ======== ======= *
00002 *
00003 *  uerror.hpp
00004 *  Ubit Project
00005 *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006 *  (C) 1999-2006 Eric Lecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00007 *
00008 * ***********************************************************************
00009 * COPYRIGHT NOTICE :
00010 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
00011 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00012 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
00013 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
00014 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016 * ***********************************************************************
00017 * ==================================================== [(c)Elc] ======= *
00018 * ==================================================== ======== ======= */
00019 
00020 #ifndef _uerror_hpp_
00021 #define _uerror_hpp_
00022 //pragma ident  "@(#)uerror.hpp ubit:05.05.00"
00023 #include <ubit/ubrick.hpp>
00024 namespace ubit {
00025 
00026 class ULogHandler;
00027 
00028 /* ==================================================== ===== ======= */
00032 class UError {
00033 public:
00034   UError();
00035   UError(const char* location, const char* message);
00040   virtual ~UError();
00041 
00042   virtual const UStr& errname() const;
00044   
00045   virtual UStr& location() {return *plocation;}
00046   virtual const UStr& location() const {return *plocation;}
00047 
00048   virtual UStr& message()  {return *pmessage;}
00049   virtual const UStr& message() const {return *pmessage;}
00050 
00051 protected:
00052   uptr<UStr> plocation, pmessage;
00053 };
00054 
00055 /* ==================================================== ===== ======= */
00058 struct UWarning : public UError {
00059   UWarning() {}
00060   UWarning(const char* loc, const char* msg) : UError(loc, msg) {}
00061   
00062   virtual const UStr& errname() const;
00064 };
00065 
00068 struct UFatalError : public UError {
00069   UFatalError() {}
00070   UFatalError(const char* loc, const char* msg) : UError(loc, msg) {}
00071   
00072   virtual const UStr& errname() const;
00074 };
00075 
00078 struct UInternalError : public UError {
00079   UInternalError() {}
00080   UInternalError(const char* loc, const char* msg) : UError(loc, msg) {}
00081 
00082   virtual const UStr& errname() const;
00084 };
00085 
00086 /* ==================================================== ===== ======= */
00089 class UErrorLog {
00090 public: 
00091   UErrorLog();
00092   virtual ~UErrorLog();
00093   
00094   virtual UErrorLog& operator<<(const UError&);
00095   //virtual ULog& operator<<(const UArgs&);
00096 
00097   virtual void setHandler(ULogHandler&);
00098   virtual ULogHandler& getHandler();
00099   
00100 private:
00101   ULogHandler* handler;
00102 };
00103 
00104 /* ==================================================== ===== ======= */
00107 class ULogHandler {
00108 public: 
00109   ULogHandler();
00110   virtual ~ULogHandler();
00111   
00112   virtual void processError(const UError&);
00118   virtual void printError(const UError&);
00119 };
00120 
00121 }
00122 #endif
00123 /* ================================================== [TheEnd] ======= */

Generated on Mon Jan 29 00:20:38 2007 for Ubit by  doxygen 1.4.7