Skip to content

Commit

Permalink
KSS Parser (#17)
Browse files Browse the repository at this point in the history
* update .gitignore

* add missing iss string literals

* add missing types

* introduce undirected track element

* add test case for de_export

* make all_of constexpr

* fix route iterator

* skip faulty data

* speed limits can now be placed on section elements

* refactor make_piecwise into is_continuous

* disable unnecessary resolve_overlaps for now

* make it compile

* skip test if file does not exist

* update tiles and utl to silence catch2 errors

* ignore some iss files for now

* wip

* add layout option

* add warning message

* wip

* make sassert not constexpr due to stringstream

* finish bitfield

* add duration factory methods

* kss parser wip

* update gitignore

* merge parse-iss into kss-parser

* add interlocking option

* fix resource filepath

* merge parse-iss into kss-parser

* rename test file path

* kss wip

* fix clang warning wrt signedness

* cleanup

* don't use source_location with clang for now

* fix sassert for clangd

* add tuple slice

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix format

* fix windows error

* disable cista build for now

* fix windows build

* fix windows build

* fix windows build

* don't use mmap on windows for now

* fix format

* fix constness

* add msvc-relwithdebinfo

* fix windows release build

* fix format

* dont use ternary in coroutines.?

Co-authored-by: Julian Harbarth <[email protected]>
  • Loading branch information
julianharbarth and Julian Harbarth authored Dec 9, 2022
1 parent 2253ce9 commit 2f8df15
Show file tree
Hide file tree
Showing 202 changed files with 6,943 additions and 10,214 deletions.
1 change: 0 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
- preset: clang-debug
- preset: gcc-release
- preset: gcc-debug
- preset: gcc-cista-debug
- preset: clang-tidy
- preset: clang-sanitizer

Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
.pkg.lock
.pkg.mutex
/CMakeSettings.json
resources/infrastructure/de_iss/
resources/timetable/de_kss/

resources/infrastructure/de_iss
resources/timetable/de_kss
# Ignore the file produced by cmake
test/include/test/file_paths.h
4 changes: 2 additions & 2 deletions .pkg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[cista]
[email protected]:felixguendling/cista.git
branch=master
commit=32e52a0082e89986bb86afad513654fa6a6c1412
branch=nigiri
commit=47633d28d97b50bb128de9d0cc4c879031e5bb1c
[utl]
[email protected]:motis-project/utl.git
branch=master
Expand Down
53 changes: 49 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
"name": "base-preset",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"environment": {
"EMSDK": "${sourceDir}/deps/emsdk/"
}
"binaryDir": "${sourceDir}/build/${presetName}"
},
{
"name": "clang-preset",
Expand Down Expand Up @@ -144,6 +141,17 @@
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "msvc-relwithdebinfo",
"displayName": "MSVC RelWithDebInfo",
"inherits": [
"base-preset",
"msvc-preset"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "msvc-debug",
"displayName": "MSVC Debug",
Expand Down Expand Up @@ -181,6 +189,43 @@
"SORO_CUDA": "On"
}
},
{
"name": "clang-cista-release",
"displayName": "Linux AMD64 Clang CISTA Release",
"inherits": [
"base-preset",
"clang-preset"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"SERIALIZE": "On"
}
},
{
"name": "clang-cista-debug",
"displayName": "Linux AMD64 Clang CISTA Debug",
"inherits": [
"base-preset",
"clang-preset"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"SERIALIZE": "On"
}
},
{
"name": "clang-cista-sanitizer",
"displayName": "Linux AMD64 Clang CISTA Sanitizer",
"inherits": [
"base-preset",
"clang-preset"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"SERIALIZE": "On",
"SORO_SAN": "On"
}
},
{
"name": "gcc-cista-release",
"displayName": "Linux AMD64 GCC CISTA Release",
Expand Down
42 changes: 21 additions & 21 deletions cmake/soro-server-client.cmake
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# This file is responsible for building the soro-server,
# which includes the soro-client build with emscripten

# For this to work it is necessary that the environment variable
# EMSDK=/path/to/emsdk/
# is set.
# which includes the soro-client

add_custom_target(soro-server-client)

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

if (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
# Gets us the soro-client interface (using emscripten)
add_subdirectory(web/client)
else ()
# SERVER
set(SORO_SERVER_DIR ${CMAKE_CURRENT_BINARY_DIR})
file(MAKE_DIRECTORY ${SORO_SERVER_DIR})
# SERVER
set(SORO_SERVER_DIR ${CMAKE_CURRENT_BINARY_DIR})
file(MAKE_DIRECTORY ${SORO_SERVER_DIR})

add_subdirectory(web/server/)
add_dependencies(soro-server-client soro-server)

add_subdirectory(web/server/)
add_dependencies(soro-server-client soro-server)
# CLIENT
file(GLOB_RECURSE soro-client-files
web/client/*.html
web/client/*.css
web/client/*.js
web/client/*.ico
web/client/*.png
web/client/*.svg
web/client/*.map)

file(GLOB_RECURSE soro-client-files web/client/ *.html *.css *.js *.ico *.png *.svg *.map)
foreach (file ${soro-client-files})
set(path ${file})
cmake_path(RELATIVE_PATH path BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/web/client OUTPUT_VARIABLE relative-path)
configure_file(${file} ${SORO_SERVER_DIR}/server_resources/${relative-path} COPYONLY)
endforeach ()
endif ()
foreach (file ${soro-client-files})
set(path ${file})
cmake_path(RELATIVE_PATH path BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/web/client/ OUTPUT_VARIABLE relative-path)
configure_file(${file} ${SORO_SERVER_DIR}/server_resources/${relative-path} COPYONLY)
endforeach ()
6 changes: 3 additions & 3 deletions include/soro/base/fp_precision.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
#include <cmath>
#include <concepts>

#include "soro/utls/sassert.h"

namespace soro {

template <std::floating_point T>
constexpr T const FP_PRECISION = T(0.01);

template <std::floating_point T>
constexpr bool equal(T const a, T const b) noexcept {
assert(!std::isnan(a));
assert(!std::isnan(b));

utls::sassert(!std::isnan(a) && !std::isnan(b), "Never compare with nan.");
return std::abs(a - b) < FP_PRECISION<T>;
}

Expand Down
23 changes: 15 additions & 8 deletions include/soro/base/soro_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ using set = data::hash_set<T>;
template <typename T>
using vector = data::vector<T>;

using size_type = uint32_t;
using size_t = uint32_t;

template <typename T, std::size_t Size>
using array = data::array<T, Size>;
Expand All @@ -86,6 +86,12 @@ constexpr inline auto tuple_size_v = cista::tuple_size_v<Tuple>;
template <std::size_t I, typename Tuple>
using tuple_element_t = cista::tuple_element_t<I, Tuple>;

template <typename T>
static constexpr bool const is_pointer_v = cista::is_pointer_v<T>;

template <typename T>
using remove_pointer_t = cista::remove_pointer_t<T>;

#else

template <typename T>
Expand All @@ -103,16 +109,16 @@ using pair = std::pair<T1, T2>;
template <typename... Ts>
using tuple = std::tuple<Ts...>;

template <typename Key, typename Value>
using map = std::map<Key, Value>;
template <typename Key, typename Value, typename Comparator = std::less<> >
using map = std::map<Key, Value, Comparator>;

template <typename T>
using set = data::hash_set<T>;

template <typename ValueType>
using vector = std::vector<ValueType>;

using size_type = size_t;
using size_t = std::size_t;

template <typename ValueType, std::size_t Size>
using array = data::array<ValueType, Size>;
Expand All @@ -137,11 +143,12 @@ constexpr inline auto tuple_size_v = std::tuple_size_v<Tuple>;
template <std::size_t I, typename Tuple>
using tuple_element_t = std::tuple_element_t<I, Tuple>;

#endif
template <typename T>
static constexpr bool const is_pointer_v = std::is_pointer_v<T>;

template <typename T>
constexpr bool is_pointer() {
return std::is_pointer_v<T> || cista::is_pointer_v<T>;
}
using remove_pointer_t = std::remove_pointer_t<T>;

#endif

} // namespace soro
66 changes: 66 additions & 0 deletions include/soro/base/time.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#pragma once

#include <chrono>

#include "date/date.h"
#include "fmt/format.h"

#include "soro/utls/concepts/is_any_of.h"

namespace soro {

namespace sc = std::chrono;

using i32_seconds = sc::duration<uint32_t, sc::seconds::period>;
using i64_seconds = sc::duration<uint64_t, sc::seconds::period>;
using seconds = i32_seconds;
using minutes = sc::duration<uint32_t, sc::minutes::period>;
using hours = sc::duration<uint32_t, sc::hours::period>;
using days = sc::duration<uint32_t, sc::days::period>;

// an absolute point in time, given as a count of non-leap seconds
// since unix epoch (1970/01/01/ 00:00:00)
// same as sc::time_point<sc::system_clock, sc::seconds>
using absolute_time = date::sys_time<i32_seconds>;

// relative point in time wrt to an anchor point
// given as a count of non-leap seconds since an absolute time (the anchor)
using relative_time = i32_seconds;

using duration2 = i32_seconds;

constexpr absolute_time relative_to_absolute(absolute_time const anchor,
relative_time const relative) {
return sc::time_point_cast<absolute_time::duration>(anchor) + relative;
}

template <typename T>
concept soro_time = utls::is_any_of<T, absolute_time, relative_time, duration2>;

template <soro_time T>
constexpr T const INVALID = T::max();

template <soro_time T>
constexpr bool valid(T const t) {
return t != INVALID<T>;
}

} // namespace soro

template <>
struct fmt::formatter<soro::absolute_time> {
constexpr auto parse(format_parse_context& ctx) // NOLINT
-> decltype(ctx.begin()) {
if (ctx.begin() != ctx.end() && *ctx.begin() != '}') {
throw format_error("invalid format for anchor time");
}

return ctx.begin();
}

template <typename FormatContext>
auto format(soro::absolute_time const at, FormatContext& ctx) const
-> decltype(ctx.out()) {
return fmt::format_to(ctx.out(), "{}", at);
}
};
Loading

0 comments on commit 2f8df15

Please sign in to comment.