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 
27 #include <MemoryX/interface/core/MemoryInterface.h>
28 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
29 
31 
32 namespace memoryx
33 {
34  using SegmentMap = std::map<std::string, std::string>;
35 
36  /*!
37  * \brief The WorkingMemorySnapshot class handles snapshot IO methods.
38  *
39  * Snapshots can be loaded and restored from the database.
40  *
41  */
43  virtual public WorkingMemorySnapshotInterface
44  {
45  public:
46  WorkingMemorySnapshot(const std::string& name, Ice::CommunicatorPtr ic, const DatabaseInterfacePrx& databasePrx);
47 
48  // implementation of WorkingMemorySnapshotInterface methods
49  PersistentEntitySegmentBasePrx addSegment(const ::std::string& segName, const ::Ice::Current& = Ice::emptyCurrent) override;
50  PersistentEntitySegmentBasePrx getSegment(const ::std::string& segName, const ::Ice::Current& = Ice::emptyCurrent) override;
51  bool hasSegment(const ::std::string& segName, const ::Ice::Current& = Ice::emptyCurrent) override;
52  NameList getSegmentNames(const ::Ice::Current& = Ice::emptyCurrent) override;
53  void clear(const ::Ice::Current& = Ice::emptyCurrent) override;
54 
55  /*!
56  * \brief Save all segments with all entities of the WorkingMemory to this snapshot.
57  * \param workingMemory The WorkingMemory to save.
58  */
59  void saveWorkingMemory(const AbstractWorkingMemoryInterfacePrx& workingMemory, const ::Ice::Current& = Ice::emptyCurrent) override;
60  void saveWorkingMemorySubset(const AbstractWorkingMemoryInterfacePrx& workingMemory, const Ice::StringSeq& entityIdList, const ::Ice::Current& = Ice::emptyCurrent) override;
61 
62  /*!
63  * \brief Restore all segments with all entities of this snapshot to the WorkingMemory.
64  * \param workingMemory The WorkingMemory to restore.
65  */
66  void restoreWorkingMemory(const AbstractWorkingMemoryInterfacePrx& workingMemory, const ::Ice::Current& = Ice::emptyCurrent) override;
67 
68  public:
69  Ice::Identity getIceId() const;
70  SegmentMap getSegmentAndCollectionNames() const;
71 
72  public: // serialization.
73  void serialize(const armarx::ObjectSerializerBasePtr& serializer, const ::Ice::Current& = Ice::emptyCurrent) const override;
74  void deserialize(const armarx::ObjectSerializerBasePtr& serializer, const ::Ice::Current& = Ice::emptyCurrent) override;
75 
76  private:
77  std::string name;
78  SegmentMap segmentNames;
79 
81  const DatabaseInterfacePrx& databasePrx;
82  Ice::Identity iceId;
83  std::map<Ice::Identity, PersistentEntitySegmentBasePtr> openedSegments;
84 
85  std::string getSegmentCollectionName(const std::string& segName);
86  PersistentEntitySegmentPtr getSegmentPtr(const std::string& segName);
87  PersistentEntitySegmentPtr addSegmentPtr(const std::string& segName);
88  void addSegmentToMap(const std::string& segName);
89  };
90 
91 }
92 
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:523
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
memoryx::WorkingMemorySnapshot
The WorkingMemorySnapshot class handles snapshot IO methods.
Definition: WorkingMemorySnapshot.h:42
memoryx::SegmentMap
std::map< std::string, std::string > SegmentMap
Definition: WorkingMemorySnapshot.h:34
IceUtil::Handle
Definition: forward_declarations.h:29
ImportExportComponent.h