Helios++
Helios software for LiDAR simulations
FileReader.h
1 #pragma once
2 
3 #include <filems/read/strategies/ReadingStrategy.h>
4 
5 #include <string>
6 #include <memory>
7 
8 namespace helios { namespace filems{
9 
10 using std::string;
11 using std::shared_ptr;
12 
19 template <typename ReadType>
20 class FileReader{
21 protected:
22  // *** ATTRIBUTES *** //
23  // ******************** //
27  string path;
32  shared_ptr<ReadingStrategy<ReadType>> readingStrategy = nullptr;
33 
34 public:
35  // *** CONSTRUCTION / DESTRUCTION *** //
36  // ************************************ //
41  FileReader(string const &path) :
42  path(path)
43  {}
44  virtual ~FileReader() = default;
45 
46  // *** READ METHODS *** //
47  // ********************** //
52  virtual ReadType read() = 0;
53 
54 protected:
55  // *** INNER METHODS *** //
56  // *********************** //
60  virtual void makeStrategy() = 0;
61 
62 
63 public:
64  // *** GETTERs and SETTERs *** //
65  // ***************************** //
71  virtual string getPath() const {return path;};
77  virtual void setPath(string const &path) {this->path = path;}
78 
79 };
80 
81 }}
Abstract class defining the fundamentals of any file reader.
Definition: FileReader.h:20
virtual void makeStrategy()=0
Build the strategy for the file reader.
FileReader(string const &path)
Default constructor for file reader.
Definition: FileReader.h:41
virtual ReadType read()=0
Read from file.
virtual string getPath() const
Obtain the path to the file to be read.
Definition: FileReader.h:71
shared_ptr< ReadingStrategy< ReadType > > readingStrategy
The reading strategy to be used by the file reader.
Definition: FileReader.h:32
string path
Path to the file to be read.
Definition: FileReader.h:27
virtual void setPath(string const &path)
Set the path to the file to be read.
Definition: FileReader.h:77