User Manual, Developers Guide and API Documentation

Exception.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2007
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 16, D-52074 Aachen, Germany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #ifndef WNS_EXCEPTION_HPP
00029 #define WNS_EXCEPTION_HPP
00030 
00031 #include <WNS/IOutputStreamable.hpp>
00032 #include <WNS/Backtrace.hpp>
00033 
00034 #include <sstream>
00035 #include <exception>
00036 
00037 namespace wns {
00048     class Exception :
00049         virtual public wns::IOutputStreamable,
00050         virtual public std::exception
00051     {
00052     public:
00056         Exception();
00057 
00061         explicit
00062         Exception(const std::string& s);
00063 
00064         // Default c'tor is ok
00065 
00069         virtual
00070         ~Exception() throw();
00071 
00075         virtual const char*
00076         what() const throw();
00077 
00087         const Backtrace&
00088         getBacktrace() const;
00089 
00095         template <typename T>
00096         friend Exception&
00097         operator <<(Exception& e, const T& t)
00098         {
00099             std::stringstream ss;
00100             ss << t;
00101             e.reason_.append(ss.str());
00102             return e;
00103         }
00104 
00105     protected:
00109         virtual std::string
00110         doToString() const;
00111 
00112     private:
00116         std::string reason_;
00117 
00122         Backtrace backtrace_;
00123     };
00124 }
00125 #endif  // NOT defined WNS_EXCEPTION_HPP

Generated on Wed May 23 03:31:34 2012 for openWNS by  doxygen 1.5.5