00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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 )
00030 {
00031
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 }