FinderInfoBase.h
Go to the documentation of this file.
1#pragma once
2
3// STD/STL
4#include <filesystem>
5#include <optional>
6#include <string>
7
8// Base Class
10
11// ArmarX
14
16{
18 {
19 /// Name of the ArmarX package.
20 std::string package;
21
22 /// Relative to the package's data directory.
23 std::filesystem::path relativePath;
24
25 /// The absolute path (in the host's file system).
26 std::filesystem::path absolutePath;
27 };
28
29 /**
30 * @brief The FinderInfoBase class
31 * Indicates an into to 'something' of type IDType
32 */
33 template <class IDType>
35 {
36 public:
37 FinderInfoBase(const std::string& packageName,
38 const std::filesystem::path& absPackageDataPath, // the path to the data dir
39 const std::filesystem::path&
40 relPathToId, // the path to 'something' from data/packageName
41 const IDType& id) :
42 packageName(packageName),
43 absPackageDataPath(absPackageDataPath),
44 relPathToId(relPathToId),
45 id(id)
46 {
47 }
48
50 {
51 }
52
58
59 std::string
61 {
62 return packageName;
63 }
64
65 std::filesystem::path
67 {
68 return relPathToId;
69 }
70
71 std::filesystem::path
73 {
75 return absPackageDataPath;
76 }
77
78 virtual std::filesystem::path
80 {
82 return absPackageDataPath / packageName / relPathToId;
83 }
84
85 IDType
86 getID() const
87 {
88 return id;
89 }
90
91 protected:
92 void
94 {
95 if (!std::filesystem::exists(absPackageDataPath))
96 {
97 ARMARX_ERROR << "Could not resolve absolute path for package '" << packageName
98 << "'.";
99 }
100 }
101
102
103 protected:
104 bool logError = true;
105
106 private:
107 std::string packageName;
108 std::filesystem::path absPackageDataPath;
109 std::filesystem::path relPathToId;
110 IDType id;
111 };
112
113 /**
114 * @brief The DatasetFinderInfoBase class
115 * Indicates an into to 'something' of type IDType inside a dataset of type DatasetType
116 */
117 template <class IDType, class DatasetType>
119 {
120
121 public:
123
125 const std::string& packageName,
126 const std::filesystem::path& absPackageDataDir,
127 const std::filesystem::path&
128 relDatasetPath, // the path to the dataset from data/packageName
129 const std::filesystem::path& relPath, // the path to 'something' from the dataset
130 const DatasetType& dataset,
131 const IDType& id) :
132 Base(packageName, absPackageDataDir, (relDatasetPath / relPath), id),
133 dataset(dataset),
134 relDatasetPath(relDatasetPath)
135 {
136 }
137
139 {
140 }
141
142 DatasetType
144 {
145 return dataset;
146 }
147
148 private:
149 DatasetType dataset;
150 std::filesystem::path relDatasetPath;
151 };
152
153} // namespace armarx::priorknowledge::core
DatasetFinderInfoBase(const std::string &packageName, const std::filesystem::path &absPackageDataDir, const std::filesystem::path &relDatasetPath, const std::filesystem::path &relPath, const DatasetType &dataset, const IDType &id)
std::filesystem::path getAbsolutePackageDataPath() const
FinderInfoBase(const std::string &packageName, const std::filesystem::path &absPackageDataPath, const std::filesystem::path &relPathToId, const IDType &id)
virtual std::filesystem::path getFullPath() const
std::filesystem::path getRelativePath() const
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
std::filesystem::path relativePath
Relative to the package's data directory.
std::filesystem::path absolutePath
The absolute path (in the host's file system).
std::string package
Name of the ArmarX package.