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 
12 namespace armarx::armem::human
13 {
14 
15 
16  /**
17  * @brief Accessor for human profile files.
18  */
19  class Info
20  {
21  public:
22  using path = std::filesystem::path;
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 
51  PackagePath profileJson() const;
52 
53  PackagePath faceImageDir() const;
54  std::vector<PackagePath>
55  faceImages(const std::vector<std::string>& extensions = {".png", ".jpg"}) const;
56 
57 
58  std::optional<Profile> loadProfile() 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
armarx::armem::human::operator==
bool operator==(const Info &lhs, const Info &rhs)
Definition: Info.h:86
armarx::armem::human::operator<<
std::ostream & operator<<(std::ostream &os, const Info &rhs)
Definition: Info.cpp:173
armarx::armem::human::Info::file
PackagePath file(const std::string &extension, const std::string &suffix="") const
Definition: Info.cpp:61
armarx::armem::human::operator<
bool operator<(const Info &lhs, const Info &rhs)
Definition: Info.h:98
armarx::armem::human::Info::faceImages
std::vector< PackagePath > faceImages(const std::vector< std::string > &extensions={".png", ".jpg"}) const
Definition: Info.cpp:94
armarx::armem::human::Info::sub_directory
PackagePath sub_directory(const std::string &suffix) const
Definition: Info.cpp:75
armarx::armem::human::Info::Profile
armarx::human::arondto::Profile Profile
Definition: Info.h:23
armarx::armem::human::Info::Info
Info(const std::string &packageName, const path &absPackageDataDir, const path &relativePath, const std::string &id)
Info.
Definition: Info.cpp:25
armarx::armem::human::operator>
bool operator>(const Info &lhs, const Info &rhs)
Definition: Info.h:104
armarx::armem::human::Info::loadProfile
std::optional< Profile > loadProfile() const
Definition: Info.cpp:117
armarx::armem::human::Info::id
std::string id() const
Definition: Info.cpp:49
armarx::armem::human::operator!=
bool operator!=(const Info &lhs, const Info &rhs)
Definition: Info.h:92
armarx::armem::human::Info::setLogError
void setLogError(bool enabled)
Definition: Info.cpp:37
armarx::armem::human::operator>=
bool operator>=(const Info &lhs, const Info &rhs)
Definition: Info.h:116
armarx::armem::human::Info::~Info
virtual ~Info()=default
armarx::armem::server::human::profile::Profile
armarx::human::arondto::Profile Profile
Definition: Segment.cpp:43
enabled
std::atomic< bool > * enabled
Definition: RemoteGuiWidgetController.cpp:75
forward_declarations.h
armarx::armem::human::Info::checkPaths
virtual bool checkPaths() const
Checks the existence of expected files.
Definition: Info.cpp:152
armarx::armem::human::Info::package
std::string package() const
Definition: Info.cpp:43
armarx::armem::human::Info::faceImageDir
PackagePath faceImageDir() const
Definition: Info.cpp:88
armarx::armem::human::operator<=
bool operator<=(const Info &lhs, const Info &rhs)
Definition: Info.h:110
armarx::armem::human
Definition: aron_conversions.cpp:16
armarx::PackagePath
Definition: PackagePath.h:52
armarx::armem::human::Info::path
std::filesystem::path path
Definition: Info.h:22
armarx::armem::human::Info::profileJson
PackagePath profileJson() const
Definition: Info.cpp:82
armarx::armem::human::Info
Accessor for human profile files.
Definition: Info.h:19
PackagePath.h