1 /* Copyright (c) 2008-2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef MC_ADDRESS_SPACE_H
8 #define MC_ADDRESS_SPACE_H
11 #include <type_traits>
17 #include "mc_forward.h"
22 /** Process index used when no process is available
24 * The expected behaviour is that if a process index is needed it will fail.
26 const int ProcessIndexMissing = -1;
28 /** Process index used when we don't care about the process index
30 const int ProcessIndexDisabled = -2;
32 /** Constant used when any process will do.
34 * This is is index of the first process.
36 const int ProcessIndexAny = 0;
42 /** Allows the `read_bytes` to return a pointer to another buffer
43 * where the data ins available instead of copying the data into the buffer
47 virtual ~AddressSpace();
48 virtual const void* read_bytes(void* buffer, std::size_t size,
49 std::uint64_t address, int process_index = ProcessIndexAny,
50 ReadMode mode = Normal) = 0;
52 T read(uint64_t address, int process_index = ProcessIndexMissing)
54 static_assert(std::is_trivial<T>::value, "Cannot read a non-trivial type");
56 return *(T*)this->read_bytes(&res, sizeof(T), address, process_index);