72 static std::string
getFilePath(
const std::string& path);
88 const std::string& path);
99 static bool isSocket(
const std::string& name);
112 static bool isAbsolute(
const std::string& path);
127 const std::string& basePath);
145 static std::ostream&
writeInt(std::ostream& strm,
int value);
154 static std::ostream&
writeUInt(std::ostream& strm,
unsigned int value);
174 static std::ostream&
writeByte(std::ostream& strm,
unsigned char value);
187 static std::ostream&
writeString(std::ostream& strm,
const std::string& value);
208 template <
typename E>
209 static std::ostream&
writeEdgeVector(std::ostream& os,
const std::vector<E>& edges);
218 template <
typename E>
219 static void readEdgeVector(std::istream& in, std::vector<const E*>& edges,
const std::string& rid);
226 template <
typename E>
229 std::vector<unsigned int> follow;
230 unsigned int maxFollow = 0;
231 E prev = edges.front();
232 for (
typename std::vector<E>::const_iterator i = edges.begin() + 1; i != edges.end(); ++i) {
233 unsigned int idx = 0;
234 for (; idx < prev->getNumSuccessors(); ++idx) {
238 if (prev->getSuccessors()[idx] == (*i)) {
239 follow.push_back(idx);
240 if (idx > maxFollow) {
246 if (idx > 15 || idx == prev->getNumSuccessors()) {
252 if (follow.empty()) {
253 for (
typename std::vector<E>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
257 const int bits = maxFollow > 3 ? 4 : 2;
258 const unsigned int numFields = 8 *
sizeof(
unsigned int) / bits;
261 unsigned int data = 0;
262 unsigned int field = 0;
263 for (std::vector<unsigned int>::const_iterator i = follow.begin(); i != follow.end(); ++i) {
266 if (field == numFields) {
282 template <
typename E>
285 in.read((
char*) &size,
sizeof(
int));
288 in.read((
char*) &bitsOrEntry,
sizeof(
int));
289 if (bitsOrEntry < 0) {
290 const unsigned int bits = -bitsOrEntry;
291 const unsigned int numFields = 8 *
sizeof(
unsigned int) / bits;
292 const unsigned int mask = (1 << bits) - 1;
294 in.read((
char*) &edgeID,
sizeof(
int));
295 const E* prev = E::getAllEdges()[edgeID];
297 edges.push_back(prev);
299 unsigned int data = 0;
300 unsigned int field = numFields;
301 for (; size > 0; size--) {
302 if (field == numFields) {
303 in.read((
char*) &data,
sizeof(
int));
306 unsigned int followIndex = (data >> ((numFields - field - 1) * bits)) & mask;
307 if (followIndex >= prev->getNumSuccessors()) {
308 throw ProcessError(
"Invalid follower index in route '" + rid +
"'!");
310 prev = prev->getSuccessors()[followIndex];
311 edges.push_back(prev);
316 const E* edge = E::getAllEdges()[bitsOrEntry];
318 throw ProcessError(
"An edge within the route '" + rid +
"' is not known!");
320 edges.push_back(edge);
323 in.read((
char*) &bitsOrEntry,
sizeof(
int));
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
static std::string prependToLastPathComponent(const std::string &prefix, const std::string &path)
prepend the given prefix to the last path component of the given file path
static bool isReadable(std::string path)
Checks whether the given file is readable.
static bool isSocket(const std::string &name)
Returns the information whether the given name represents a socket.
static std::ostream & writeFloat(std::ostream &strm, SUMOReal value)
Writes a float binary.
static std::ostream & writeUInt(std::ostream &strm, unsigned int value)
Writes an unsigned integer binary.
static std::ostream & writeTime(std::ostream &strm, SUMOTime value)
Writes a time description binary.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
Functions for an easier usage of files and paths.
static std::ostream & writeInt(std::ostream &strm, int value)
Writes an integer binary.
static std::ostream & writeByte(std::ostream &strm, unsigned char value)
Writes a byte binary.
static std::string checkForRelativity(const std::string &filename, const std::string &basePath)
Returns the path from a configuration so that it is accessable from the current working directory...
static void readEdgeVector(std::istream &in, std::vector< const E * > &edges, const std::string &rid)
Reads an edge vector binary.
static std::ostream & writeEdgeVector(std::ostream &os, const std::vector< E > &edges)
Writes an edge vector binary.
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
static std::ostream & writeString(std::ostream &strm, const std::string &value)
Writes a string binary.