include/EDoc/StdErrNotifier.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_STDERRNOTIFIER_H
00020 #define EDOC_STDERRNOTIFIER_H
00021 
00022 #include "EDoc/stdint.h"
00023 #include "EDoc/NotificationIFace.h"
00024 
00025 namespace EDoc
00026 {
00027    //===========================================================================
00028    /** \brief Standard implementation of NotificationIFace that notifies users
00029     * of events through the stderr stream.
00030     *
00031     * This will display events in a format that should be simple for automated
00032     * parsers to extract infromation from.
00033     *
00034     * Note: This does not display events as they occur, but queues them in a
00035     * list that can be displayed at a later time. This is to avoid events being
00036     * intermixed with progress bar indication data. All events will be displayed
00037     * by calling PrintAll()
00038     */
00039    class StdErrNotifier : public NotificationIFace
00040    {
00041    public:
00042 
00043       //------------------------------------------------------------------------
00044       /** \brief Constructor.
00045        *
00046        * Adds all the standard notification events found in events.inc upon
00047        * construction.
00048        */
00049       StdErrNotifier(bool show_details_in);
00050       
00051       //------------------------------------------------------------------------
00052       /** \brief Destructor.
00053        */
00054       virtual ~StdErrNotifier();
00055       
00056       //------------------------------------------------------------------------
00057       /** \brief Registers a new event type.
00058        */
00059       void RegisterEvent(EventType type, EventCode code, std::string name, 
00060          std::string summary);
00061 
00062       //------------------------------------------------------------------------
00063       /** \brief Prints an event.
00064        */
00065       void PrintEvent(EventCode code, const std::string& message);
00066 
00067       //------------------------------------------------------------------------
00068       /** \brief See NotificationIFace::Event()
00069        */
00070       virtual void Event(EventCode code, 
00071          const char* source_file, 
00072          unsigned int source_line, 
00073          std::string message,
00074          const Function* function, 
00075          const File* file, 
00076          uint32_t line, 
00077          const File* rfile, 
00078          uint32_t rline, 
00079          const Type* type, 
00080          const PropogatingException* prop_exc,
00081          const FunctionType* function_type,
00082          const char* extra);
00083 
00084       //------------------------------------------------------------------------
00085       /** \brief Displays current configuration.
00086        */
00087       std::ostream& Print(std::ostream& out) const;
00088       
00089       //------------------------------------------------------------------------
00090       /** \brief Prints all currently queued events to stderr.
00091        */
00092       void PrintAll();
00093       
00094       //------------------------------------------------------------------------
00095       /** \brief Returns the total number of error type events encountered.
00096        */
00097       uint32_t GetTotalErrorCount() const
00098       {
00099          return error_count;
00100       }
00101 
00102       //------------------------------------------------------------------------
00103 
00104    private:
00105       
00106       //------------------------------------------------------------------------
00107       /** \brief Temporary structure for storing events for display at alater
00108        * date.
00109        */
00110       struct Details
00111       {
00112          //---------------------------------------------------------------------
00113          /** \brief Constructor.
00114           */
00115          Details() {}
00116          
00117          //---------------------------------------------------------------------
00118          /** \brief Constructor.
00119           */
00120          Details(EventType type_in, 
00121                std::string name_in, 
00122                std::string summary_in) :
00123 
00124             type(type_in),
00125             name(name_in),
00126             summary(summary_in)
00127          {}
00128          
00129          //---------------------------------------------------------------------
00130          /** \brief The type of the event that occured.
00131           */
00132          EventType type;
00133 
00134          //---------------------------------------------------------------------
00135          /** \brief The name of the event that occured.
00136           */
00137          std::string name;
00138 
00139          //---------------------------------------------------------------------
00140          /** \brief A summary of the event.
00141           */
00142          std::string summary;
00143 
00144          //---------------------------------------------------------------------
00145       };
00146       
00147       //------------------------------------------------------------------------
00148       /** \brief Lists all possible event types that may occur.
00149        */
00150       std::map<EventCode, Details> event_types;
00151 
00152       //------------------------------------------------------------------------
00153       /** \brief A list of enqueued events that have yet to be displayed.
00154        */
00155       std::list<std::string> messages;
00156 
00157       //------------------------------------------------------------------------
00158       /** \brief If true display details about notification events.
00159        */
00160       bool show_details;
00161 
00162       //------------------------------------------------------------------------
00163       /** \brief Stores statistics for the number of the events were errors.
00164        */
00165       uint32_t error_count;
00166 
00167       //------------------------------------------------------------------------
00168 
00169    };
00170    //===========================================================================
00171 }
00172 
00173 #endif // EDOC_STDERRNOTIFIER_H

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