Equalizer
1.4.1
|
00001 00002 /* Copyright (c) 2011, Stefan Eilemann <eile@eyescale.ch> 00003 * 00004 * This library is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU Lesser General Public License version 2.1 as published 00006 * by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, but WITHOUT 00009 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00010 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00011 * details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this library; if not, write to the Free Software Foundation, Inc., 00015 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00016 */ 00017 00018 #ifndef EQ_EXCEPTION_H 00019 #define EQ_EXCEPTION_H 00020 00021 #include <co/exception.h> // base class 00022 00023 namespace eq 00024 { 00025 class Exception; 00026 std::ostream& operator << ( std::ostream& os, const Exception& e ); 00027 00029 class Exception : public co::Exception 00030 { 00031 public: 00032 enum Type 00033 { 00034 TIMEOUT_INPUTFRAME = co::Exception::CUSTOM, 00035 GL_ERROR, 00036 CUSTOM = co::Exception::CUSTOM + 20 // leave some room 00037 }; 00038 00040 Exception( const uint32_t type ) : co::Exception( type ) {} 00041 00042 virtual const char* what() const throw() 00043 { 00044 std::stringstream os; 00045 os << *this; 00046 return os.str().c_str(); 00047 } 00048 }; 00049 00050 inline std::ostream& operator << ( std::ostream& os, const Exception& e ) 00051 { 00052 switch( e.getType() ) 00053 { 00054 case Exception::TIMEOUT_INPUTFRAME: 00055 os << " Timeout waiting on input frame"; 00056 break; 00057 case Exception::GL_ERROR: 00058 os << " OpenGL Error"; 00059 break; 00060 default: 00061 os << static_cast< const co::Exception& >( e ); 00062 break; 00063 } 00064 return os; 00065 } 00066 } 00067 00068 #endif // EQ_EXCEPTION_H