2016-11-14 21:34:39 -05:00
|
|
|
#ifndef PROCESS_MEMORY_DATAFACADE_HPP
|
|
|
|
#define PROCESS_MEMORY_DATAFACADE_HPP
|
2016-10-24 23:27:56 -04:00
|
|
|
|
|
|
|
// implements all data storage when shared memory is _NOT_ used
|
|
|
|
|
2016-11-14 21:34:39 -05:00
|
|
|
#include "engine/datafacade/contiguous_internalmem_datafacade_base.hpp"
|
2016-10-24 23:27:56 -04:00
|
|
|
#include "storage/storage.hpp"
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace engine
|
|
|
|
{
|
|
|
|
namespace datafacade
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This datafacade uses a process-local memory block to load
|
|
|
|
* data into. The structure and layout is the same as when using
|
2016-11-14 21:34:39 -05:00
|
|
|
* shared memory, so this class, and the SharedMemoryDataFacade both
|
2016-10-24 23:27:56 -04:00
|
|
|
* share a common base.
|
|
|
|
* This class holds a unique_ptr to the memory block, so it
|
|
|
|
* is auto-freed upon destruction.
|
|
|
|
*/
|
2016-11-14 21:34:39 -05:00
|
|
|
class ProcessMemoryDataFacade final : public ContiguousInternalMemoryDataFacadeBase
|
2016-10-24 23:27:56 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<char[]> internal_memory;
|
|
|
|
std::unique_ptr<storage::DataLayout> internal_layout;
|
|
|
|
|
|
|
|
public:
|
2016-11-14 21:34:39 -05:00
|
|
|
explicit ProcessMemoryDataFacade(const storage::StorageConfig &config)
|
2016-10-24 23:27:56 -04:00
|
|
|
{
|
|
|
|
storage::Storage storage(config);
|
|
|
|
|
|
|
|
// Calculate the layout/size of the memory block
|
|
|
|
internal_layout = std::make_unique<storage::DataLayout>();
|
2016-11-15 00:44:16 -05:00
|
|
|
storage.PopulateLayout(*internal_layout);
|
2016-10-24 23:27:56 -04:00
|
|
|
|
|
|
|
// Allocate the memory block, then load data from files into it
|
2016-11-14 17:09:04 -05:00
|
|
|
internal_memory = std::make_unique<char[]>(internal_layout->GetSizeOfLayout());
|
2016-11-15 00:44:16 -05:00
|
|
|
storage.PopulateData(*internal_layout, internal_memory.get());
|
2016-10-24 23:27:56 -04:00
|
|
|
|
|
|
|
// Adjust all the private m_* members to point to the right places
|
2016-11-15 02:41:44 -05:00
|
|
|
InitializeInternalPointers(*internal_layout.get(), internal_memory.get());
|
2016-10-24 23:27:56 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-14 21:34:39 -05:00
|
|
|
#endif // PROCESS_MEMORY_DATAFACADE_HPP
|