SegmentedMemory.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::Core
17 * @author ALexey Kozlov ( kozlov at kit dot edu)
18 * @date 2013
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 // Ice
26 #include <shared_mutex>
27 
28 #include <Ice/ObjectAdapter.h>
29 
30 #include <MemoryX/interface/core/MemoryInterface.h>
31 
32 namespace memoryx
33 {
34 
36  {
37  AbstractMemorySegmentPrx proxy;
38  AbstractMemorySegmentPtr pointer;
39  };
40 
41  using MemorySegmentMap = std::map<std::string, MemorySegmentEntry>;
42 
43  /*!
44  * \brief The SegmentedMemory class provides an interface for organizing memories with segmented data structures.
45  */
46  class SegmentedMemory : virtual public MemoryInterface
47  {
48  protected:
49  ~SegmentedMemory() override;
50 
51  public:
53 
54 
55  AbstractMemorySegmentPrx addSegment(const std::string& segmentName,
56  const AbstractMemorySegmentPtr& segment,
57  const ::Ice::Current& = Ice::emptyCurrent) override;
58  bool hasSegment(const std::string& segmentName,
59  const ::Ice::Current& = Ice::emptyCurrent) const override;
60  AbstractMemorySegmentPrx
61  getSegment(const std::string& segmentName,
62  const ::Ice::Current& = Ice::emptyCurrent) const override;
63  void removeSegment(const std::string& segmentName,
64  const ::Ice::Current& = Ice::emptyCurrent) override;
65  NameList getSegmentNames(const ::Ice::Current& = Ice::emptyCurrent) const override;
66 
67  EntityBasePtr findEntityById(const std::string& entityId,
68  const Ice::Current& c = Ice::emptyCurrent) override;
69  EntityRefBasePtr findEntityRefById(const std::string& entityId,
70  const Ice::Current& c = Ice::emptyCurrent) override;
71 
72  AbstractMemorySegmentPtr getSegmentPtr(const std::string& segmentName);
73 
74  virtual Ice::ObjectAdapterPtr getObjectAdapter() const = 0;
75 
76  protected:
78  mutable std::shared_mutex segmentsMutex;
79  };
80 
82 
83 } // namespace memoryx
memoryx::SegmentedMemory::segments
MemorySegmentMap segments
Definition: SegmentedMemory.h:77
memoryx::SegmentedMemory::SegmentedMemory
SegmentedMemory()
Definition: SegmentedMemory.cpp:32
memoryx::SegmentedMemory::getSegmentPtr
AbstractMemorySegmentPtr getSegmentPtr(const std::string &segmentName)
Definition: SegmentedMemory.cpp:133
memoryx::SegmentedMemory::addSegment
AbstractMemorySegmentPrx addSegment(const std::string &segmentName, const AbstractMemorySegmentPtr &segment, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: SegmentedMemory.cpp:41
memoryx::SegmentedMemory::segmentsMutex
std::shared_mutex segmentsMutex
Definition: SegmentedMemory.h:78
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
memoryx::SegmentedMemory::getObjectAdapter
virtual Ice::ObjectAdapterPtr getObjectAdapter() const =0
memoryx::MemorySegmentMap
std::map< std::string, MemorySegmentEntry > MemorySegmentMap
Definition: SegmentedMemory.h:41
memoryx::SegmentedMemory::hasSegment
bool hasSegment(const std::string &segmentName, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: SegmentedMemory.cpp:74
memoryx::SegmentedMemory
The SegmentedMemory class provides an interface for organizing memories with segmented data structure...
Definition: SegmentedMemory.h:46
IceInternal::Handle<::Ice::ObjectAdapter >
memoryx::MemorySegmentEntry::proxy
AbstractMemorySegmentPrx proxy
Definition: SegmentedMemory.h:37
memoryx::SegmentedMemory::findEntityRefById
EntityRefBasePtr findEntityRefById(const std::string &entityId, const Ice::Current &c=Ice::emptyCurrent) override
Definition: SegmentedMemory.cpp:176
memoryx::MemorySegmentEntry
Definition: SegmentedMemory.h:35
memoryx::SegmentedMemory::findEntityById
EntityBasePtr findEntityById(const std::string &entityId, const Ice::Current &c=Ice::emptyCurrent) override
Definition: SegmentedMemory.cpp:150
memoryx::MemorySegmentEntry::pointer
AbstractMemorySegmentPtr pointer
Definition: SegmentedMemory.h:38
memoryx::SegmentedMemory::removeSegment
void removeSegment(const std::string &segmentName, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: SegmentedMemory.cpp:98
memoryx::SegmentedMemory::getSegment
AbstractMemorySegmentPrx getSegment(const std::string &segmentName, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: SegmentedMemory.cpp:81
memoryx::SegmentedMemory::~SegmentedMemory
~SegmentedMemory() override
Definition: SegmentedMemory.cpp:36
memoryx::SegmentedMemory::getSegmentNames
NameList getSegmentNames(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: SegmentedMemory.cpp:118