First implementation of moving the algorithmic core into a library

This commit is contained in:
Dennis Luxen
2013-06-26 19:47:47 -04:00
parent 4430cbc3cb
commit bfef8f39b7
7 changed files with 53 additions and 70 deletions
+11 -5
View File
@@ -21,12 +21,12 @@ or see http://www.gnu.org/licenses/agpl.txt.
#ifndef BASECONFIGURATION_H_
#define BASECONFIGURATION_H_
#include <iostream>
#include <string>
#include "../DataStructures/HashTable.h"
#include <exception>
#include <fstream>
#include "../DataStructures/HashTable.h"
#include <iostream>
#include <string>
class BaseConfiguration {
public:
@@ -73,7 +73,11 @@ public:
}
private:
void Tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters = "=") {
void Tokenize(
const std::string& str,
std::vector<std::string>& tokens,
const std::string& delimiters = "="
) {
std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
std::string::size_type pos = str.find_first_of(delimiters, lastPos);
@@ -86,6 +90,7 @@ private:
pos = str.find_first_of(delimiters, lastPos);
}
}
void TrimStringRight(std::string& str) {
std::string::size_type pos = str.find_last_not_of(" ");
if (pos != std::string::npos)
@@ -93,6 +98,7 @@ private:
else
str.erase( str.begin() , str.end() );
}
void TrimStringLeft(std::string& str) {
std::string::size_type pos = str.find_first_not_of(" ");
if (pos != std::string::npos)
+2 -2
View File
@@ -21,10 +21,10 @@ or see http://www.gnu.org/licenses/agpl.txt.
#ifndef INPUTFILEUTIL_H_
#define INPUTFILEUTIL_H_
#include <boost/filesystem.hpp>
#include "../typedefs.h"
#include <boost/filesystem.hpp>
// Check if file exists and if it can be opened for reading with ifstream an object
inline bool testDataFile(const std::string & filename){
boost::filesystem::path fileToTest(filename);
-1
View File
@@ -25,7 +25,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include <string>
#ifdef __linux__
#include <cxxabi.h>
#include <execinfo.h>
+11 -11
View File
@@ -1,17 +1,17 @@
/*
open source routing machine
Copyright (C) Dennis Luxen, others 2010
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -23,11 +23,11 @@
#if defined(__APPLE__) || defined(__FreeBSD__)
extern "C" {
#include <sys/types.h>
#include <sys/sysctl.h>
}
#include <sys/types.h>
#include <sys/sysctl.h>
}
#elif defined _WIN32
#include <windows.h>
#include <windows.h>
#endif
enum Endianness {
@@ -55,28 +55,28 @@ inline unsigned swapEndian(unsigned x) {
inline unsigned GetPhysicalmemory(void){
#if defined(SUN5) || defined(__linux__)
return (sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE));
#elif defined(__APPLE__)
int mib[2] = {CTL_HW, HW_MEMSIZE};
long long memsize;
size_t len = sizeof(memsize);
sysctl(mib, 2, &memsize, &len, NULL, 0);
return memsize/1024;
#elif defined(__FreeBSD__)
int mib[2] = {CTL_HW, HW_PHYSMEM};
long long memsize;
size_t len = sizeof(memsize);
sysctl(mib, 2, &memsize, &len, NULL, 0);
return memsize/1024;
#elif defined(_WIN32)
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
GlobalMemoryStatusEx(&status);
return status.ullTotalPhys/1024;
#else
std::cout << "[Warning] Compiling on unknown architecture." << std::endl
std::cout << "[Warning] Compiling on unknown architecture." << std::endl
<< "Please file a ticket at http://project-osrm.org" << std::endl;
return 2048*1024; /* 128 Mb default memory */
+5 -5
View File
@@ -23,12 +23,12 @@ or see http://www.gnu.org/licenses/agpl.txt.
#define _OPENMPREPLACEMENTY_H
#ifdef _OPENMP
#include <omp.h>
#include <omp.h>
#else
inline const int omp_get_num_procs() { return 1; }
inline const int omp_get_max_threads() { return 1; }
inline const int omp_get_thread_num() { return 0; }
inline const void omp_set_num_threads(int i) {}
inline const int omp_get_num_procs() { return 1; }
inline const int omp_get_max_threads() { return 1; }
inline const int omp_get_thread_num() { return 0; }
inline const void omp_set_num_threads(int i) {}
#endif
#endif
+4 -3
View File
@@ -21,6 +21,10 @@ or see http://www.gnu.org/licenses/agpl.txt.
#ifndef STRINGUTIL_H_
#define STRINGUTIL_H_
#include "../DataStructures/Coordinate.h"
#include "../typedefs.h"
#include <string>
#include <boost/algorithm/string.hpp>
@@ -29,9 +33,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include <cstdio>
#include "../DataStructures/Coordinate.h"
#include "../typedefs.h"
// precision: position after decimal point
// length: maximum number of digits including comma and decimals
template< int length, int precision >