ObjectClassSegmentWrapper.cpp
Go to the documentation of this file.
2 
3 
8 
9 #include <VirtualRobot/ManipulationObject.h>
10 #include <SimoxUtility/algorithm/string.h>
11 
12 
13 namespace memoryx
14 {
15 
16  void ObjectClassSegmentWrapper::initFromProxy(PriorKnowledgeInterfacePrx const& priorKnowledge, const std::vector<std::string>& datasets)
17  {
19  ARMARX_CHECK_NOT_NULL(priorKnowledge);
20 
21  memoryx::PersistentObjectClassSegmentBasePrx objectClassesSegment = priorKnowledge->getObjectClassesSegment();
22  memoryx::GridFileManagerPtr fileManager(new memoryx::GridFileManager(priorKnowledge->getCommonStorage()));
23 
24  memoryx::EntityBaseList classEntities = objectClassesSegment->getAllEntities();
25  for (auto& classEntity : classEntities)
26  {
28  ARMARX_CHECK_NOT_NULL(classEntity);
29  memoryx::ObjectClassPtr objectClass = memoryx::ObjectClassPtr::dynamicCast(classEntity);
30  if (objectClass)
31  {
32  std::string objectClassName = objectClass->getName();
33  bool load = datasets.empty();
34  for (const auto& d : datasets)
35  {
36  if (simox::alg::count(objectClassName, "/") == 0) // we always load the legacy stuff
37  {
38  load = true;
39  break;
40  }
41  if (simox::alg::starts_with(objectClassName, d + "/"))
42  {
43  load = true;
44  break;
45  }
46 
47  }
48 
49  if (load)
50  {
51  ARMARX_INFO << "Getting files for object class '" << objectClassName << "'";
53  VirtualRobot::ManipulationObjectPtr manipulationObject = sw->getManipulationObject();
54 
55  ObjectClassWrapper classData = {objectClass, manipulationObject};
56  classToWrapper.emplace(objectClassName, classData);
57  }
58  }
59  }
60  }
61 
62  std::optional<ObjectClassWrapper> ObjectClassSegmentWrapper::getClass(std::string const& className) const
63  {
64  auto found = classToWrapper.find(className);
65  if (found == classToWrapper.end())
66  {
67  return std::nullopt;
68  }
69  else
70  {
71  return found->second;
72  }
73  }
74 
75 }
ObjectClassSegmentWrapper.h
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition: ExpressionException.h:206
GridFileManager.h
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
ObjectClass.h
memoryx::ObjectClassSegmentWrapper::getClass
std::optional< ObjectClassWrapper > getClass(std::string const &className) const
Definition: ObjectClassSegmentWrapper.cpp:62
memoryx::ObjectClassWrapper
Definition: ObjectClassSegmentWrapper.h:17
armarx::starts_with
bool starts_with(const std::string &haystack, const std::string &needle)
Definition: StringHelpers.cpp:43
IceInternal::Handle< ObjectClass >
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
memoryx::ObjectClassSegmentWrapper::initFromProxy
void initFromProxy(memoryx::PriorKnowledgeInterfacePrx const &priorKnowledge, const std::vector< std::string > &datasets)
Definition: ObjectClassSegmentWrapper.cpp:16
memoryx::EntityWrappers::SimoxObjectWrapper
SimoxObjectWrapper offers a simplified access to the Simox ManipulationObject (i.e visualization,...
Definition: SimoxObjectWrapper.h:46
ExpressionException.h
SimoxObjectWrapper.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
memoryx::GridFileManagerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
Definition: AbstractEntityWrapper.h:32
memoryx::GridFileManager
GridFileManager provides utility functions for working with files in Mongo GridFS and links to them s...
Definition: GridFileManager.h:42
armarx::armem::server::ltm::mongodb::util::load
void load(const mongocxx::database &db, armem::wm::Memory &m)
Definition: operations.cpp:40