ObjectID.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4
5namespace armarx
6{
7 /**
8 * @brief A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
9 */
11 {
12 public:
13 ObjectID();
14 ObjectID(const std::string& dataset,
15 const std::string& className,
16 const std::string& instancName = "");
17 /// Construct from either a class name ("myobject") or ID ("mydataset/myobject", "mydataset/myclass/myinstance").
18 ObjectID(const std::string& nameOrID);
19
20 /// Construct from a string produced by `str()`, e.g. ("mydataset/myobject", "mydataset/myclass/myinstance").
21 static ObjectID FromString(const std::string& idString);
22
23 inline std::string
24 dataset() const
25 {
26 return _dataset;
27 }
28
29 inline std::string
30 className() const
31 {
32 return _className;
33 }
34
35 inline std::string
37 {
38 return _instanceName;
39 }
40
41 inline void
42 setInstanceName(const std::string& instanceName)
43 {
44 this->_instanceName = instanceName;
45 }
46
47 /// Return "dataset/className" or "dataset/className/instanceName".
48 std::string str() const;
49 void setFromString(const std::string& idString);
50
51
52 /// Return just the class ID without an intance name.
53 ObjectID getClassID() const;
54 /// Indicates whether dataset and class name are equal.
55 bool equalClass(const ObjectID& rhs) const;
56
57 ObjectID withInstanceName(const std::string& instanceName) const;
58
59 /// Indicates whether dataset, class name and instance name are equal.
60 bool operator==(const ObjectID& rhs) const;
61
62 inline bool
63 operator!=(const ObjectID& rhs) const
64 {
65 return !operator==(rhs);
66 }
67
68 bool operator<(const ObjectID& rhs) const;
69
70 inline bool
71 operator>(const ObjectID& rhs) const
72 {
73 return rhs < (*this);
74 }
75
76 inline bool
77 operator<=(const ObjectID& rhs) const
78 {
79 return !operator>(rhs);
80 }
81
82 inline bool
83 operator>=(const ObjectID& rhs) const
84 {
85 return !operator<(rhs);
86 }
87
88
89 private:
90 /// The dataset name in ArmarXObjects, e.g. "KIT", "YCB", "SecondHands", ...
91 std::string _dataset;
92 /// The class name in ArmarXObjects, e.g. "Amicelli", "001_chips_can", ...
93 std::string _className;
94 /// An optional instance name, chosen by the user.
95 std::string _instanceName;
96 };
97
98 std::ostream& operator<<(std::ostream& os, const ObjectID& rhs);
99
100
101} // namespace armarx
A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
Definition ObjectID.h:11
void setFromString(const std::string &idString)
Definition ObjectID.cpp:42
bool operator!=(const ObjectID &rhs) const
Definition ObjectID.h:63
bool operator>(const ObjectID &rhs) const
Definition ObjectID.h:71
std::string className() const
Definition ObjectID.h:30
bool operator<(const ObjectID &rhs) const
Definition ObjectID.cpp:96
static ObjectID FromString(const std::string &idString)
Construct from a string produced by str(), e.g. ("mydataset/myobject", "mydataset/myclass/myinstance"...
Definition ObjectID.cpp:34
bool operator<=(const ObjectID &rhs) const
Definition ObjectID.h:77
ObjectID withInstanceName(const std::string &instanceName) const
Definition ObjectID.cpp:83
ObjectID getClassID() const
Return just the class ID without an intance name.
Definition ObjectID.cpp:71
void setInstanceName(const std::string &instanceName)
Definition ObjectID.h:42
bool equalClass(const ObjectID &rhs) const
Indicates whether dataset and class name are equal.
Definition ObjectID.cpp:77
bool operator==(const ObjectID &rhs) const
Indicates whether dataset, class name and instance name are equal.
Definition ObjectID.cpp:89
bool operator>=(const ObjectID &rhs) const
Definition ObjectID.h:83
std::string instanceName() const
Definition ObjectID.h:36
std::string dataset() const
Definition ObjectID.h:24
std::string str() const
Return "dataset/className" or "dataset/className/instanceName".
Definition ObjectID.cpp:60
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::ostream & operator<<(std::ostream &os, const PythonApplicationManager::Paths &paths)