Xyris  0.5
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
MemoryMap.hpp
Go to the documentation of this file.
1 /**
2  * @file MemoryMap.hpp
3  * @author Keeton Feavel (keeton@xyr.is)
4  * @brief Memory map containing a number of Memory sections
5  * that describe the physical memory layout
6  * @version 0.1
7  * @date 2021-09-12
8  *
9  * @copyright Copyright the Xyris Contributors (c) 2021
10  *
11  */
12 #pragma once
13 #include <Memory/MemorySection.hpp>
14 
15 namespace Memory {
16 
17 class MemoryMap {
18 public:
19 
20  /**
21  * @brief Returns the max number of memory sections allowed in a MemoryMap
22  *
23  * @return size_t Max number of entries
24  */
25  size_t Count()
26  {
27  return m_max_sections;
28  }
29 
30  /**
31  * @brief Returns a reference to the memory section at the given index
32  *
33  * @param idx Memory section index
34  * @return Section& Section at index available for updating
35  */
36  Section& Get(size_t idx)
37  {
38  return m_sections[idx];
39  }
40 
41  /**
42  * @brief Getter bracket operator. Returns a copy of the Memory::Section at
43  * the provided index.
44  *
45  * @param idx Memory section index
46  * @return Section Copy of the Memory::Section
47  */
48  Section operator[](size_t idx) const
49  {
50  return m_sections[idx];
51  }
52 
53  /**
54  * @brief Getter bracket operator. Returns a reference to the Memory::Section at
55  * the provided index.
56  *
57  * @param idx Memory section index
58  * @return Section& Reference to the Memory::Section
59  */
60  Section& operator[](size_t idx)
61  {
62  return m_sections[idx];
63  }
64 
65 private:
66  // TODO: Set some sort of counter that indicates how many were inserted
67  static const size_t m_max_sections = 32;
69 };
70 
71 } // !namespace Memory
Memory
Definition: MemoryMap.hpp:15
Memory::MemoryMap::m_max_sections
static const size_t m_max_sections
Definition: MemoryMap.hpp:67
Memory::MemoryMap::operator[]
Section & operator[](size_t idx)
Getter bracket operator. Returns a reference to the Memory::Section at the provided index.
Definition: MemoryMap.hpp:60
MemorySection.hpp
Memory::MemoryMap::Count
size_t Count()
Returns the max number of memory sections allowed in a MemoryMap.
Definition: MemoryMap.hpp:25
Memory::MemoryMap
Definition: MemoryMap.hpp:17
Memory::Section
Definition: MemorySection.hpp:29
Memory::MemoryMap::operator[]
Section operator[](size_t idx) const
Getter bracket operator. Returns a copy of the Memory::Section at the provided index.
Definition: MemoryMap.hpp:48
Memory::MemoryMap::Get
Section & Get(size_t idx)
Returns a reference to the memory section at the given index.
Definition: MemoryMap.hpp:36
Memory::MemoryMap::m_sections
Section m_sections[m_max_sections]
Definition: MemoryMap.hpp:68