00001
00002 #ifndef messageMANAGER_H
00003 #define messageMANAGER_H 1
00004
00005 #include <string>
00006 #include <stdlib.h>
00007 #include <iostream>
00008 #include <fstream>
00009
00010 #include "Event/serviceI.h"
00011 00013
00014 <ul>
00015 <li> It defines an ostream& output (method \c out()) where to send the messages. The
00016 output can be a file or the screen (std::cout). The method \c open() define and open
00017 a file to send the messages to.
00018 <li> A collection of message() methods allows a external class to send a message
00019 (either a string or a string + a double value) to the ostream output. The messageManager
00020 has a enumeration LEVEL (from messageBase) that defines which are the messages that
00021 the messageManager will process out, via the \c acceptLevel() method. The message()
00022 methods are inherits and overwriten from messageVI.
00023 <li> It has a protected server with the list of classes that can be served with
00024 messages (that inherit from messageVI). the method \c writeOut(name) executes the
00025 \c writeOut() method of the object with name stored in the server.
00026 </ul>
00027 */
00028
00029
00030
00031
00032
00033 class messageManager : public serviceI
00034
00035 {
00036 friend class messageVI;
00037
00038 public:
00039
00041 messageManager();
00043 virtual ~messageManager();
00044
00046 static messageManager* instance() {return m_instance;}
00047
00049 std::ostream& out() const;
00050
00052 void open(std::string fileName);
00054 void close();
00055
00057 void message(std::string message, std::string ilevel = "RELEASE") const ;
00059 void message(std::string message, double val, std::string ilevel = "RELEASE") const;
00060
00062 bool acceptLevel(std::string slevel) const;
00063
00065 void addToServer(std::string name, messageVI* mp);
00066
00068 void writeOutServer() const;
00069
00071 void writeOut(std::string name) const;
00072
00074 void writeOut() const;
00075
00076 protected:
00077
00079 messageVI* getMessage(std::string name) const;
00080
00082 virtual void defineOption();
00083
00084
00086
00087 virtual void setOption(std::string var, std::string content);
00088
00089 private:
00090
00092 static messageManager* m_instance;
00093
00095 serverVI<messageVI>* m_server;
00096
00098 std::string m_level;
00100 std::string m_fileName;
00101
00103 bool m_definedFile;
00104
00106 std::ofstream m_file;
00107 };
00108
00109 #endif