00001 /***************************************************************** 00002 * 00003 * This file is part of the FLIRTLib project 00004 * 00005 * FLIRTLib Copyright (c) 2010 Gian Diego Tipaldi and Kai O. Arras 00006 * 00007 * This software is licensed under the "Creative Commons 00008 * License (Attribution-NonCommercial-ShareAlike 3.0)" 00009 * and is copyrighted by Gian Diego Tipaldi and Kai O. Arras 00010 * 00011 * Further information on this license can be found at: 00012 * http://creativecommons.org/licenses/by-nc-sa/3.0/ 00013 * 00014 * FLIRTLib is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied 00016 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00017 * PURPOSE. 00018 * 00019 *****************************************************************/ 00020 00021 00022 00023 #ifndef LOGSENSORSTREAM_H_ 00024 #define LOGSENSORSTREAM_H_ 00025 00026 #include <sensorstream/SensorStream.h> 00027 #include <sensorstream/LogReader.h> 00028 #include <sensorstream/LogWriter.h> 00029 #include <sensorstream/LogReader.h> 00030 #include <sensors/AbstractReading.h> 00031 00032 #include <iostream> 00033 #include <fstream> 00034 #include <string> 00035 #include <vector> 00036 00038 #define AVG_SIZE_LOG 1000 00039 00049 class LogSensorStream: public SensorStream { 00050 public: 00056 LogSensorStream(const LogReader* _reader, const LogWriter* _writer); 00058 LogSensorStream(const LogSensorStream& _stream); 00063 LogSensorStream& operator=(const LogSensorStream& _stream); 00065 virtual ~LogSensorStream(); 00066 00068 virtual const AbstractReading* next() const; 00070 virtual const AbstractReading* current() const; 00072 virtual bool seek(const unsigned int _position = 0, SensorStreamOffset _offset = BEGIN); 00074 virtual inline unsigned int tell() const {return m_index;} 00076 virtual inline bool isSeekable() const {return true;} 00078 virtual bool end() const; 00079 00081 inline const std::vector<AbstractReading*>& getLog() const 00082 {return m_log;} 00084 inline const LogReader* getReader() const 00085 {return m_logReader;} 00087 inline const LogWriter* getWriter() const 00088 {return m_logWriter;} 00089 00091 void load(const std::string& _filename); 00093 void save(const std::string& _filename); 00094 00096 void load(std::istream& _stream); 00098 void save(std::ostream& _stream); 00099 00100 protected: 00101 std::vector<AbstractReading*> m_log; 00102 mutable unsigned int m_index; 00103 const LogReader * m_logReader; 00104 const LogWriter * m_logWriter; 00105 }; 00106 00107 #endif