CanFileResolutionHelper.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
22 //----------------------------------------------------------------------
23 #ifndef ICL_HARDWARE_CAN_SOURCE_CAN_FILE_RESOLUTION_HELPER_H_INCLUDED
24 #define ICL_HARDWARE_CAN_SOURCE_CAN_FILE_RESOLUTION_HELPER_H_INCLUDED
25 
26 #include <fstream>
27 #include <string>
28 #include <boost/shared_ptr.hpp>
29 
30 #include <icl_sourcesink/Position.h>
31 #include <icl_sourcesink/FileResolutionHelper.h>
33 
34 namespace icl_hardware {
35 namespace can {
36 
37 class CanFileResolutionHelper : public ::icl_sourcesink::FileResolutionHelper
38 {
39 public:
41  typedef boost::shared_ptr<CanFileResolutionHelper> Ptr;
43  typedef boost::shared_ptr<const CanFileResolutionHelper> ConstPtr;
44 
45  CanFileResolutionHelper(const std::string& filename);
46 
47  virtual CanFileResolutionHelper *clone() const
48  {
50  my_clone->m_file.clear();
51  my_clone->seekg(tellg());
52  return my_clone;
53  }
54 
55  virtual bool good() const
56  {
57  return m_file.good();
58  }
59 
60  virtual icl_sourcesink::Position current() const
61  {
62  return m_current_position;
63  }
64 
65  virtual bool advance();
66 
67  virtual std::ifstream::pos_type size() const
68  {
69  std::ifstream::pos_type curr = m_file.tellg();
70  m_file.seekg(0, std::ios::end);
71  std::ifstream::pos_type result = m_file.tellg();
72  m_file.seekg(curr);
73  return result;
74  }
75 
76  virtual std::ifstream::pos_type tellg() const
77  {
78  return m_file.tellg();
79  }
80 
81  virtual bool seekg(std::ifstream::pos_type position)
82  {
83  m_file.clear();
84  m_file.seekg(position);
85  return resolveHere();
86  }
87 
88  virtual bool seekg(std::ifstream::off_type offset, std::ios_base::seekdir direction)
89  {
90  m_file.clear();
91  m_file.seekg(offset, direction);
92  return resolveHere();
93  }
94 
95  static boost::posix_time::ptime timestampToPtime(double stamp);
96 
98 
99 protected:
100  bool tryParse(const std::string& line, uint64_t current_pos);
101 
102  bool resolveHere();
103 
104 private:
105  std::string m_filename;
106  mutable std::ifstream m_file;
107  icl_sourcesink::Position m_current_position;
109 };
110 
111 }
112 }
113 
114 #endif
virtual std::ifstream::pos_type size() const
static boost::posix_time::ptime timestampToPtime(double stamp)
virtual bool seekg(std::ifstream::off_type offset, std::ios_base::seekdir direction)
boost::shared_ptr< const CanFileResolutionHelper > ConstPtr
Convenience shared pointer shorthand (const version).
virtual std::ifstream::pos_type tellg() const
boost::shared_ptr< Stamped< DataType > > Ptr
unsigned __int64 uint64_t
virtual CanFileResolutionHelper * clone() const
boost::shared_ptr< CanFileResolutionHelper > Ptr
Convenience shared pointer shorthand.
CanMessageStamped::Ptr currentMessage() const
virtual bool seekg(std::ifstream::pos_type position)
virtual icl_sourcesink::Position current() const
bool tryParse(const std::string &line, uint64_t current_pos)


fzi_icl_can
Author(s):
autogenerated on Mon Jun 10 2019 13:17:02