Logger.hh
00001 /* 00002 * Copyright 2011 Nate Koenig & Andrew Howard 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 */ 00017 /* Desc: A class to log data 00018 * Author: Nate Koenig 00019 * Date: 1 Jun 2010 00020 */ 00021 00022 #ifndef LOGGER_HH 00023 #define LOGGER_HH 00024 00025 #include <vector> 00026 #include <fstream> 00027 #include <string> 00028 00029 #include "common/SingletonT.hh" 00030 00031 namespace gazebo 00032 { 00033 namespace common 00034 { 00037 00039 class Logger : public SingletonT<Logger> 00040 { 00042 public: Logger(); 00043 00045 public: virtual ~Logger(); 00046 00048 public: void AddLog(const std::string &model, const std::string &filename); 00049 00051 public: void RemoveLog(const std::string &entity); 00052 00054 public: void Update(); 00055 00056 private: class LogObj 00057 { 00058 public: LogObj(const std::string &entityName, 00059 const std::string &filename); 00060 public: virtual ~LogObj(); 00061 public: void Update(); 00062 public: std::string GetEntityName() const; 00063 00064 public: bool valid; 00065 private: Entity *entity; 00066 private: std::fstream logFile; 00067 private: Time startSimTime; 00068 private: Time startRealTime; 00069 }; 00070 00071 private: std::vector<LogObj*> logObjects; 00072 00073 private: friend class SingletonT<Logger>; 00074 }; 00076 } 00077 } 00078 #endif

1.7.5.1