RTC Toolkit 4.0.1
Loading...
Searching...
No Matches
pathMapper.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_COMPONENTFRAMEWORK_PATHMAPPER_HPP
14#define RTCTK_COMPONENTFRAMEWORK_PATHMAPPER_HPP
15
16#include <filesystem>
17#include <mal/utility/Uri.hpp>
19#include <string>
20#include <vector>
21
23
34public:
38 struct UriResult {
40 elt::mal::Uri m_uri;
41
43 std::vector<std::string> m_key_names;
44 };
45
51 std::filesystem::path m_filepath;
52
54 std::vector<std::string> m_key_names;
55 };
56
64 PathMapper(const elt::mal::Uri& baseuri, bool simple_layout = false);
65
67 const elt::mal::Uri& GetBaseUri() const {
68 return m_baseuri;
69 }
70
76 const std::filesystem::path& GetBasePath() const {
77 return m_basepath;
78 }
79
81 bool GetSimpleLayout() const {
82 return m_simple_layout;
83 }
84
94 void SetSimpleLayout(bool simple_layout) {
95 m_simple_layout = simple_layout;
96 }
97
111 UriResult PathToUri(const DataPointPath& path) const;
112
125 FilePathResult PathToFile(const DataPointPath& path) const;
126
135 static std::vector<std::string> SplitPathComponents(const DataPointPath& path);
136
137private:
152 void MapToFile(const DataPointPath& path,
153 std::string& filepath,
154 std::vector<std::string>& dictkeys) const;
155
157 elt::mal::Uri m_baseuri;
158
160 bool m_simple_layout;
161
166 std::filesystem::path m_basepath;
167};
168
169} // namespace rtctk::componentFramework
170
171#endif // RTCTK_COMPONENTFRAMEWORK_PATHMAPPER_HPP
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:73
Used to calculate URIs from datapoint paths.
Definition: pathMapper.hpp:33
FilePathResult PathToFile(const DataPointPath &path) const
Maps a datapoint path to the corresponding local filesystem path.
Definition: pathMapper.cpp:33
void SetSimpleLayout(bool simple_layout)
Sets the flag that indicates if the simple repository layout should be used.
Definition: pathMapper.hpp:94
bool GetSimpleLayout() const
Definition: pathMapper.hpp:81
static std::vector< std::string > SplitPathComponents(const DataPointPath &path)
Splits the datapoint path into a list of individual path components.
Definition: pathMapper.cpp:41
UriResult PathToUri(const DataPointPath &path) const
Maps a datapoint path to the corresponding URI.
Definition: pathMapper.cpp:25
const std::filesystem::path & GetBasePath() const
Get the base path for the repository.
Definition: pathMapper.hpp:76
const elt::mal::Uri & GetBaseUri() const
Definition: pathMapper.hpp:67
Header file for DataPointPath.
Definition: commandReplier.cpp:22
Result object returned by the PathToFile method.
Definition: pathMapper.hpp:49
std::filesystem::path m_filepath
Local YAML file path calculated from a datapoint path.
Definition: pathMapper.hpp:51
std::vector< std::string > m_key_names
The dictionary keys needed to lookup the datapoint within the YAML file.
Definition: pathMapper.hpp:54
Result object returned by the PathToUri method.
Definition: pathMapper.hpp:38
elt::mal::Uri m_uri
URI calculated from a datapoint path.
Definition: pathMapper.hpp:40
std::vector< std::string > m_key_names
The dictionary keys needed to lookup the datapoint within the document.
Definition: pathMapper.hpp:43