Wiselib
|
00001 /* 00002 Provides statistics output for roomba robot. Statistics 00003 should be computed at the event of received messages. 00004 Copyright (C) 2010 Andreas Cord-Landwehr 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 3 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, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 00021 00022 #ifndef ROOMBA_STATISTICS_H 00023 #define ROOMBA_STATISTICS_H 00024 00025 #include <string.h> 00026 #include <fstream> 00027 #include <iostream> 00028 #include <boost/concept_check.hpp> 00029 00030 class RoombaStatistics 00031 { 00032 00033 public: 00034 RoombaStatistics( std::string statistics_filename = "output.txt" ) 00035 { 00036 set_statistics_filename( statistics_filename ); 00037 statistics_stream_.open( statistics_filename_.c_str() ); 00038 statistics_stream_ << "Time;Buffer Size;Action\n"; 00039 statistics_stream_.flush(); 00040 } 00041 00042 virtual ~RoombaStatistics() 00043 {} 00044 00052 void print_statistics( int time, int buffer_size, int action ) 00053 { 00054 statistics_stream_ << time << ";" << buffer_size << ";" << action << "\n"; 00055 statistics_stream_.flush(); 00056 } 00057 00062 void print_statistics_comment(std::string comment) 00063 { 00064 statistics_stream_ << "# " << comment << "\n"; 00065 statistics_stream_.flush(); 00066 } 00067 00071 void close_statistics() 00072 { 00073 statistics_stream_.close(); 00074 } 00075 00076 /* 00077 * Setter and getter methods 00078 */ 00079 void set_statistics_filename( std::string statistics_filename ) 00080 { 00081 statistics_filename_ = statistics_filename; 00082 } 00083 00084 std::string statistics_filename( ) 00085 { 00086 return statistics_filename_; 00087 } 00088 00089 private: 00090 std::string statistics_filename_; 00091 std::ofstream statistics_stream_; 00092 }; 00093 00094 #endif // ROOMBA_STATISTICS_H