Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

logserver.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002 
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2002,2003 Koblenz University
00006    Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
00007    $Id: logserver.cpp,v 1.3 2004/06/13 06:35:54 fruit Exp $
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; version 2 of the License.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 #include "logserver.h"
00023 #include "logserverstreambuf.h"
00024 #include <stdarg.h>
00025 
00026 using namespace std;
00027 using namespace zeitgeist;
00028 
00029 LogServer::LogServer(unsigned int size) :
00030     Node(), ostream(new LogServerStreamBuf(size))
00031 {
00032 }
00033 
00034 LogServer::~LogServer()
00035 {
00036     flush();
00037 
00038     // delete the created streambuf
00039     delete rdbuf();
00040 }
00041 
00042 void LogServer::AddStream(std::ostream* stream, unsigned int mask)
00043 {
00044     GetStreamBuf().AddStream(stream, mask);
00045 }
00046 
00047 bool LogServer::RemoveStream(const std::ostream* stream)
00048 {
00049     return GetStreamBuf().RemoveStream(stream);
00050 }
00051 
00052 unsigned int LogServer::GetPriorityMask(const std::ostream* stream) const
00053 {
00054     return GetStreamBuf().GetPriorityMask(stream);
00055 }
00056 
00057 bool LogServer::SetPriorityMask(const std::ostream* stream, unsigned int mask)
00058 {
00059     return GetStreamBuf().SetPriorityMask(stream, mask);
00060 }
00061 
00062 LogServer& LogServer::Priority(unsigned int prio)
00063 {
00064     GetStreamBuf().SetCurrentPriority(prio);
00065     return *this;
00066 }
00067 
00068 void
00069 LogServer::Printf(const char *inFormat, ...)
00070 {
00071     const int size = 4096;
00072     char copyBuffer[size];
00073     va_list args;
00074     va_start(args, inFormat);
00075     if (vsnprintf(copyBuffer, size, inFormat, args) == size)
00076     {
00077         copyBuffer[size-1] = 0;
00078     }
00079     va_end(args);
00080     (*this) << copyBuffer;
00081     this->flush();
00082 }
00083 
00084 const LogServerStreamBuf& LogServer::GetStreamBuf() const
00085 {
00086     LogServerStreamBuf* streamBuf = (LogServerStreamBuf*)(rdbuf());
00087     return *streamBuf;
00088 }
00089 
00090 LogServerStreamBuf& LogServer::GetStreamBuf()
00091 {
00092     LogServerStreamBuf* streamBuf = (LogServerStreamBuf*)(rdbuf());
00093     return *streamBuf;
00094 }

Generated on Thu Apr 6 15:25:38 2006 for rcssserver3d by  doxygen 1.4.4