Gazebo

GazeboMessage.hh

00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /*
00022  * Desc: Gazebo Message
00023  * Author: Nathan Koenig
00024  * Date: 09 June 2007
00025  * SVN info: $Id: GazeboMessage.hh 4457 2008-03-28 20:38:22Z natepak $
00026  */
00027 
00028 #ifndef GAZEBOMESSAGE_HH
00029 #define GAZEBOMESSAGE_HH
00030 
00031 #include <iostream>
00032 #include <fstream>
00033 #include <string>
00034 #include <sstream>
00035 
00036 namespace gazebo
00037 {
00038   
00042 
00044   #define gzmsg(level) (gazebo::GazeboMessage::Instance()->Msg(level) << "[" << __FILE__ << ":" << __LINE__ << "]\n  ")
00045 
00046   #define gzerr(level) (gazebo::GazeboMessage::Instance()->Err(level) << "Error: [" << __FILE__ << ":" << __LINE__ << "]\n  ")
00047  
00049   #define gzlog() (gazebo::GazeboMessage::Instance()->Log() << "[" << __FILE__ << ":" << __LINE__ << "] ")
00050   
00051     class XMLConfigNode;
00052  
00055 
00066   class GazeboMessage
00067   {
00069     public: GazeboMessage();
00070   
00072     public: virtual ~GazeboMessage();
00073   
00075     public: static GazeboMessage *Instance();
00076   
00078     public: void Load(XMLConfigNode *node);
00079   
00081     public: void Save(XMLConfigNode *node);
00082 
00085     public: void SetVerbose( int level );
00086   
00089     public: std::ostream &Msg( int level = 0 );
00090 
00093     public: std::ostream &Err( int level = 0 );
00094   
00096     public: std::ofstream &Log();
00097   
00099     private: int level;
00100    
00102     private: bool logData;
00103   
00104     private: std::ostringstream nullStream;
00105     private: std::ostream *msgStream;
00106     private: std::ostream *errStream;
00107     private: std::ofstream logStream;
00108   
00110     private: static GazeboMessage *myself;
00111   };
00112 
00114 }
00115 
00116 #endif

Last updated Aug 04 2007