#pragma once #include #include #include #include #include #include "TargetMemory.hpp" #include "TargetMemorySegmentDescriptor.hpp" namespace Targets { using TargetAddressSpaceDescriptorId = std::uint8_t; struct TargetAddressSpaceDescriptor { public: const TargetAddressSpaceDescriptorId id; std::string key; TargetMemoryAddressRange addressRange; TargetMemoryEndianness endianness; std::map segmentDescriptorsByKey; TargetAddressSpaceDescriptor( const std::string& key, const TargetMemoryAddressRange& addressRange, TargetMemoryEndianness endianness, const std::map& segmentDescriptorsByKey ); TargetMemorySize size() const; /** * Attempts to fetch a memory segment descriptor with the given key. * * @param key * The key of the memory segment descriptor to lookup. * * @return * A reference wrapper of the memory segment descriptor, if found. Otherwise, std::nullopt. */ std::optional> tryGetMemorySegmentDescriptor( const std::string& key ) const; /** * Fetches a memory segment descriptor with the given key. If the descriptor doesn't exist, an * InternalFatalErrorException is thrown. * * @param key * The key of the memory segment descriptor to lookup. * * @return * A reference to the memory segment descriptor. */ const TargetMemorySegmentDescriptor& getMemorySegmentDescriptor(const std::string& key) const; private: static inline std::atomic lastAddressSpaceDescriptorId = 0; }; }