RTC Toolkit  2.0.0
pathMapper.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_COMPONENTFRAMEWORK_PATHMAPPER_HPP
13 #define RTCTK_COMPONENTFRAMEWORK_PATHMAPPER_HPP
14 
15 #include <filesystem>
16 #include <mal/utility/Uri.hpp>
18 #include <string>
19 #include <vector>
20 
21 namespace rtctk::componentFramework {
22 
29 class PathMapper {
30 public:
34  struct UriResult {
36  elt::mal::Uri m_uri;
37 
39  std::vector<std::string> m_key_names;
40  };
41 
45  struct FilePathResult {
47  std::filesystem::path m_filepath;
48 
50  std::vector<std::string> m_key_names;
51  };
52 
60  PathMapper(const elt::mal::Uri& baseuri, bool simple_layout = false);
61 
63  const elt::mal::Uri& GetBaseUri() const {
64  return m_baseuri;
65  }
66 
72  const std::filesystem::path& GetBasePath() const {
73  return m_basepath;
74  }
75 
77  bool GetSimpleLayout() const {
78  return m_simple_layout;
79  }
80 
89  void SetSimpleLayout(bool simple_layout) {
90  m_simple_layout = simple_layout;
91  }
92 
106  UriResult PathToUri(const DataPointPath& path) const;
107 
120  FilePathResult PathToFile(const DataPointPath& path) const;
121 
130  static std::vector<std::string> SplitPathComponents(const DataPointPath& path);
131 
132 private:
147  void MapToFile(const DataPointPath& path,
148  std::string& filepath,
149  std::vector<std::string>& dictkeys) const;
150 
152  elt::mal::Uri m_baseuri;
153 
155  bool m_simple_layout;
156 
161  std::filesystem::path m_basepath;
162 };
163 
164 } // namespace rtctk::componentFramework
165 
166 #endif // RTCTK_COMPONENTFRAMEWORK_PATHMAPPER_HPP
rtctk::componentFramework::PathMapper::UriResult::m_uri
elt::mal::Uri m_uri
URI calculated from a datapoint path.
Definition: pathMapper.hpp:36
rtctk::componentFramework::PathMapper::SplitPathComponents
static std::vector< std::string > SplitPathComponents(const DataPointPath &path)
Splits the datapoint path into a list of individual path components.
Definition: pathMapper.cpp:39
rtctk::componentFramework::PathMapper::PathToFile
FilePathResult PathToFile(const DataPointPath &path) const
Maps a datapoint path to the corresponding local filesystem path.
Definition: pathMapper.cpp:31
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::componentFramework::PathMapper
Used to calculate URIs from datapoint paths.
Definition: pathMapper.hpp:29
rtctk::componentFramework::PathMapper::PathMapper
PathMapper(const elt::mal::Uri &baseuri, bool simple_layout=false)
Constructs the mapper object with base URI and format flag.
Definition: pathMapper.cpp:18
rtctk::componentFramework::PathMapper::FilePathResult::m_filepath
std::filesystem::path m_filepath
Local YAML file path calculated form a datapoint path.
Definition: pathMapper.hpp:47
rtctk::componentFramework::PathMapper::GetBasePath
const std::filesystem::path & GetBasePath() const
Get the base path for the repository.
Definition: pathMapper.hpp:72
rtctk::componentFramework::PathMapper::SetSimpleLayout
void SetSimpleLayout(bool simple_layout)
Sets the flag that indicates if the simple repository layout should be used.
Definition: pathMapper.hpp:89
rtctk::componentFramework::PathMapper::UriResult::m_key_names
std::vector< std::string > m_key_names
The dictionary keys needed to lookup the datapoint within the document.
Definition: pathMapper.hpp:39
rtctk::componentFramework::PathMapper::UriResult
Result object returned by the PathToUri method.
Definition: pathMapper.hpp:34
rtctk::componentFramework::PathMapper::PathToUri
UriResult PathToUri(const DataPointPath &path) const
Maps a datapoint path to the corresponding URI.
Definition: pathMapper.cpp:23
rtctk::componentFramework::PathMapper::GetSimpleLayout
bool GetSimpleLayout() const
Definition: pathMapper.hpp:77
dataPointPath.hpp
Header file for DataPointPath.
rtctk::componentFramework::PathMapper::FilePathResult::m_key_names
std::vector< std::string > m_key_names
The dictionary keys needed to lookup the datapoint within the YAML file.
Definition: pathMapper.hpp:50
rtctk::componentFramework::PathMapper::FilePathResult
Result object returned by the PathToFile method.
Definition: pathMapper.hpp:45
rtctk::componentFramework::DataPointPath
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:65
rtctk::componentFramework::PathMapper::GetBaseUri
const elt::mal::Uri & GetBaseUri() const
Definition: pathMapper.hpp:63