MessageLogMgr.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef MESSAGELOGMGR_H
00011 #define MESSAGELOGMGR_H
00012 
00013 #include "Service.h"
00014 #include "Subject.h"
00015 
00016 #include <string>
00017 #include <vector>
00018 
00019 class MessageLog;
00020 
00021 /**
00022  *  Manages reporting of status messages to a log file.
00023  *
00024  *  One technique of reporting messages to users is to generate a log file based on
00025  *  various processing events.  This capability exists in the form of message logs
00026  *  that are maintained by the MessageLogMgr.  %Message logs are created according to
00027  *  a unique name, and there is no limit to the number of message logs for a
00028  *  session.  All message logs are saved in a file on disk in a common message log
00029  *  directory set that is initially specified in the user options.
00030  *
00031  *  The MessageLogMgr class maintains the creation and management of each log and
00032  *  provides an interface to add a message to a single log.
00033  *
00034  *  A default log is automatically created for each user session.  All
00035  *  messages with the reporting level of SILENT are also written to the session
00036  *  log.  The session log has the filename "username_session.log", where "username"
00037  *  is the username of the person currently logged into the system.
00038  *
00039  *  This subclass of Subject will notify upon the following conditions:
00040  *  - The message log path is changed as a result of calling setPath().
00041  *  - A new MessageLog is created as a result of calling createLog().
00042  *  - A log is removed when a session is closed.
00043  *  - The MessageLogMgr is destroyed.  The notification occurs before the
00044  *    message logs are deleted allowing observers to access the logs during
00045  *    cleanup.
00046  *  - Everything else documented in Subject.
00047  *
00048  *  @see     MessageReportingLevel
00049  */
00050 class MessageLogMgr : public Subject
00051 {
00052 public:
00053    /**
00054     *  Emitted when the message log path changes with boost::any<std::string>
00055     *  containing the new path.
00056     */
00057    SIGNAL_METHOD(MessageLogMgr, LogPathChanged)
00058 
00059    /**
00060     *  Emitted when a new log is created by calling createLog() with
00061     *  boost::any<\link MessageLog \endlink*> containing a pointer to the
00062     *  created log.
00063     */
00064    SIGNAL_METHOD(MessageLogMgr, LogAdded)
00065 
00066    /**
00067     *  Emitted when a log is removed while closing a session with
00068     *  boost::any<\link MessageLog \endlink*> containing a pointer to the
00069     *  removed log.
00070     */
00071    SIGNAL_METHOD(MessageLogMgr, LogRemoved)
00072 
00073    /**
00074     *  Sets a new path for message logs.
00075     *
00076     *  This method sets a new directory to which all message logs are written.  This
00077     *  should not normally be called, since the message log path is set by the user
00078     *  options.
00079     *
00080     *  @param   path
00081     *           The new message log path.
00082     */
00083    virtual void setPath(const std::string& path) = 0;
00084 
00085    /**
00086     *  Creates a new log with a given name.
00087     *
00088     *  @param   logName
00089     *           The name of the new log to create.
00090     *
00091     *  @return  A pointer to the created log.  A \c NULL pointer is returned
00092     *           if a log with the given name already exists.
00093     *
00094     *  @see     getLog(const std::string&) const, getLog(), getLogs()
00095     */
00096    virtual MessageLog* createLog(const std::string& logName) = 0;
00097 
00098    /**
00099     *  Gets a handle to the specified log.
00100     *
00101     *  @param   logName
00102     *           The name of the desired log.
00103     *
00104     *  @return  A pointer to the specified log.
00105     *
00106     *  @see     getLog(), getLogs(), createLog()
00107     */
00108    virtual MessageLog* getLog(const std::string& logName) const = 0;
00109 
00110    /**
00111     *  Gets a handle to log associated with the current session.
00112     *
00113     *  @return  A pointer to the current log.
00114     *
00115     *  @see     getLog(const std::string&) const, getLogs(), createLog()
00116     */
00117    virtual MessageLog* getLog() const = 0;
00118 
00119    /**
00120     *  Gets handles for all managed logs.
00121     *
00122     *  @return  A vector of pointers to all managed logs.
00123     *
00124     *  @see     getLog(const std::string&) const, getLog(), createLog()
00125     */
00126    virtual std::vector<MessageLog*> getLogs() const = 0;
00127 
00128 protected:
00129    /**
00130     * This will be cleaned up during application close.  Plug-ins do not
00131     * need to destroy it.
00132     */
00133    virtual ~MessageLogMgr() {}
00134 };
00135 
00136 #endif

Software Development Kit - Opticks 4.9.0 Build 16218