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