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 <map>
28 #include <mutex>
29 #include <string>
30 #include <vector>
31 
32 // Coin3D
33 #include <Inventor/nodes/SoNode.h>
34 
35 // MemoryXInterface
36 #include <MemoryX/interface/components/CommonStorageInterface.h>
37 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
38 
39 // MemoryX
40 #include "MemoryXController.h"
43 
44 namespace memoryxcontroller
45 {
46  class MemoryXController;
47 
48  /**
49  * @brief The controller for the communication with the priorknowledge.
50  *
51  * This class provides methods to get information from the priorknowledge.
52  * It is not possible to change the content of the priorknowledge.
53  */
55  {
56  public:
57  /**
58  * @brief Constructor.
59  *
60  * Constructs a new instance of this class.
61  *
62  * @param priorKnowledgePrx the proxy to the priorknowledge where the object classes are stored
63  */
64  PriorKnowledgeController(const memoryx::PriorKnowledgeInterfacePrx& priorKnowledgePrx);
65  /**
66  * @brief Copy-constructor.
67  *
68  * This constructor can be used if a copy of the given PriorknowledgeController is needed.
69  * It prevents that problems with mutex:scoped_lock occure.
70  *
71  * @param other the priorknowledgecontroller that is about to be copied
72  */
74  /**
75  * @brief Destructor.
76  *
77  */
79  /**
80  * @brief Returns a list of the names of all collections in the database.
81  *
82  * @return std::vector<std::string> the names of all availiable collections
83  */
84  std::vector<std::string> getCollectionNames() const;
85  /**
86  * @brief Returns a list of pointers to all object classes in the given collection.
87  *
88  * @param collection the name of the collection
89  * @return std::vector<memoryx::ObjectClassPtr> the pointers to all object classes
90  */
91  std::vector<memoryx::ObjectClassPtr>
92  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,
103  const std::string& collection) const;
104  /**
105  * @brief Returns a coin node that contains a visual model of the given object class.
106  *
107  * If the parameter collisionModel is true, the a collision model of the object class is returned, otherwise its visualisation model.
108  *
109  * @param objectClass the pointer to object class
110  * @param collisionModel true if the collision model should be returned
111  * @return SoNode the coin node that contains the requested visual model
112  */
113  SoNode* getCoinVisualisation(const memoryx::ObjectClassPtr& objectClass,
114  const bool& collisionModel) const;
115  /**
116  * @brief Returns a map with every attribute and its value of the given object class.
117  *
118  * The values of the attributes are partially converted in strings that are easy to display.
119  *
120  * @param objectClass the pointer to the given object class
121  * @return std::map<std::string, std::string> the map with the attributes
122  */
123  std::map<std::string, std::string>
124  getAllAttributes(const memoryx::ObjectClassPtr& objectClass) const;
125  /**
126  * @brief Returns the name of the collection the object class of the given object instance belongs to.
127  *
128  * @param objectInstance the given object instance
129  * @return std::string the name of the collection the object class belongs to
130  */
131  std::string getCollection(const memoryx::ObjectInstancePtr& objectInstance) const;
132 
133  private:
134  memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx;
135  memoryx::CommonStorageInterfacePrx databasePrx;
136  memoryx::PersistentObjectClassSegmentBasePrx classesSegmentPrx;
137  MemoryXController* memoryXController;
138 
139  memoryx::GridFileManagerPtr fileManager;
140 
141  mutable std::recursive_mutex mutexEntities;
142  };
143 
144  using PriorKnowledgeControllerPtr = std::shared_ptr<PriorKnowledgeController>;
145 } // namespace memoryxcontroller
memoryxcontroller::PriorKnowledgeController::~PriorKnowledgeController
~PriorKnowledgeController()
Destructor.
Definition: PriorKnowledgeController.cpp:84
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:280
memoryxcontroller::MemoryXController
Definition: MemoryXController.h:52
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:156
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:196
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:96
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:133
memoryxcontroller::PriorKnowledgeControllerPtr
std::shared_ptr< PriorKnowledgeController > PriorKnowledgeControllerPtr
Definition: PriorKnowledgeController.h:144
memoryxcontroller::PriorKnowledgeController
The controller for the communication with the priorknowledge.
Definition: PriorKnowledgeController.h:54
ObjectInstance.h
memoryx::GridFileManagerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
Definition: AbstractEntityWrapper.h:33
memoryxcontroller::PriorKnowledgeController::getCollectionNames
std::vector< std::string > getCollectionNames() const
Returns a list of the names of all collections in the database.
Definition: PriorKnowledgeController.cpp:89
MemoryXController.h
memoryxcontroller::PriorKnowledgeController::PriorKnowledgeController
PriorKnowledgeController(const memoryx::PriorKnowledgeInterfacePrx &priorKnowledgePrx)
Constructor.
Definition: PriorKnowledgeController.cpp:56