Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

cl_assert.cpp

Go to the documentation of this file.
00001 /*
00002         $Id: cl_assert.cpp,v 1.3 2000/10/24 01:46:59 plasmoid Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 */
00014 
00015 #include "Core/precomp.h"
00016 
00017 #include <stdlib.h>
00018 #include <iostream>
00019 #include <assert.h>
00020 
00021 #ifdef BORLAND
00022 #pragma hdrstop
00023 #endif
00024 
00025 #include "API/Core/System/cl_assert.h"
00026 
00027 std::list<CL_AssertListener*> CL_Assert::listeners;
00028 
00029 void CL_Assert::enable_channels(int /*channel_mask*/)
00030 {
00031         // not implemented yet!
00032 }
00033 
00034 void CL_Assert::die(bool a, const char *file, int line, const char *function, const char *assert_str)
00035 {
00036         if (a) return;
00037 
00038         if (function == NULL)
00039         {
00040                 std::cout << std::endl;
00041                 std::cout << "ClanLib Assert: " << file << ":" << line << std::endl;
00042                 std::cout << "                '" << assert_str << "' failed." << std::endl << std::endl;
00043         }
00044         else
00045         {
00046                 std::cout << std::endl;
00047                 std::cout << "ClanLib Assert: " << file << ":" << line << "," << std::endl;
00048                 std::cout << "                in function " << function << std::endl;
00049                 std::cout << "                '" << assert_str << "' failed." << std::endl << std::endl;
00050         }
00051         
00052         for (
00053                 std::list<CL_AssertListener*>::iterator it = listeners.begin();
00054                 it != listeners.end();
00055                 it++)
00056         {
00057                 (*it)->assert_occoured(file, line);
00058         }
00059         
00060         abort();
00061 }
00062 
00063 void CL_Assert::info(int channel, const char *text, const char *file, int line)
00064 {
00065         std::cout << "ClanLib Info(" << channel << "): " << text << " from " << file 
00066                 << ":" << line << std::endl;
00067 }
00068 
00069 void CL_Assert::add_listener(CL_AssertListener *listener)
00070 {
00071         listeners.push_back(listener);
00072 }
00073 
00074 void CL_Assert::remove_listener(CL_AssertListener *listener)
00075 {
00076         listeners.remove(listener);
00077 }

Generated at Wed Apr 4 19:53:59 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001