Maintain storage_config exposed API

This commit is contained in:
Pepijn Schoen
2017-07-07 16:42:07 +02:00
committed by Daniel J. H
parent 0b5c7a97a7
commit 8da40419ee
13 changed files with 52 additions and 34 deletions
+15 -14
View File
@@ -23,6 +23,21 @@ struct IOConfig
{
}
bool IsValid() const;
boost::filesystem::path GetPath(const std::string &fileName) const
{
if (!IsConfigured(fileName, required_input_files) &&
!IsConfigured(fileName, optional_input_files) && !IsConfigured(fileName, output_files))
{
throw util::exception("Tried to access file which is not configured: " + fileName);
}
return {base_path.string() + fileName};
}
boost::filesystem::path base_path;
protected:
// Infer the base path from the path of the .osrm file
void UseDefaultOutputNames(const boost::filesystem::path &base)
{
@@ -45,20 +60,6 @@ struct IOConfig
base_path = {path};
}
bool IsValid() const;
boost::filesystem::path GetPath(const std::string &fileName) const
{
if (!IsConfigured(fileName, required_input_files) &&
!IsConfigured(fileName, optional_input_files) && !IsConfigured(fileName, output_files))
{
throw util::exception("Tried to access file which is not configured: " + fileName);
}
return {base_path.string() + fileName};
}
boost::filesystem::path base_path;
private:
static bool IsConfigured(const std::string &fileName,
const std::vector<boost::filesystem::path> &paths)
+5
View File
@@ -44,6 +44,11 @@ namespace storage
*/
struct StorageConfig final : IOConfig
{
StorageConfig(const boost::filesystem::path &base) : StorageConfig()
{
IOConfig::UseDefaultOutputNames(base);
}
StorageConfig()
: IOConfig({".osrm.ramIndex",
".osrm.fileIndex",