Equalizer  1.2.1
eq/client/exception.h
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             CUSTOM              = co::Exception::CUSTOM + 20 // leave some room
00036         };
00037 
00039         Exception( const uint32_t type ) : co::Exception( type ) {}
00040 
00041         virtual const char* what() const throw() 
00042         { 
00043             std::stringstream os;
00044             os << *this;
00045             return os.str().c_str(); 
00046         }
00047     };
00048 
00049     inline std::ostream& operator << ( std::ostream& os, const Exception& e )
00050     {
00051         switch( e.getType() )
00052         {
00053           case Exception::TIMEOUT_INPUTFRAME:
00054               os << " Timeout waiting on input frame";
00055               break;
00056           default:
00057               os << static_cast< const co::Exception& >( e );
00058               break;
00059         }
00060         return os;
00061     }
00062 }
00063 
00064 #endif // EQ_EXCEPTION_H
Generated on Fri Jun 8 2012 15:44:30 for Equalizer 1.2.1 by  doxygen 1.8.0