XtermConsole.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *
00003  * Copyright (C) 2009-2010 Cassio Neri Moreira
00004  *
00005  * This file is part of the KeyValue library.
00006  *
00007  * The KeyValue library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as published
00009  * by the Free Software Foundation, either version 3 of the License, or (at
00010  * your option) any later version.
00011  *
00012  * The KeyValue library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
00015  * Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License along
00018  * with KeyValue. If not, see <http://www.gnu.org/licenses/>.
00019  *
00020  **************************************************************************/
00021 
00028 #if !_WIN32 || DOXYGEN
00029 
00030 #ifndef KEYVALUE_SYS_LOGGER_XTERMCONSOLE_H_
00031 #define KEYVALUE_SYS_LOGGER_XTERMCONSOLE_H_
00032 
00033 #include <cstdio>
00034 
00035 #include "keyvalue/sys/logger/LoggerImpl.h"
00036 #include "keyvalue/sys/logger/policy/AddPrefix.h"
00037 #include "keyvalue/sys/logger/policy/XtermColor.h"
00038 
00039 namespace keyvalue {
00040 namespace logger {
00041 
00047 class XtermConsole : public LoggerImpl<AddPrefix, XtermColor> {
00048 
00049 public:
00050 
00051   XtermConsole(unsigned int level, const string& title);
00052 
00053   ~XtermConsole();
00054 
00055 private:
00056 
00064   class FileRaii {
00065 
00066   public:
00067 
00068     explicit
00069     FileRaii(const int fd = -1);
00070 
00071     ~FileRaii();
00072 
00073     FileRaii& operator=(const int fd);
00074 
00075     void
00076     close();
00077 
00078     int
00079     getFd() const;
00080 
00081   private:
00082 
00083     int fd_;
00084   };
00085 
00086   unsigned int  level_;
00087   pid_t         childPid_;
00088   FileRaii      writeSlave_;
00089 
00090   bool
00091   send(const string& message);
00092 
00093 }; // class XtermConsole
00094 
00095 } // namespace logger
00096 } // namespace keyvalue
00097 
00098 #endif  // KEYVALUE_SYS_LOGGER_XTERMCONSOLE_H_
00099 
00100 #endif // !_WIN32 || DOXYGEN

Generated on Sat Mar 20 15:08:29 2010 for KeyValue by  doxygen 1.6.1