00001 #ifndef SENSORSTREAM_H 00002 #define SENSORSTREAM_H 00003 00004 #include <istream> 00005 #include "sensorlog.h" 00006 00007 namespace GMapping { 00008 class SensorStream{ 00009 public: 00010 SensorStream(const SensorMap& sensorMap); 00011 virtual ~SensorStream(); 00012 virtual operator bool() const=0; 00013 virtual bool rewind() = 0 ; 00014 virtual SensorStream& operator >>(const SensorReading*&) = 0; 00015 inline const SensorMap& getSensorMap() const {return m_sensorMap; } 00016 protected: 00017 const SensorMap& m_sensorMap; 00018 static SensorReading* parseReading(std::istream& is, const SensorMap& smap); 00019 static OdometryReading* parseOdometry(std::istream& is, const OdometrySensor* ); 00020 static RangeReading* parseRange(std::istream& is, const RangeSensor* ); 00021 }; 00022 00023 class InputSensorStream: public SensorStream{ 00024 public: 00025 InputSensorStream(const SensorMap& sensorMap, std::istream& is); 00026 virtual operator bool() const; 00027 virtual bool rewind(); 00028 virtual SensorStream& operator >>(const SensorReading*&); 00029 00030 //virtual SensorStream& operator >>(SensorLog*& log); 00031 protected: 00032 std::istream& m_inputStream; 00033 }; 00034 00035 class LogSensorStream: public SensorStream{ 00036 public: 00037 LogSensorStream(const SensorMap& sensorMap, const SensorLog* log); 00038 virtual operator bool() const; 00039 virtual bool rewind(); 00040 virtual SensorStream& operator >>(const SensorReading*&); 00041 protected: 00042 const SensorLog* m_log; 00043 SensorLog::const_iterator m_cursor; 00044 }; 00045 00046 }; 00047 #endif