MemoryXController.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 <vector>
29
30// MemoryXInterface
31#include <MemoryX/interface/components/LongtermMemoryInterface.h>
32#include <MemoryX/interface/core/EntityBase.h>
34
35/* Boost headers */
36#include <memory>
37
42
44{
47
48 /**
49 * @brief
50 *
51 */
53 {
54 public:
55 /**
56 * @brief Constructor.
57 *
58 * Creates an instance of this class.
59 */
61 /**
62 * @brief Destructor
63 *
64 */
66 /**
67 * @brief Initialisates the MemoryXController.
68 *
69 * @param priorKnowledgePrx the proxy to the priorknowledge
70 * @param workingMemoryPrx the proxy to the working memory
71 * @param workingMemoryUpdatesTopic the name of the topic where changes of the working memory are reported
72 * @param objectInstancesSegmentName the name of the segment in the working memory where the object instances are stored
73 * @param longtermMemoryPrx the proxy to the longtermmemory where snapshots are stored
74 * @param mainController the controller of this programm
75 *
76 * @see controller::Controller
77 */
78 void init(const memoryx::PriorKnowledgeInterfacePrx& priorKnowledgePrx,
79 const memoryx::WorkingMemoryInterfacePrx& workingMemoryPrx,
80 const std::string& workingMemoryUpdatesTopic,
81 const std::string& objectInstancesSegmentName,
82 const memoryx::LongtermMemoryInterfacePrx& longtermMemoryPrx,
83 const controller::ControllerPtr& mainController);
84 /**
85 * @brief Saves the whole content of the working memory in a snapshot with the given name.
86 *
87 * If the given name does not start with 'Snapshot_', this prefix will be added.
88 *
89 * @param snapshotName the name of the snapshot
90 * @return bool true when the saving was successful
91 */
92 bool saveSceneInSnapshot(std::string& snapshotName);
93 /**
94 * @brief Saves all object instances whose ids are given in a snapshot with the given name.
95 *
96 * @param snapshotName the name of the snapshot
97 * @param objectIds the list with the ids of the object instances that shold be saved
98 * @return bool true when the saving was successful
99 */
100 bool saveObjectsInSnapshot(std::string& snapshotName,
101 const std::vector<std::string>& objectIds);
102 /**
103 * @brief Loads the content of the snapshot with the given name and add it to the current working memory.
104 *
105 * Returns a list with the ids of the added object instances.
106 * If there is no snapshot with the given name nothing is added to the working memory.
107 *
108 * @param snapshotName the name of the snapshot that should be loaded
109 * @return std::vector<std::string> the list with the ids of the added object instances
110 */
111 std::vector<std::string> loadSnapshot(const std::string& snapshotName);
112 /**
113 * @brief Returns a shared pointer to the WorkingMemoryController.
114 *
115 * @return IceInternal::Handle<WorkingMemoryController> the pointer to the WorkingMemoryController
116 */
118 /**
119 * @brief Returns a shared pointer to the PriorKnowledgeController.
120 *
121 * @return std::shared_ptr<PriorKnowledgeController> the pointer to the PriorKnowledgeController
122 */
123 std::shared_ptr<PriorKnowledgeController> getPriorKnowlegdeController() const;
124 /**
125 * @brief Returns a list with the names of all existing snapshots
126 *
127 * @return std::vector<std::string> list of names of all existing snapshots
128 */
129 std::vector<std::string> getAllSnapshots();
130 /**
131 * @brief Returns the main controller of this plugin.
132 *
133 * @return controller::ControllerPtr the pointer to the main controller
134 */
136
137 private:
138 memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx;
139 IceInternal::Handle<WorkingMemoryController> workingMemoryController;
140 std::shared_ptr<PriorKnowledgeController> priorKnowledgeController;
141 controller::ControllerWeakPtr mainController;
142
143 /**
144 * @brief LONGTERM_SNAPSHOT_PREFIX is set to "Snapshot_" and needs to be the prefix of each Snapshot name
145 */
146 const std::string LONGTERM_SNAPSHOT_PREFIX;
147 };
148
149 using MemoryXControllerPtr = std::shared_ptr<MemoryXController>;
150} // namespace memoryxcontroller
bool saveSceneInSnapshot(std::string &snapshotName)
Saves the whole content of the working memory in a snapshot with the given name.
std::vector< std::string > getAllSnapshots()
Returns a list with the names of all existing snapshots.
void init(const memoryx::PriorKnowledgeInterfacePrx &priorKnowledgePrx, const memoryx::WorkingMemoryInterfacePrx &workingMemoryPrx, const std::string &workingMemoryUpdatesTopic, const std::string &objectInstancesSegmentName, const memoryx::LongtermMemoryInterfacePrx &longtermMemoryPrx, const controller::ControllerPtr &mainController)
Initialisates the MemoryXController.
std::vector< std::string > loadSnapshot(const std::string &snapshotName)
Loads the content of the snapshot with the given name and add it to the current working memory.
std::shared_ptr< PriorKnowledgeController > getPriorKnowlegdeController() const
Returns a shared pointer to the PriorKnowledgeController.
IceInternal::Handle< WorkingMemoryController > getWorkingMemoryController() const
Returns a shared pointer to the WorkingMemoryController.
controller::ControllerPtr getController() const
Returns the main controller of this plugin.
bool saveObjectsInSnapshot(std::string &snapshotName, const std::vector< std::string > &objectIds)
Saves all object instances whose ids are given in a snapshot with the given name.
The controller for the communication with the priorknowledge.
The controller for the communication with the working memory.
std::weak_ptr< Controller > ControllerWeakPtr
std::shared_ptr< Controller > ControllerPtr
std::shared_ptr< MemoryXController > MemoryXControllerPtr