include/EDoc/PropogatingException.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 
00003    Copyright (C) 2007 by Brendon Costa
00004 
00005    This library is free software; you can redistribute it and/or modify 
00006    it under the terms of the "LGPL Like" License defined in the file COPYING 
00007    that should have been distributed along with this source.
00008 
00009    This library is distributed in the hope that it will be useful, 
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of 
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013    You should have received a copy of the "LGPL Like" License 
00014    along with this library; see the file COPYING. if not, it can be 
00015    obtained from the EDoc++ website: 
00016    http://edoc.sourceforge.net/license.html
00017 
00018 *******************************************************************************/
00019 #ifndef EDOC_PROPOGATINGEXCEPTION_H
00020 #define EDOC_PROPOGATINGEXCEPTION_H
00021 
00022 #include "EDoc/DictionarySpecific.h"
00023 #include "EDoc/Location.h"
00024 #include "EDoc/FunctionLoc.h"
00025 
00026 #include <list>
00027 #include <vector>
00028 
00029 namespace EDoc
00030 {
00031    class Exception;
00032    class PStack;
00033    
00034    //===========================================================================
00035    /** \brief Represents an exception that propogates out a function.
00036     *
00037     * Note this may also represent an exception that originates from the same
00038     * function (Originating exception) in which case the function in its "from"
00039     * field is the function that also holds the reference to this propogating
00040     * exception instance.
00041     */
00042    class PropogatingException : public DictionarySpecific
00043    {
00044    public:
00045 
00046       //------------------------------------------------------------------------
00047       /** \brief Constructs a new propogating exception object belonging to
00048        * the given Dictionary initialising with given values.
00049        */
00050       PropogatingException(Dictionary& dict_in, Exception* exception_in, 
00051          FunctionLoc& from_in);
00052 
00053       //------------------------------------------------------------------------
00054       /** \brief \brief See CodeBlock::CodeBlock(Dictionary* dict_in=NULL)
00055        */
00056       PropogatingException(Dictionary* dict_in = NULL);
00057 
00058       //------------------------------------------------------------------------
00059       /** \brief \brief See CodeBlock::CodeBlock(const CodeBlock& right)
00060        */
00061       PropogatingException(const PropogatingException& right);
00062 
00063       //------------------------------------------------------------------------
00064       /** \brief See CodeBlock::CodeBlock(const CodeBlock& right, 
00065        * Dictionary& dict_in)
00066        */
00067       PropogatingException(const PropogatingException& right, 
00068          Dictionary& dict_in);
00069 
00070       //------------------------------------------------------------------------
00071       /** \brief See CodeBlock::operator=()
00072        */
00073       PropogatingException& operator=(const PropogatingException& right);
00074 
00075       //------------------------------------------------------------------------
00076       /** \brief See DictionarySpecific::ReplaceReferences() 
00077        */
00078       virtual size_t ReplaceReferences(PStack& stack, 
00079          void* remove, void* replace);
00080 
00081       //------------------------------------------------------------------------
00082       /** \brief See DictionarySpecific::Print()
00083        */
00084       virtual std::ostream& Print(std::ostream& out, 
00085          std::string prefix="") const;
00086 
00087       //------------------------------------------------------------------------
00088       /** \brief See DictionarySpecific::Validate()
00089        */
00090       virtual void Validate(PStack& stack, const Dictionary& dict_in) const;
00091 
00092       //------------------------------------------------------------------------
00093       /** \brief Equivilance operator (Works across dictionaries).
00094        *
00095        * NOTE: Does not look at the rethrow list for equality.
00096        */
00097       bool operator==(const PropogatingException& right) const;
00098       
00099 
00100       //------------------------------------------------------------------------
00101       /** \brief Returns true if this exception is visible.
00102        *
00103        * This will only return true if all of the following are visible:
00104        *    - PropogatingException::visible - this instance
00105        *    - Exception::visible - The originating exception for this pe found
00106        *       in member: exception.
00107        *    - Type::visible - The type for the originating exception.
00108        *    .
00109        */
00110       bool IsVisible() const;
00111       
00112 
00113 
00114       //------------------------------------------------------------------------
00115       /** \brief A reference to the exception object that this propogating
00116        * exception originates from.
00117        */
00118       Exception* exception;
00119       
00120       //------------------------------------------------------------------------
00121       /** \brief Has two usages.
00122        *
00123        * Usages include:
00124        *    -# Exception propogates from another function. In this case this
00125        *       contains the reference to the function from which this exception
00126        *       comes and ALSO the source code Location where the call to that
00127        *       function is made.
00128        *    -# Exception originates from THIS function. This is when a function
00129        *       directly throws an exception with the C++ throws statement. In
00130        *       this case the function reference is NULL 
00131        *       and the Location is the location in source where the exception 
00132        *       is Dictionary::UNKNOWN_LOCATION
00133        *    .
00134        */
00135       FunctionLoc func;
00136 
00137       //------------------------------------------------------------------------
00138       /** \brief A list of Exception objects that indicate where in this
00139        * functions implementation that the current exception may have been
00140        * "re-thrown".
00141        *
00142        * List of the throw ... statements that have been used to rethrow this
00143        * exception.
00144        */
00145       std::list<Exception*> rethrows;
00146 
00147       //------------------------------------------------------------------------
00148       /** \brief True if this exception is propogated from a "possible" function
00149        * call and is not a definite propogation.
00150        */
00151       // @@@Brendon I dont think this is needed. I could just use func.possible
00152       // instead!
00153       bool possible;
00154 
00155       //------------------------------------------------------------------------
00156       /** \brief True if this exception is visible to the user or false if 
00157        * this exception will never be displayed to the user.
00158        *
00159        * This is used for suppressions.
00160        */
00161       bool visible;
00162 
00163 
00164       //------------------------------------------------------------------------
00165       // Data used to flag this propagating exception is the original 
00166       // substitution exception. This is omitted from certain processing.
00167       //------------------------------------------------------------------------
00168       /** \brief 
00169        */
00170       bool orig_subst;
00171 
00172       //------------------------------------------------------------------------
00173 
00174    };
00175    //===========================================================================
00176    typedef std::list<PropogatingException> PropExcepList;
00177    typedef std::list<PropogatingException*> PropExcepPList;
00178 
00179 }
00180 
00181 #endif // EDOC_PROPOGATINGEXCEPTION_H

Generated on Tue Jan 20 18:26:07 2009 for EDoc-0.2.1 by  doxygen 1.5.1