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