ObjectID.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 namespace armarx
6 {
7  /**
8  * @brief A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
9  */
10  class ObjectID
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
36  instanceName() const
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
armarx::ObjectID
A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
Definition: ObjectID.h:10
armarx::ObjectID::withInstanceName
ObjectID withInstanceName(const std::string &instanceName) const
Definition: ObjectID.cpp:83
armarx::ObjectID::FromString
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
armarx::ObjectID::getClassID
ObjectID getClassID() const
Return just the class ID without an intance name.
Definition: ObjectID.cpp:71
armarx::armem::attachment::ObjectID
armem::MemoryID ObjectID
Definition: types.h:79
armarx::ObjectID::dataset
std::string dataset() const
Definition: ObjectID.h:24
armarx::ObjectID::operator>=
bool operator>=(const ObjectID &rhs) const
Definition: ObjectID.h:83
armarx::ObjectID::operator!=
bool operator!=(const ObjectID &rhs) const
Definition: ObjectID.h:63
armarx::ObjectID::operator>
bool operator>(const ObjectID &rhs) const
Definition: ObjectID.h:71
armarx::ObjectID::className
std::string className() const
Definition: ObjectID.h:30
armarx::ObjectID::setFromString
void setFromString(const std::string &idString)
Definition: ObjectID.cpp:42
armarx::ObjectID::equalClass
bool equalClass(const ObjectID &rhs) const
Indicates whether dataset and class name are equal.
Definition: ObjectID.cpp:77
armarx::ObjectID::instanceName
std::string instanceName() const
Definition: ObjectID.h:36
armarx::ObjectID::ObjectID
ObjectID()
Definition: ObjectID.cpp:9
armarx::ObjectID::operator==
bool operator==(const ObjectID &rhs) const
Indicates whether dataset, class name and instance name are equal.
Definition: ObjectID.cpp:89
armarx::ObjectID::operator<
bool operator<(const ObjectID &rhs) const
Definition: ObjectID.cpp:96
armarx::operator<<
std::ostream & operator<<(std::ostream &os, const PythonApplicationManager::Paths &paths)
Definition: PythonApplicationManager.cpp:285
armarx::ObjectID::operator<=
bool operator<=(const ObjectID &rhs) const
Definition: ObjectID.h:77
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::ObjectID::str
std::string str() const
Return "dataset/className" or "dataset/className/instanceName".
Definition: ObjectID.cpp:60
armarx::ObjectID::setInstanceName
void setInstanceName(const std::string &instanceName)
Definition: ObjectID.h:42