/* * Copyright (c) ICG. All rights reserved. * See copyright.txt for more information. * * Institute for Computer Graphics and Vision * Graz, University of Technology / Austria * * * This software is distributed WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the above copyright notices for more information. * * * Project : MIPItkProjects * Module : Evaluation * Class : $RCSfile$ * Language : C++ * Description : * * Author : Martin Urschler * EMail : urschler@icg.tu-graz.ac.at * Date : $Date: $ * Version : $Revision: $ * Full Id : $Id: $ * */ #ifndef __MLEXCEPTION_HPP__ #define __MLEXCEPTION_HPP__ #ifdef WIN32 #pragma warning(disable:4786) #pragma warning(disable:4290) #endif // WIN32 #include #include #include #include #include class MLException : public std::exception { public: explicit MLException( const std::string& msg ) : msg_(msg) { } explicit MLException( const std::ostringstream& msg ) : msg_(msg.str()) { } virtual ~MLException() throw() {} MLException( const std::string& class_name, const std::string& member, const std::ostringstream& msg ) { msg_ = class_name + "::" + member + ": " + msg.str(); } MLException( const std::string& class_name, const std::string& member, const std::string& msg ) { msg_ = class_name + "::" + member + ": " + msg; } virtual void print() const { std::cout << "Exception (" << typeid(*this).name() << ") occurred! " << std::endl; std::cout << msg_ << std::endl; } protected: std::string msg_; }; #ifdef QT_SUPPORT #include class MLQException : public MLException { public: explicit MLQException( const std::string& msg ) : MLException(msg) { } MLQException( const std::string& class_name, const std::string& member, const std::string& msg ) : MLException(class_name, member, msg) { } virtual void print() const { QMessageBox::critical( 0, "Termination information", QString("Exception <") + typeid(*this).name() + QString("> occurred! \n") + msg_.c_str() ); } }; #endif // QT_SUPPORT #endif // __MLEXCEPTION_HPP__