WorkingMemorySnapshot.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package MemoryX::LongtermMemory
17 * @author Alexey Kozlov ( kozlov at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
26 
28 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
29 #include <MemoryX/interface/core/MemoryInterface.h>
30 
31 namespace memoryx
32 {
33  using SegmentMap = std::map<std::string, std::string>;
34 
35  /*!
36  * \brief The WorkingMemorySnapshot class handles snapshot IO methods.
37  *
38  * Snapshots can be loaded and restored from the database.
39  *
40  */
42  virtual public WorkingMemorySnapshotInterface
43  {
44  public:
45  WorkingMemorySnapshot(const std::string& name,
47  const DatabaseInterfacePrx& databasePrx);
48 
49  // implementation of WorkingMemorySnapshotInterface methods
50  PersistentEntitySegmentBasePrx
51  addSegment(const ::std::string& segName,
52  const ::Ice::Current& = Ice::emptyCurrent) override;
53  PersistentEntitySegmentBasePrx
54  getSegment(const ::std::string& segName,
55  const ::Ice::Current& = Ice::emptyCurrent) override;
56  bool hasSegment(const ::std::string& segName,
57  const ::Ice::Current& = Ice::emptyCurrent) override;
58  NameList getSegmentNames(const ::Ice::Current& = Ice::emptyCurrent) override;
59  void clear(const ::Ice::Current& = Ice::emptyCurrent) override;
60 
61  /*!
62  * \brief Save all segments with all entities of the WorkingMemory to this snapshot.
63  * \param workingMemory The WorkingMemory to save.
64  */
65  void saveWorkingMemory(const AbstractWorkingMemoryInterfacePrx& workingMemory,
66  const ::Ice::Current& = Ice::emptyCurrent) override;
67  void saveWorkingMemorySubset(const AbstractWorkingMemoryInterfacePrx& workingMemory,
68  const Ice::StringSeq& entityIdList,
69  const ::Ice::Current& = Ice::emptyCurrent) override;
70 
71  /*!
72  * \brief Restore all segments with all entities of this snapshot to the WorkingMemory.
73  * \param workingMemory The WorkingMemory to restore.
74  */
75  void restoreWorkingMemory(const AbstractWorkingMemoryInterfacePrx& workingMemory,
76  const ::Ice::Current& = Ice::emptyCurrent) override;
77 
78  public:
79  Ice::Identity getIceId() const;
80  SegmentMap getSegmentAndCollectionNames() const;
81 
82  public: // serialization.
83  void serialize(const armarx::ObjectSerializerBasePtr& serializer,
84  const ::Ice::Current& = Ice::emptyCurrent) const override;
85  void deserialize(const armarx::ObjectSerializerBasePtr& serializer,
86  const ::Ice::Current& = Ice::emptyCurrent) override;
87 
88  private:
89  std::string name;
90  SegmentMap segmentNames;
91 
93  const DatabaseInterfacePrx& databasePrx;
94  Ice::Identity iceId;
95  std::map<Ice::Identity, PersistentEntitySegmentBasePtr> openedSegments;
96 
97  std::string getSegmentCollectionName(const std::string& segName);
98  PersistentEntitySegmentPtr getSegmentPtr(const std::string& segName);
99  PersistentEntitySegmentPtr addSegmentPtr(const std::string& segName);
100  void addSegmentToMap(const std::string& segName);
101  };
102 
103 } // namespace memoryx
cyberglove_with_calib_22dof.ic
ic
Definition: cyberglove_with_calib_22dof.py:22
PersistentEntitySegment.h
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
IceInternal::Handle<::Ice::Communicator >
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
memoryx::WorkingMemorySnapshot
The WorkingMemorySnapshot class handles snapshot IO methods.
Definition: WorkingMemorySnapshot.h:41
memoryx::SegmentMap
std::map< std::string, std::string > SegmentMap
Definition: WorkingMemorySnapshot.h:33
IceUtil::Handle
Definition: forward_declarations.h:30
ImportExportComponent.h