RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
pathMapper.hpp
Go to the documentation of this file.
1
11
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
22
33public:
37 struct UriResult {
39 elt::mal::Uri m_uri;
40
42 std::vector<std::string> m_key_names;
43 };
44
50 std::filesystem::path m_filepath;
51
53 std::vector<std::string> m_key_names;
54 };
55
63 explicit PathMapper(const elt::mal::Uri& baseuri, bool simple_layout = false);
64
66 const elt::mal::Uri& GetBaseUri() const {
67 return m_baseuri;
68 }
69
75 const std::filesystem::path& GetBasePath() const {
76 return m_basepath;
77 }
78
80 bool GetSimpleLayout() const {
81 return m_simple_layout;
82 }
83
93 void SetSimpleLayout(bool simple_layout) {
94 m_simple_layout = simple_layout;
95 }
96
110 UriResult PathToUri(const DataPointPath& path) const;
111
124 FilePathResult PathToFile(const DataPointPath& path) const;
125
134 static std::vector<std::string> SplitPathComponents(const DataPointPath& path);
135
136private:
151 void MapToFile(const DataPointPath& path,
152 std::string& filepath,
153 std::vector<std::string>& dictkeys) const;
154
156 elt::mal::Uri m_baseuri;
157
159 bool m_simple_layout;
160
165 std::filesystem::path m_basepath;
166};
167
168} // namespace rtctk::componentFramework
169
170#endif // RTCTK_COMPONENTFRAMEWORK_PATHMAPPER_HPP
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:76
FilePathResult PathToFile(const DataPointPath &path) const
Maps a datapoint path to the corresponding local filesystem path.
Definition pathMapper.cpp:31
void SetSimpleLayout(bool simple_layout)
Sets the flag that indicates if the simple repository layout should be used.
Definition pathMapper.hpp:93
bool GetSimpleLayout() const
Definition pathMapper.hpp:80
PathMapper(const elt::mal::Uri &baseuri, bool simple_layout=false)
Constructs the mapper object with base URI and format flag.
Definition pathMapper.cpp:19
static std::vector< std::string > SplitPathComponents(const DataPointPath &path)
Splits the datapoint path into a list of individual path components.
Definition pathMapper.cpp:39
UriResult PathToUri(const DataPointPath &path) const
Maps a datapoint path to the corresponding URI.
Definition pathMapper.cpp:23
const std::filesystem::path & GetBasePath() const
Get the base path for the repository.
Definition pathMapper.hpp:75
const elt::mal::Uri & GetBaseUri() const
Definition pathMapper.hpp:66
Header file for DataPointPath.
Definition commandReplier.cpp:21
Result object returned by the PathToFile method.
Definition pathMapper.hpp:48
std::filesystem::path m_filepath
Local YAML file path calculated from a datapoint path.
Definition pathMapper.hpp:50
std::vector< std::string > m_key_names
The dictionary keys needed to lookup the datapoint within the YAML file.
Definition pathMapper.hpp:53
Result object returned by the PathToUri method.
Definition pathMapper.hpp:37
elt::mal::Uri m_uri
URI calculated from a datapoint path.
Definition pathMapper.hpp:39
std::vector< std::string > m_key_names
The dictionary keys needed to lookup the datapoint within the document.
Definition pathMapper.hpp:42