All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Logger.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Nate Koenig
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /* Desc: A class to log data
18  * Author: Nate Koenig
19  * Date: 1 Jun 2010
20  */
21 
22 #ifndef _LOGGER_HH_
23 #define _LOGGER_HH_
24 
25 #include <vector>
26 #include <fstream>
27 #include <string>
28 
29 #include "common/SingletonT.hh"
30 
31 namespace gazebo
32 {
33  namespace physics
34  {
37 
55  class Logger : public SingletonT<Logger>
56  {
58  private: Logger();
59 
61  private: virtual ~Logger();
62 
73  public: bool Add(const std::string &_entityName,
74  const std::string &_filename);
75 
84  public: bool Remove(const std::string &_entity);
85 
90  private: void Update();
91 
93  private: class LogObj
94  {
95  public: LogObj(const std::string &entityName,
96  const std::string &filename);
97  public: virtual ~LogObj();
98  public: void Update();
99  public: std::string GetEntityName() const;
100 
101  public: bool valid;
102  private: Entity *entity;
103  private: std::fstream logFile;
104  private: Time startSimTime;
105  private: Time startRealTime;
106  };
107 
108  private: std::vector<LogObj*> logObjects;
109 
110  private: friend class SingletonT<Logger>;
111  };
113  }
114 }
115 #endif