From: <de...@us...> - 2004-03-30 10:33:56
|
Update of /cvsroot/csp/APPLICATIONS/SimData/Include/SimData In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27724 Added Files: ExceptionBase.h ExceptionBase.i Log Message: see CHANGES.current --- NEW FILE: ExceptionBase.h --- /* SimData: Data Infrastructure for Simulations * Copyright (C) 2002 Mark Rose <tm...@st...> * * This file is part of SimData. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * @file BaseException.h * @brief Exception base classes and macros for creating new exceptions. */ #ifndef __SIMDATA_EXCEPTION_H__ #define __SIMDATA_EXCEPTION_H__ #include <string> #include <SimData/Export.h> #include <SimData/Namespace.h> // XXX this is a temporary hack to make // swig1.3.21 correctly parses this file #ifndef NAMESPACE_SIMDATA namespace simdata { #else NAMESPACE_SIMDATA #endif #ifndef SIMDATA_EXPORT #define SIMDATA_EXPORT #endif /** General exception base class with error reporting. * * @author Mark Rose <mr...@st...> */ class SIMDATA_EXPORT ExceptionBase { //: public std::runtime_error { std::string _msg; std::string _type; mutable bool dump; public: /** Create a new exception. * * @param type a string representing the type of error. * @param msg a string providing additional information about the error. */ ExceptionBase(std::string const &type="Exception", std::string const &msg=""); /** Copy constructor. */ ExceptionBase(ExceptionBase const &e); /** Destructor. * * If the exception has not cleared, it will display its * details to stderr on destruction. */ virtual ~ExceptionBase(); /** Get the string describing the error. */ std::string getMessage(); /** Get the string representing the type of error. */ std::string getType(); /** Get the full error message (type + message). */ std::string getError(); /** Append additional information to the error description. */ void appendMessage(std::string const &msg); /** Add (prepend) additional information to the error description. */ void addMessage(std::string const &msg); /** Reset the exception so that it will not print to stderr on * destruction. */ void clear(); /** Dump information about the exception to stderr. */ void details(); }; /** Base class for all SimData specific exceptions. */ class SIMDATA_EXPORT Exception: public ExceptionBase { public: Exception(std::string const &type="Exception", std::string const &msg=""): ExceptionBase(type, msg) { } }; #define SIMDATA_SUBEXCEPTION(a, b) \ class a: public b { \ public: \ a(std::string const &msg=""): \ b(#a, msg) { } \ a(std::string const &type, std::string const &msg): \ b(type, msg) { } \ }; #define SIMDATA_EXCEPTION(a) SIMDATA_SUBEXCEPTION(a, Exception) /** Exception for marshalling python exceptions through SWIG wrapers. * * @author Mark Rose <mr...@st...> */ SIMDATA_EXCEPTION(PythonException); #ifndef NAMESPACE_SIMDATA_END } #else NAMESPACE_SIMDATA_END #endif #endif // __SIMDATA_EXCEPTION_H__ --- NEW FILE: ExceptionBase.i --- /* SimDataCSP: Data Infrastructure for Simulations * Copyright (C) 2002 Mark Rose <tm...@st...> * * This file is part of SimDataCSP. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ %module ExceptionBase %{ #include "SimData/ExceptionBase.h" %} // suppress warning about undefined base class std::runtime_exception // not sure how to fix this cleanly, since std::runtime_exception has // a protected default constructor that causes the wrapper code to // break if swig knows about the class. %warnfilter(401) Exception; %include "SimData/ExceptionBase.h" |