# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

# dirac_exception.h

Go to the documentation of this file.

    00001 /* ***** BEGIN LICENSE BLOCK *****
    00002 *
    00003 * $Id: dirac_exception.h,v 1.3 2007/03/19 16:18:59 asuraparaju Exp $ $Name: Dirac_0_7_0 $
    00004 *
    00005 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
    00006 *
    00007 * The contents of this file are subject to the Mozilla Public License
    00008 * Version 1.1 (the "License"); you may not use this file except in compliance
    00009 * with the License. You may obtain a copy of the License at
    00010 * http://www.mozilla.org/MPL/
    00011 *
    00012 * Software distributed under the License is distributed on an "AS IS" basis,
    00013 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
    00014 * the specific language governing rights and limitations under the License.
    00015 *
    00016 * The Original Code is BBC Research and Development code.
    00017 *
    00018 * The Initial Developer of the Original Code is the British Broadcasting
    00019 * Corporation.
    00020 * Portions created by the Initial Developer are Copyright (C) 2004.
    00021 * All Rights Reserved.
    00022 *
    00023 * Contributor(s): Andrew Kennedy (Original Author)
    00024 *
    00025 * Alternatively, the contents of this file may be used under the terms of
    00026 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
    00027 * Public License Version 2.1 (the "LGPL"), in which case the provisions of
    00028 * the GPL or the LGPL are applicable instead of those above. If you wish to
    00029 * allow use of your version of this file only under the terms of the either
    00030 * the GPL or LGPL and not to allow others to use your version of this file
    00031 * under the MPL, indicate your decision by deleting the provisions above
    00032 * and replace them with the notice and other provisions required by the GPL
    00033 * or LGPL. If you do not delete the provisions above, a recipient may use
    00034 * your version of this file under the terms of any one of the MPL, the GPL
    00035 * or the LGPL.
    00036 * ***** END LICENSE BLOCK ***** */
    00037
    00041 #ifndef DiracException_h
    00042 #define DiracException_h
    00043
    00044
    00045 // SYSTEM INCLUDES
    00046 //
    00047 #include <string>                           // has a string
    00048 #include <iostream>                          // has an ostringstream
    00049
    00050
    00051 namespace dirac {
    00052
    00058     enum DiracErrorCode {
    00059         ERR_UNSUPPORTED_STREAM_DATA=0,
    00060         ERR_END_OF_STREAM,
    00061         ERR_INVALID_VIDEO_FORMAT,
    00062         ERR_INVALID_CHROMA_FORMAT,
    00063         ERR_INVALID_FRAME_RATE,
    00064         ERR_INVALID_SIGNAL_RANGE,
    00065         ERR_INVALID_ASPECT_RATIO,
    00066         ERR_INVALID_VIDEO_DEPTH,
    00067         ERR_INVALID_MOTION_VECTOR_PRECISION
    00068
    00069     };
    00070
    00074     enum DiracSeverityCode {
    00075         SEVERITY_NO_ERROR=0,
    00076         SEVERITY_WARNING,
    00077         SEVERITY_FRAME_ERROR,
    00078         SEVERITY_ACCESSUNIT_ERROR,
    00079         SEVERITY_SEQUENCE_ERROR,
    00080         SEVERITY_TERMINATE
    00081     };
    00082
    00087 class DiracException
    00088 {
    00089 public:
    00090
    00091
    00099     DiracException(
    00100         const DiracErrorCode& errorCode,
    00101         const std::string& errorMessage,
    00102         const DiracSeverityCode& severityCode);
    00103
    00107     DiracException(
    00108         const DiracException& src);
    00109
    00113     virtual ~DiracException();
    00114
    00115
    00116 // OPERATORS
    00117
    00118
    00119 // ACCESS
    00120
    00126     DiracErrorCode GetErrorCode() const;
    00127
    00133     DiracSeverityCode GetSeverityCode() const;
    00134
    00140     std::string GetErrorMessage() const;
    00141
    00142
    00143
    00144 private:
    00145
    00146 // ATTRIBUTES
    00147
    00151     DiracErrorCode mErrorCode;
    00152
    00156     DiracSeverityCode mSeverityCode;
    00157
    00161     std::string mErrorMessage;
    00162
    00163
    00164
    00165 // UNIMPLEMENTED METHODS
    00166     DiracException& operator=(const DiracException&);
    00167
    00168 }; // class DiracException
    00169
    00170
    00171
    00172
    00173
    00174 // GLOBAL OPERATORS
    00175 //
    00176 std::ostream& operator<<(std::ostream& dst, const DiracException& exception);
    00177
    00178
    00179 // MACROS FOR LOGGING AND THROWING DIRAC EXCEPTIONS
    00180 //
    00181
    00182
    00186 #define DIRAC_LOG_EXCEPTION(exception)                           \
    00187     {                                                                   \
    00188        if(exception.GetSeverityCode()!=SEVERITY_NO_ERROR)       \
    00189             std::cerr << exception.GetErrorMessage();          \
    00190     }
    00191
    00195 #define DIRAC_THROW_EXCEPTION(arg1,arg2,arg3)                          \
    00196     {                                                                   \
    00197         DiracException exception(arg1,arg2, arg3);      \
    00198         DIRAC_LOG_EXCEPTION(exception)  \
    00199         throw exception;                        \
    00200     }
    00201
    00205 #define DIRAC_CATCH_AND_RETHROW()                                 \
    00206     catch (const DiracException& e) {                                     \
    00207         DiracException exception(e);           \
    00208         DIRAC_LOG_EXCEPTION(exception)\
    00209         throw exception;                     \
    00210     }
    00211
    00212 } // namespace Dirac
    00213
    00214 #endif // DiracException_h

© 2004 British Broadcasting Corporation. Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.