Info.h
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4#include <optional>
5#include <ostream>
6#include <string>
7
9
11
13{
14
15
16 /**
17 * @brief Accessor for human profile files.
18 */
19 class Info
20 {
21 public:
22 using path = std::filesystem::path;
23 using Person = armarx::human::arondto::Person;
24
25 public:
26 /**
27 * @brief Info
28 *
29 * @param packageName The ArmarX package.
30 * @param absPackageDataDir Absolute path to the package's data directory.
31 * @param relativePath The path where human profiles are stored in the data directory.
32 * @param id The human profile ID.
33 */
34 Info(const std::string& packageName,
35 const path& absPackageDataDir,
36 const path& relativePath,
37 const std::string& id);
38
39 virtual ~Info() = default;
40
41 void setLogError(bool enabled);
42
43
44 std::string package() const;
45 std::string id() const;
46
47
48 PackagePath file(const std::string& extension, const std::string& suffix = "") const;
49 PackagePath sub_directory(const std::string& suffix) const;
50
52
54 std::vector<PackagePath>
55 faceImages(const std::vector<std::string>& extensions = {".png", ".jpg"}) const;
56
57
58 std::optional<Person> loadProfile(const bool loadFaceImages = true) const;
59
60
61 /**
62 * @brief Checks the existence of expected files.
63 * If a file is does not exist, emits a warning returns false.
64 * @return True if all existing files are found, false otherwise.
65 */
66 virtual bool checkPaths() const;
67
68
69 private:
70 path _relativeProfileDirectory() const;
71
72
73 private:
74 std::string _packageName;
75 path _absPackageDataDir;
76 path _relativePath;
77
78 std::string _id;
79
80 bool _logError = true;
81 };
82
83 std::ostream& operator<<(std::ostream& os, const Info& rhs);
84
85 inline bool
86 operator==(const Info& lhs, const Info& rhs)
87 {
88 return lhs.id() == rhs.id();
89 }
90
91 inline bool
92 operator!=(const Info& lhs, const Info& rhs)
93 {
94 return lhs.id() != rhs.id();
95 }
96
97 inline bool
98 operator<(const Info& lhs, const Info& rhs)
99 {
100 return lhs.id() < rhs.id();
101 }
102
103 inline bool
104 operator>(const Info& lhs, const Info& rhs)
105 {
106 return lhs.id() > rhs.id();
107 }
108
109 inline bool
110 operator<=(const Info& lhs, const Info& rhs)
111 {
112 return lhs.id() <= rhs.id();
113 }
114
115 inline bool
116 operator>=(const Info& lhs, const Info& rhs)
117 {
118 return lhs.id() >= rhs.id();
119 }
120
121} // namespace armarx::armem::human
Accessor for human profile files.
Definition Info.h:20
std::vector< PackagePath > faceImages(const std::vector< std::string > &extensions={".png", ".jpg"}) const
Definition Info.cpp:95
virtual bool checkPaths() const
Checks the existence of expected files.
Definition Info.cpp:163
std::string id() const
Definition Info.cpp:49
virtual ~Info()=default
std::string package() const
Definition Info.cpp:43
void setLogError(bool enabled)
Definition Info.cpp:37
std::optional< Person > loadProfile(const bool loadFaceImages=true) const
Definition Info.cpp:124
PackagePath file(const std::string &extension, const std::string &suffix="") const
Definition Info.cpp:61
std::filesystem::path path
Definition Info.h:22
PackagePath sub_directory(const std::string &suffix) const
Definition Info.cpp:75
armarx::human::arondto::Person Person
Definition Info.h:23
PackagePath faceImageDir() const
Definition Info.cpp:88
PackagePath profileJson() const
Definition Info.cpp:82
Info(const std::string &packageName, const path &absPackageDataDir, const path &relativePath, const std::string &id)
Info.
Definition Info.cpp:25
bool operator==(const Info &lhs, const Info &rhs)
Definition Info.h:86
bool operator<=(const Info &lhs, const Info &rhs)
Definition Info.h:110
bool operator>(const Info &lhs, const Info &rhs)
Definition Info.h:104
bool operator<(const Info &lhs, const Info &rhs)
Definition Info.h:98
bool operator>=(const Info &lhs, const Info &rhs)
Definition Info.h:116
std::ostream & operator<<(std::ostream &os, const Info &rhs)
Definition Info.cpp:184
bool operator!=(const Info &lhs, const Info &rhs)
Definition Info.h:92