orsa_error.h

Go to the documentation of this file.
00001 /* 
00002    ORSA - Orbit Reconstruction, Simulation and Analysis
00003    Copyright (C) 2002-2004 Pasquale Tricarico
00004    
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License
00007    as published by the Free Software Foundation; either version 2
00008    of the License, or (at your option) any later version.
00009    
00010    As a special exception, Pasquale Tricarico gives permission to
00011    link this program with Qt commercial edition, and distribute the
00012    resulting executable, without including the source code for the Qt
00013    commercial edition in the source distribution.
00014    
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019    
00020    You should have received a copy of the GNU General Public License
00021    along with this program; if not, write to the Free Software
00022    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 */
00024 
00025 #ifndef _ORSA_ERROR_H_
00026 #define _ORSA_ERROR_H_
00027 
00028 #include <cstdarg>
00029 
00030 namespace orsa {
00031   
00032   class Debug {
00033   public:
00034     static void construct();
00035     virtual ~Debug();
00036     virtual void set(const char *msg, const char *file, const int line);
00037     void trace(const char *fmt, ...); // do not make this one virtual
00038     static void setDefaultOutput(bool);
00039     static Debug * obj();
00040   protected:
00041     Debug();
00042     virtual void vtrace(const char *fmt, std::va_list list);   
00043     static Debug * m_instance;
00044     bool doTrace;
00045     bool doDefaultOutput;
00046   };
00047 
00048 } // namespace orsa
00049 
00050 // Note: do not change those to variadic macros. Believe it or not, some
00051 // compilers just won't dig it. Besides, the code below *does* work properly
00052 // when used like
00053 // if (condition) ORSA_DEBUG("blublah");
00054 #define ORSA_DEBUG          orsa::Debug::obj()->set("Debug:",__FILE__,__LINE__); orsa::Debug::obj()->trace
00055 #define ORSA_ERROR          orsa::Debug::obj()->set("Error:",__FILE__,__LINE__); orsa::Debug::obj()->trace
00056 #define ORSA_WARNING        orsa::Debug::obj()->set("Warning:",__FILE__,__LINE__); orsa::Debug::obj()->trace
00057 #define ORSA_DOMAIN_ERROR   orsa::Debug::obj()->set("Domain Error:",__FILE__,__LINE__); orsa::Debug::obj()->trace
00058 #define ORSA_LOGIC_ERROR    orsa::Debug::obj()->set("Logic Error (this shouldn't happen):",__FILE__,__LINE__); orsa::Debug::obj()->trace
00059 #define ORSA_LOGIC_WARNING  orsa::Debug::obj()->set("Logic Warning (possibly unimplemented case):",__FILE__,__LINE__); orsa::Debug::obj()->trace
00060   
00061 #endif // _ORSA_ERROR_H_

Generated on Fri Nov 3 20:37:41 2006 for liborsa by  doxygen 1.4.7