PriorKnowledgeController.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package MemoryX::gui-plugins::SceneEditor
19  * @date 2015
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 #include <exception>
27 #include <string>
28 #include <map>
29 #include <vector>
30 #include <mutex>
31 
32 // Coin3D
33 #include <Inventor/nodes/SoNode.h>
34 
35 // MemoryXInterface
36 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
37 #include <MemoryX/interface/components/CommonStorageInterface.h>
38 
39 // MemoryX
42 
43 #include "MemoryXController.h"
44 
45 namespace memoryxcontroller
46 {
47  class MemoryXController;
48 
49  /**
50  * @brief The controller for the communication with the priorknowledge.
51  *
52  * This class provides methods to get information from the priorknowledge.
53  * It is not possible to change the content of the priorknowledge.
54  */
56  {
57  public:
58  /**
59  * @brief Constructor.
60  *
61  * Constructs a new instance of this class.
62  *
63  * @param priorKnowledgePrx the proxy to the priorknowledge where the object classes are stored
64  */
65  PriorKnowledgeController(const memoryx::PriorKnowledgeInterfacePrx& priorKnowledgePrx);
66  /**
67  * @brief Copy-constructor.
68  *
69  * This constructor can be used if a copy of the given PriorknowledgeController is needed.
70  * It prevents that problems with mutex:scoped_lock occure.
71  *
72  * @param other the priorknowledgecontroller that is about to be copied
73  */
75  /**
76  * @brief Destructor.
77  *
78  */
80  /**
81  * @brief Returns a list of the names of all collections in the database.
82  *
83  * @return std::vector<std::string> the names of all availiable collections
84  */
85  std::vector<std::string> getCollectionNames() const;
86  /**
87  * @brief Returns a list of pointers to all object classes in the given collection.
88  *
89  * @param collection the name of the collection
90  * @return std::vector<memoryx::ObjectClassPtr> the pointers to all object classes
91  */
92  std::vector<memoryx::ObjectClassPtr> getAllObjectClassesPtr(const std::string& collection) const;
93  /**
94  * @brief Returns a pointer to the object class with the given name in the give collection.
95  *
96  * If there is no object class with the given name, a null pointer is returned.
97  *
98  * @param className the name of the object class
99  * @param collection the name of the collection, where the object class belongs to
100  * @return memoryx::ObjectClassPtr the pointer to the object class with the given name
101  */
102  memoryx::ObjectClassPtr getObjectClassPtr(const std::string& className, const std::string& collection) const;
103  /**
104  * @brief Returns a coin node that contains a visual model of the given object class.
105  *
106  * If the parameter collisionModel is true, the a collision model of the object class is returned, otherwise its visualisation model.
107  *
108  * @param objectClass the pointer to object class
109  * @param collisionModel true if the collision model should be returned
110  * @return SoNode the coin node that contains the requested visual model
111  */
112  SoNode* getCoinVisualisation(const memoryx::ObjectClassPtr& objectClass, const bool& collisionModel) const;
113  /**
114  * @brief Returns a map with every attribute and its value of the given object class.
115  *
116  * The values of the attributes are partially converted in strings that are easy to display.
117  *
118  * @param objectClass the pointer to the given object class
119  * @return std::map<std::string, std::string> the map with the attributes
120  */
121  std::map<std::string, std::string> getAllAttributes(const memoryx::ObjectClassPtr& objectClass) const;
122  /**
123  * @brief Returns the name of the collection the object class of the given object instance belongs to.
124  *
125  * @param objectInstance the given object instance
126  * @return std::string the name of the collection the object class belongs to
127  */
128  std::string getCollection(const memoryx::ObjectInstancePtr& objectInstance) const;
129 
130  private:
131  memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx;
132  memoryx::CommonStorageInterfacePrx databasePrx;
133  memoryx::PersistentObjectClassSegmentBasePrx classesSegmentPrx;
134  MemoryXController* memoryXController;
135 
136  memoryx::GridFileManagerPtr fileManager;
137 
138  mutable std::recursive_mutex mutexEntities;
139  };
140  using PriorKnowledgeControllerPtr = std::shared_ptr<PriorKnowledgeController>;
141 }
142 
memoryxcontroller::PriorKnowledgeController::~PriorKnowledgeController
~PriorKnowledgeController()
Destructor.
Definition: PriorKnowledgeController.cpp:80
memoryxcontroller::PriorKnowledgeController::getCollection
std::string getCollection(const memoryx::ObjectInstancePtr &objectInstance) const
Returns the name of the collection the object class of the given object instance belongs to.
Definition: PriorKnowledgeController.cpp:250
memoryxcontroller::MemoryXController
Definition: MemoryXController.h:51
memoryxcontroller::PriorKnowledgeController::getCoinVisualisation
SoNode * getCoinVisualisation(const memoryx::ObjectClassPtr &objectClass, const bool &collisionModel) const
Returns a coin node that contains a visual model of the given object class.
Definition: PriorKnowledgeController.cpp:145
memoryxcontroller::PriorKnowledgeController::getAllAttributes
std::map< std::string, std::string > getAllAttributes(const memoryx::ObjectClassPtr &objectClass) const
Returns a map with every attribute and its value of the given object class.
Definition: PriorKnowledgeController.cpp:181
IceInternal::Handle< ObjectClass >
memoryxcontroller
Definition: MemoryXController.h:43
memoryxcontroller::PriorKnowledgeController::getAllObjectClassesPtr
std::vector< memoryx::ObjectClassPtr > getAllObjectClassesPtr(const std::string &collection) const
Returns a list of pointers to all object classes in the given collection.
Definition: PriorKnowledgeController.cpp:90
MemoryXCoreObjectFactories.h
memoryxcontroller::PriorKnowledgeController::getObjectClassPtr
memoryx::ObjectClassPtr getObjectClassPtr(const std::string &className, const std::string &collection) const
Returns a pointer to the object class with the given name in the give collection.
Definition: PriorKnowledgeController.cpp:124
memoryxcontroller::PriorKnowledgeControllerPtr
std::shared_ptr< PriorKnowledgeController > PriorKnowledgeControllerPtr
Definition: PriorKnowledgeController.h:140
memoryxcontroller::PriorKnowledgeController
The controller for the communication with the priorknowledge.
Definition: PriorKnowledgeController.h:55
ObjectInstance.h
memoryx::GridFileManagerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
Definition: AbstractEntityWrapper.h:32
memoryxcontroller::PriorKnowledgeController::getCollectionNames
std::vector< std::string > getCollectionNames() const
Returns a list of the names of all collections in the database.
Definition: PriorKnowledgeController.cpp:84
MemoryXController.h
memoryxcontroller::PriorKnowledgeController::PriorKnowledgeController
PriorKnowledgeController(const memoryx::PriorKnowledgeInterfacePrx &priorKnowledgePrx)
Constructor.
Definition: PriorKnowledgeController.cpp:54