# 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.6 2008/01/31 11:25:16 tjdwave Exp $ $Name: Dirac_1_0_2 $
    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_PICTURE_RATE,
    00064         ERR_INVALID_SIGNAL_RANGE,
    00065         ERR_INVALID_PIXEL_ASPECT_RATIO,
    00066         ERR_INVALID_VIDEO_DEPTH,
    00067         ERR_INVALID_MOTION_VECTOR_PRECISION,
    00068         ERR_INVALID_INIT_DATA
    00069
    00070     };
    00071
    00075     enum DiracSeverityCode {
    00076         SEVERITY_NO_ERROR=0,
    00077         SEVERITY_WARNING,
    00078         SEVERITY_PICTURE_ERROR,
    00079         SEVERITY_ACCESSUNIT_ERROR,
    00080         SEVERITY_SEQUENCE_ERROR,
    00081         SEVERITY_TERMINATE
    00082     };
    00083
    00088 class DiracException
    00089 {
    00090 public:
    00091
    00092
    00100     DiracException(
    00101         const DiracErrorCode& errorCode,
    00102         const std::string& errorMessage,
    00103         const DiracSeverityCode& severityCode);
    00104
    00108     DiracException(
    00109         const DiracException& src);
    00110
    00114     virtual ~DiracException();
    00115
    00116
    00117 // OPERATORS
    00118
    00119
    00120 // ACCESS
    00121
    00127     DiracErrorCode GetErrorCode() const;
    00128
    00134     DiracSeverityCode GetSeverityCode() const;
    00135
    00141     std::string GetErrorMessage() const;
    00142
    00143
    00144
    00145 private:
    00146
    00147 // ATTRIBUTES
    00148
    00152     DiracErrorCode mErrorCode;
    00153
    00157     DiracSeverityCode mSeverityCode;
    00158
    00162     std::string mErrorMessage;
    00163
    00164
    00165
    00166 // UNIMPLEMENTED METHODS
    00167     DiracException& operator=(const DiracException&);
    00168
    00169 }; // class DiracException
    00170
    00171
    00172
    00173
    00174
    00175 // GLOBAL OPERATORS
    00176 //
    00177 std::ostream& operator<<(std::ostream& dst, const DiracException& exception);
    00178
    00179
    00180 // MACROS FOR LOGGING AND THROWING DIRAC EXCEPTIONS
    00181 //
    00182
    00183
    00187 #define DIRAC_LOG_EXCEPTION(exception)                           \
    00188     {                                                                   \
    00189        if(exception.GetSeverityCode()!=SEVERITY_NO_ERROR)       \
    00190             std::cerr << exception.GetErrorMessage();          \
    00191     }
    00192
    00196 #define DIRAC_THROW_EXCEPTION(arg1,arg2,arg3)                          \
    00197     {                                                                   \
    00198         DiracException exception(arg1,arg2, arg3);      \
    00199         DIRAC_LOG_EXCEPTION(exception)  \
    00200         throw exception;                        \
    00201     }
    00202
    00206 #define DIRAC_CATCH_AND_RETHROW()                                 \
    00207     catch (const DiracException& e) {                                     \
    00208         DiracException exception(e);           \
    00209         DIRAC_LOG_EXCEPTION(exception)\
    00210         throw exception;                     \
    00211     }
    00212
    00213 } // namespace Dirac
    00214
    00215 #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.