RTC Toolkit  0.1.0-alpha
fileRepository.hpp
Go to the documentation of this file.
1 
9 #ifndef RTCTK_COMPONENTFRAMEWORK_FILEREPOSITORY_HPP
10 #define RTCTK_COMPONENTFRAMEWORK_FILEREPOSITORY_HPP
11 
12 #include <exception>
13 #include <boost/filesystem.hpp>
14 #include <mal/utility/Uri.hpp>
16 
17 namespace rtctk::componentFramework {
18 
19 class InvalidArgumentException : public std::invalid_argument {
20 public:
21  explicit InvalidArgumentException(const std::string& message);
22 };
23 
24 class PathMissingException : public std::runtime_error {
25 public:
26  explicit PathMissingException(const std::string& path);
27 };
28 
29 class FileFormatError : public std::runtime_error {
30 public:
31  explicit FileFormatError(const boost::filesystem::path& filepath);
32 };
33 
34 class InvalidUriInFileError : public std::runtime_error {
35 public:
36  explicit InvalidUriInFileError(const boost::filesystem::path& filepath, const std::string& uri);
37 };
38 
39 class DirCreationError : public std::runtime_error {
40 public:
42 };
43 
44 class FileRepository : virtual public RepositoryIf {
45 public:
46  FileRepository() = delete;
47  FileRepository(const FileRepository&) = delete;
51  explicit FileRepository(const ::elt::mal::Uri& datauri, const int dirdepth);
52  virtual ~FileRepository();
54  void CreateDataPoint(const DataPointPath& path, const std::string& type) override;
56  void DeleteDataPoint(const DataPointPath& path) override;
58  std::string GetDataPointType(const DataPointPath& path) const override;
60  size_t GetDataPointSize(const DataPointPath& path) const override;
62  bool DataPointExists(const DataPointPath& path) const override;
64  std::pair<StringList, StringList> GetChildren(const DataPointPath& path) const override;
65  Response SendReadRequest(const Request& request) const override;
66  Response SendWriteRequest(const Request& request) override;
67 
72  inline size_t get_fits_write_threshold() const {
73  return m_fits_write_threshold;
74  }
75 
83  inline void set_fits_write_threshold(size_t value) {
84  m_fits_write_threshold = value;
85  }
86 
87 private:
88  boost::filesystem::path m_datapath;
89  std::string m_defaultfile;
90  int m_dirdepth;
91  size_t m_fits_write_threshold;
92 };
93 
94 } // namespace rtctk::componentFramework
95 
96 #endif // RTCTK_COMPONENTFRAMEWORK_FILEREPOSITORY_HPP
rtctk::componentFramework::InvalidUriInFileError::InvalidUriInFileError
InvalidUriInFileError(const boost::filesystem::path &filepath, const std::string &uri)
Definition: fileRepository.cpp:947
rtctk::componentFramework::FileRepository::CreateDataPoint
virtual void CreateDataPoint(const DataPointPath &path, const std::string &type)=0
Creates a new datapoint in the repository with a specified type.
rtctk::componentFramework::FileRepository::set_fits_write_threshold
void set_fits_write_threshold(size_t value)
Definition: fileRepository.hpp:83
rtctk::componentFramework::DirCreationError::DirCreationError
DirCreationError(const boost::filesystem::path &path)
Definition: fileRepository.cpp:954
rtctk::componentFramework::PathMissingException
Definition: fileRepository.hpp:24
rtctk::componentFramework::FileRepository::operator=
FileRepository & operator=(FileRepository &&)=default
rtctk::componentFramework::FileRepository::FileRepository
FileRepository(const FileRepository &)=delete
rtctk::componentFramework::RepositoryIf::Request
A request object to pass information about datapoints that should be read (written) from (to) the rep...
Definition: repositoryIf.hpp:37
rtctk::componentFramework::FileRepository::DeleteDataPoint
virtual void DeleteDataPoint(const DataPointPath &path)=0
Deletes a datapoint.
rtctk::componentFramework::FileRepository
Definition: fileRepository.hpp:44
rtctk::componentFramework
Definition: rtcComponent.hpp:17
rtctk::componentFramework::RepositoryIf::DataPointExists
virtual bool DataPointExists(const DataPointPath &path) const =0
Checks for the existence of a datapoint in the repository.
rtctk::componentFramework::FileFormatError
Definition: fileRepository.hpp:29
rtctk::componentFramework::PathMissingException::PathMissingException
PathMissingException(const std::string &path)
Definition: fileRepository.cpp:939
rtctkExampleDataTaskRobotTest.path
string path
Definition: rtctkExampleDataTaskRobotTest.py:228
rtctk::componentFramework::FileRepository::operator=
FileRepository & operator=(const FileRepository &)=delete
rtctk::componentFramework::RepositoryIf::GetDataPointSize
virtual size_t GetDataPointSize(const DataPointPath &path) const =0
Fetches the size of the datapoint's data.
rtctk::componentFramework::RepositoryIf::CreateDataPoint
virtual void CreateDataPoint(const DataPointPath &path, const std::string &type)=0
Creates a new datapoint in the repository with a specified type.
rtctk::componentFramework::FileRepository::FileRepository
FileRepository()=delete
rtctk::componentFramework::FileRepository::GetChildren
virtual std::pair< StringList, StringList > GetChildren(const DataPointPath &path) const=0
Queries the datapoints and child paths for a given path.
repositoryIf.hpp
Header file for RepositoryIf and related base classes.
rtctk::componentFramework::FileRepository::GetDataPointType
virtual std::string GetDataPointType(const DataPointPath &path) const=0
Fetches the type of the datapoint.
rtctk::componentFramework::FileRepository::GetDataPointSize
virtual size_t GetDataPointSize(const DataPointPath &path) const=0
Fetches the size of the datapoint's data.
rtctk::componentFramework::RepositoryIf::DeleteDataPoint
virtual void DeleteDataPoint(const DataPointPath &path)=0
Deletes a datapoint.
rtctk::componentFramework::FileRepository::DataPointExists
virtual bool DataPointExists(const DataPointPath &path) const=0
Checks for the existence of a datapoint in the repository.
rtctk::componentFramework::RepositoryIf
Abstract interface providing basic read and write facilities to a repository.
Definition: repositoryIf.hpp:28
rtctk::componentFramework::RepositoryIf::GetChildren
virtual std::pair< StringList, StringList > GetChildren(const DataPointPath &path) const =0
Queries the datapoints and child paths for a given path.
rtctk::componentFramework::FileRepository::SendReadRequest
Response SendReadRequest(const Request &request) const override
Sends a request to read data from the repository.
Definition: fileRepository.cpp:1200
rtctk::componentFramework::FileRepository::get_fits_write_threshold
size_t get_fits_write_threshold() const
Definition: fileRepository.hpp:72
rtctk::componentFramework::DirCreationError
Definition: fileRepository.hpp:39
rtctk::componentFramework::RepositoryIf::GetDataPointType
virtual std::string GetDataPointType(const DataPointPath &path) const =0
Fetches the type of the datapoint.
rtctk::componentFramework::FileRepository::FileRepository
FileRepository(FileRepository &&)=default
rtctk::componentFramework::FileFormatError::FileFormatError
FileFormatError(const boost::filesystem::path &filepath)
Definition: fileRepository.cpp:943
rtctk::componentFramework::InvalidArgumentException::InvalidArgumentException
InvalidArgumentException(const std::string &message)
Definition: fileRepository.cpp:935
rtctk::componentFramework::DataPointPath
Definition: dataPointPath.hpp:30
rtctk::componentFramework::RepositoryIf::Response
An object used to wait for a request to complete.
Definition: repositoryIf.hpp:74
rtctk::componentFramework::InvalidUriInFileError
Definition: fileRepository.hpp:34
rtctk::componentFramework::InvalidArgumentException
Definition: fileRepository.hpp:19
rtctk::componentFramework::FileRepository::~FileRepository
virtual ~FileRepository()
Definition: fileRepository.cpp:990
rtctk::componentFramework::FileRepository::SendWriteRequest
Response SendWriteRequest(const Request &request) override
Sends a request to write data to the repository.
Definition: fileRepository.cpp:1229