orsa_error.cc

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 #include "orsa_error.h"
00026 
00027 #include <cstdio>
00028 #include <cassert>
00029 
00030 namespace orsa {
00031 
00032   using namespace std;
00033 
00034   void Debug::construct()
00035   {
00036     if (!m_instance) m_instance = new Debug;
00037   }
00038   Debug::Debug() :
00039     doTrace(false),
00040     doDefaultOutput(false)
00041   { }
00042   Debug::~Debug()
00043   {
00044     m_instance = 0;
00045   }
00046   
00047   Debug * Debug::obj() {
00048     assert(m_instance != 0);
00049     return m_instance;
00050   }
00051   void Debug::setDefaultOutput(bool d) {
00052     obj()->doDefaultOutput = d;
00053   }
00054   void Debug::set(const char *msg, const char *file, const int line) {
00055     fprintf(stderr, "ORSA[%s:%i] %s ", file, line, msg);
00056     doTrace = true;
00057   }
00058   void Debug::trace(const char *fmt, ...) {
00059     va_list ap;
00060     va_start(ap, fmt);
00061     if (doTrace) vtrace(fmt, ap);
00062     doTrace = false;
00063   }
00064   void Debug::vtrace(const char *fmt, va_list ap) {
00065     vfprintf(stderr, fmt, ap);
00066     fprintf(stderr, "\n");
00067   }
00068   
00069   Debug * Debug::m_instance = 0;
00070   
00071 } // namespace orsa
00072 

Generated on Wed May 30 13:04:52 2007 for liborsa by  doxygen 1.5.2