iceoryx_doc  1.0.1
mepoo_segment.hpp
1 // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2 // Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 // SPDX-License-Identifier: Apache-2.0
17 #ifndef IOX_POSH_MEPOO_MEPOO_SEGMENT_HPP
18 #define IOX_POSH_MEPOO_MEPOO_SEGMENT_HPP
19 
20 #include "iceoryx_posh/internal/mepoo/memory_manager.hpp"
21 #include "iceoryx_posh/mepoo/memory_info.hpp"
22 #include "iceoryx_posh/mepoo/mepoo_config.hpp"
23 #include "iceoryx_utils/internal/posix_wrapper/access_control.hpp"
24 #include "iceoryx_utils/internal/posix_wrapper/shared_memory_object.hpp"
25 #include "iceoryx_utils/internal/posix_wrapper/shared_memory_object/allocator.hpp"
26 #include "iceoryx_utils/posix_wrapper/posix_access_rights.hpp"
27 
28 namespace iox
29 {
30 namespace mepoo
31 {
32 template <typename SharedMemoryObjectType = posix::SharedMemoryObject, typename MemoryManagerType = MemoryManager>
34 {
35  public:
36  MePooSegment(const MePooConfig& mempoolConfig,
37  posix::Allocator& managementAllocator,
38  const posix::PosixGroup& readerGroup,
39  const posix::PosixGroup& writerGroup,
40  const iox::mepoo::MemoryInfo& memoryInfo = iox::mepoo::MemoryInfo()) noexcept;
41 
42  posix::PosixGroup getWriterGroup() const noexcept;
43  posix::PosixGroup getReaderGroup() const noexcept;
44  const SharedMemoryObjectType& getSharedMemoryObject() const noexcept;
45  MemoryManagerType& getMemoryManager() noexcept;
46 
47  uint64_t getSegmentId() const noexcept;
48 
49  protected:
50  SharedMemoryObjectType createSharedMemoryObject(const MePooConfig& mempoolConfig,
51  const posix::PosixGroup& writerGroup) noexcept;
52 
53  protected:
54  SharedMemoryObjectType m_sharedMemoryObject;
55  MemoryManagerType m_memoryManager;
56  posix::PosixGroup m_readerGroup;
57  posix::PosixGroup m_writerGroup;
58  uint64_t m_segmentId;
59  iox::mepoo::MemoryInfo m_memoryInfo;
60 
61  private:
62  void setSegmentId(const uint64_t segmentId) noexcept;
63 };
64 } // namespace mepoo
65 } // namespace iox
66 
67 #include "iceoryx_posh/internal/mepoo/mepoo_segment.inl"
68 
69 #endif // IOX_POSH_MEPOO_MEPOO_SEGMENT_HPP
Definition: mepoo_segment.hpp:34
Definition: service_description.hpp:29
Definition: mepoo_config.hpp:33
Stores properties of the memory to be used when we distinguish between different types of memory on e...
Definition: memory_info.hpp:28