Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project structure and c++ trace file reader/writer #2

Merged
merged 85 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
3534dcb
Project structure and tracefile reader/writer poc
TimmRuppert Oct 25, 2024
ae140d9
Add proto dep
TimmRuppert Oct 25, 2024
83796a5
update workflow artifact up/download to v4 in hope of preserving file…
TimmRuppert Oct 25, 2024
299956c
Split workflows, disable CI format check and fix minor lint warnings
TimmRuppert Oct 28, 2024
f9e380b
Rename workflows
TimmRuppert Oct 28, 2024
c66deda
Ignore tests for linting
TimmRuppert Oct 28, 2024
4342224
Made linting not fail fast
TimmRuppert Oct 28, 2024
292d220
Fix several clang tidy warnings
TimmRuppert Oct 28, 2024
411458e
Wip support for txth reader
TimmRuppert Oct 29, 2024
e70f64a
move parser to private section
TimmRuppert Oct 29, 2024
44b246e
Auto format
TimmRuppert Oct 29, 2024
9dcc389
fix wrong data type
TimmRuppert Oct 29, 2024
d514b7e
reorder structure
TimmRuppert Nov 7, 2024
9f6f0d4
reorder structure - inc tests
TimmRuppert Nov 7, 2024
5b01e8c
Init support txth writer
TimmRuppert Nov 7, 2024
0aaff7f
added init support for native binary writer
TimmRuppert Nov 7, 2024
9815d77
fix missing license identifier and cleanup
TimmRuppert Nov 7, 2024
283b9ce
fix txth and add unit tests
TimmRuppert Nov 7, 2024
0930ecf
added more tests for native binary reader
TimmRuppert Nov 7, 2024
4636346
provide unit tests for NativeBinaryTraceFileWriterTest
TimmRuppert Nov 7, 2024
ac00ac5
ClangTidy cleanup
TimmRuppert Nov 7, 2024
f233925
factory cleanup
TimmRuppert Nov 7, 2024
a7fbebd
add prototype of mcap reader
TimmRuppert Nov 8, 2024
a8c1df8
cleanup rule of 5
TimmRuppert Nov 8, 2024
6d76120
auto format
TimmRuppert Nov 8, 2024
338b109
add documentation
TimmRuppert Nov 8, 2024
c15604f
Merge branch 'main' into 1-add-a-c++-trace-file-readerwriter
ClemensLinnhoff Nov 11, 2024
ebaad77
Minor readme update
ClemensLinnhoff Nov 11, 2024
127b374
Add submodule clone instructions
ClemensLinnhoff Nov 11, 2024
27c86b2
Remove if in cmakelists about c++ version
ClemensLinnhoff Nov 11, 2024
3311d43
Add input path to example mcap reader
ClemensLinnhoff Nov 11, 2024
0f86f91
Add README for examples
ClemensLinnhoff Nov 11, 2024
e86c51f
Spelling
ClemensLinnhoff Nov 11, 2024
db4b29f
Add txth examples to readme
ClemensLinnhoff Nov 11, 2024
040574d
Add examples section to main Readme
ClemensLinnhoff Nov 11, 2024
bb495cb
Fix typo
ClemensLinnhoff Nov 11, 2024
ca18808
capitalize txth
TimmRuppert Nov 12, 2024
e9519cd
fix txth examples
TimmRuppert Nov 12, 2024
d6cb7e4
rename test
TimmRuppert Nov 12, 2024
e610ad5
expose mcap writer and add unit tests for mcap reader
TimmRuppert Nov 12, 2024
08411a9
fix unit tests
TimmRuppert Nov 12, 2024
854bfbe
add unit tests for txth
TimmRuppert Nov 12, 2024
b44b08b
fix url
TimmRuppert Nov 12, 2024
7c2cf8d
clean up variable names
TimmRuppert Nov 12, 2024
9c34b88
enforce metadata on mcap before beeing able to write
TimmRuppert Nov 13, 2024
a03469d
make timestring member static
TimmRuppert Nov 13, 2024
bb70dc2
Use OSI naming convention for examples
TimmRuppert Nov 13, 2024
880a967
formatting and clang-tidy fixes
TimmRuppert Nov 13, 2024
50e12c4
Unify behavior when reading past file end
TimmRuppert Nov 13, 2024
4979950
prevent opening open file
TimmRuppert Nov 13, 2024
94dec06
allow to set mcap options
TimmRuppert Nov 13, 2024
b4f1c35
cleanup interface
TimmRuppert Nov 14, 2024
193cb84
refine documentation
TimmRuppert Nov 14, 2024
d06373b
clang-tidy fixes
TimmRuppert Nov 14, 2024
6b2cb3c
convert library to std::filesystem
TimmRuppert Nov 14, 2024
fdebf51
convert examples to std::filesystem
TimmRuppert Nov 14, 2024
565e7c0
convert example converter to std::filesystem
TimmRuppert Nov 14, 2024
79a5733
cleanup
TimmRuppert Nov 14, 2024
88107d8
Clarify state of project
TimmRuppert Nov 14, 2024
794c67c
cleanup clang-tidy const warnings
TimmRuppert Nov 14, 2024
608187a
example converter: parse time from filename, example MCAP writer: fix…
TimmRuppert Nov 15, 2024
ea07e49
solve clang-tidy issues in converter
TimmRuppert Nov 15, 2024
cca1166
Update README.md
jdsika Nov 26, 2024
1b9dc91
fix URLs in readme
TimmRuppert Nov 26, 2024
1f88a3f
fix spdx check
TimmRuppert Nov 26, 2024
126fec7
Merge branch 'main' into 1-add-a-c++-trace-file-readerwriter
jdsika Nov 26, 2024
655243f
minor changes to readme instructions
jdsika Nov 27, 2024
9e42a92
add lost clang format file
TimmRuppert Nov 29, 2024
faaea9e
rework metadata handling
TimmRuppert Nov 29, 2024
fb3d846
Change metadata format to latest spec PR and add more tests
TimmRuppert Dec 2, 2024
aa5251e
rename native binary as term does not exist in new alternative spec
TimmRuppert Dec 2, 2024
3e7d28d
solve clang-tidy warnings
TimmRuppert Dec 2, 2024
d009ea1
bump mcap for fixes of cpp api to releases/cpp/v1.4.1
TimmRuppert Dec 2, 2024
bd3a708
made timestamp parsing from .osi optional and clarify difference betw…
TimmRuppert Dec 2, 2024
b699c00
fix description in converted file example
TimmRuppert Dec 2, 2024
5221538
add warning if specified message type is different than filename sugg…
TimmRuppert Dec 2, 2024
0df13a4
formatting
TimmRuppert Dec 2, 2024
6d7729f
Add options to example mcap tracefile writer
jdsika Dec 2, 2024
820f8c2
Add chunk size and compression example to osi2mcap example
jdsika Dec 2, 2024
1d3f4e8
fix wrong enum
jdsika Dec 2, 2024
7a7abf8
rename options to mcap_opetions
jdsika Dec 2, 2024
7d0a95c
make trace file spec version a compile definition
TimmRuppert Dec 2, 2024
6df6f81
Merge branch '1-add-a-c++-trace-file-readerwriter' of github.com:Lich…
TimmRuppert Dec 2, 2024
e8326c1
provide more mcap options
TimmRuppert Dec 2, 2024
be82b6a
fix unit tests missing compile def
TimmRuppert Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use the Google style in this project.
Language: Cpp
BasedOnStyle: Google

# Google style only requires consistency: "int& a" vs. "int &a" vs. "int & a"
DerivePointerAlignment: false
PointerAlignment: Left

# Google style only requires consistency: "const int a" vs. "int const a"
QualifierAlignment: Left

# empty lines between function definitions
SeparateDefinitionBlocks: Always
EmptyLineBeforeAccessModifier: LogicalBlock

# break with the Google style but be consistent with python
IndentWidth: 4
UseTab: Never

# allow more characters per line
ColumnLimit: 180

54 changes: 54 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Checks: >
-*,
readability-*,
-readability-useless-return-value,
-readability-const-return-type,
-readability-magic-numbers,
-readability-math-missing-parentheses,
cppcoreguidelines-*,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay
misc-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-suspicious-enum-usage,
modernize-,
clang-analyzer-*,
performance-*,
-performance-avoid-endl,

# as like in clang-format, follow the Google style guide https://google.github.io/styleguide/cppguide.html
# based on https://github.com/googleapis/google-cloud-cpp/blob/main/.clang-tidy
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: aNy_CasE }
- { key: readability-identifier-naming.VariableCase, value: lower_case }
- { key: readability-identifier-naming.ClassMemberCase, value: lower_case }
- { key: readability-identifier-naming.ClassMemberSuffix, value: _ }
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ }
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
- { key: readability-identifier-naming.EnumConstantPrefix, value: k }
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
- { key: readability-identifier-naming.ConstexprVariablePrefix, value: k }
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
- { key: readability-identifier-naming.GlobalConstantPrefix, value: k }
- { key: readability-identifier-naming.MemberConstantCase, value: CamelCase }
- { key: readability-identifier-naming.MemberConstantPrefix, value: k }
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
- { key: readability-identifier-naming.StaticConstantPrefix, value: k }
- { key: readability-implicit-bool-conversion.AllowIntegerConditions, value: 1 }
- { key: readability-implicit-bool-conversion.AllowPointerConditions, value: 1 }
- { key: readability-function-cognitive-complexity.IgnoreMacros, value: 1 }
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

#### Describe the bug
A clear and concise description of what the bug is.

#### Describe how to reproduce the bug
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

#### Describe the expected behavior
A clear and concise description of what you expected to happen.

#### Show some screenshots
If applicable, add screenshots to help explain your problem.

#### Describe the OS you are using
- OS: [e.g. iOS, Ubuntu 18.04, Windows 10, ...]
- Browser: [Chrome, Opera. Firefox, ...]
- Language: [e.g. C++, Python, ...]
- Version [e.g. 3.6.8]

#### Additional context
Add any other context about the bug here.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: feature request
assignees: ''

---

#### Describe the feature
Is your feature request related to a problem with the documentation?
A clear and concise description of what the problem is.
Example: I am always frustrated when [...].

#### Describe the solution you would like
A clear and concise description of what you want to happen.

#### Describe alternatives you have considered
A clear and concise description of any alternative solutions or features you have considered.

#### Additional context
Add any other context or screenshots about the feature request here.
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#### Reference to a related issue in the repository
<!-- Add the issue number that this PR is addressing -->
closes #<issue_number>

#### Add a description
<!-- Add a description of the changes proposed in the pull request -->

#### Self-Checks
<!-- Take this checklist as orientation for yourself -->
- [ ] I have added unit tests for changed or added functions.
- [ ] I have updated function documentation of changed or added functions.
- [ ] My changes generate no errors when passing CI tests.
- [ ] I have successfully implemented and tested my fix/feature locally.
- [ ] Appropriate reviewer(s) are assigned.
34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential liblz4-dev libzstd-dev protobuf-compiler doxygen graphviz gcovr
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_EXPORT_COMPILE_COMMANDS=on
- name: Build for linting
run: cmake --build ${{github.workspace}}/build -j3
- name: Lint CPP
uses: cpp-linter/cpp-linter-action@v2
id: cpplinter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
style: '' # disable clang-format checks.
tidy-checks: '' # Use .clang-tidy config file.
thread-comments: ${{ github.event_name == 'pull_request' && 'update' }}
extra-args: -std=c++17
database: 'build'
ignore: 'tests'
- name: Check Lint Results
if: steps.linter.outputs.checks-failed > 0
run: echo "Some files failed the linting checks!"
19 changes: 19 additions & 0 deletions .github/workflows/spdx_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: SPDX License Check

on: [push, pull_request]

jobs:
check-spdx-headers:
name: SPDX License Check
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- uses: enarx/spdx@c3e8116ed31c31b3c2e58a26ba5cac407510ca37
with:
licenses: |-
Apache-2.0
BSD-3-Clause
BSD-2-Clause
MIT
MPL-2.0
25 changes: 25 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Ubuntu

on: [push, pull_request]

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential liblz4-dev libzstd-dev protobuf-compiler doxygen graphviz gcovr
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCODE_COVERAGE=ON
- name: Build
run: cmake --build ${{github.workspace}}/build -j3
- name: Run Tests
working-directory: ${{github.workspace}}/build
run: ctest --output-on-failure
- name: Generate Coverage Report
run: gcovr -r . ${{github.workspace}}/build
# TODO add coverage report upload so contributors are encouraged to add tests during a PR
60 changes: 60 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Subfolders
build/
dist/
doc/html
doc/latex
osi/
osi3/

# Specific extensions
*.egg-info
.project

# Building
CMakeCache.txt
CMakeFiles
CMakeScripts
CTestTestfile.cmake
Makefile

build
cmake_install.cmake
install_manifest.txt
osi_version.proto

compile_commands.json

# Python-generated files
__pycache__/
.venv/
venv/
*.py[cod]
proto2cpp.log
.clang-format
githooks/pre-commit

# Eclipse-specific files
*.cproject
*.project
.settings/

# PyCharm specific files
.idea
.vscode/settings.json

# Clion specific files
.idea/
cmake-build-*/

# VS Code specific files
.vscode/
.history/
*.vsix

# Local build tool output
local_build_tools/*.html

# trace file
*.osi
*.txth
*.mcap
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/mcap"]
path = lib/mcap
url = https://github.com/foxglove/mcap.git
65 changes: 65 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
cmake_minimum_required(VERSION 3.16)
project(osi-utilities)

# Som features (e.g. mcap) require at least C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Generate compile_commands.json for clang based tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Add the include folder for public headers
include_directories(${PROJECT_SOURCE_DIR}/include)

# option for specifying the path to the open_simulation_interface.
option(USE_EXTERNAL_OSI "Use an external version of open_simulation_interface" OFF)
option(LINK_WITH_SHARED_OSI "Link utils with shared OSI library instead of statically linking" OFF)

# Locate open_simulation_interface using find_package or custom path.
if (USE_EXTERNAL_OSI)
message(FATAL_ERROR "Not implemented yet")
else ()
# Download and use our own open_simulation_interface package.
include(FetchContent)
FetchContent_Declare(
open_simulation_interface
GIT_REPOSITORY https://github.com/OpenSimulationInterface/open-simulation-interface.git
GIT_TAG v3.7.0
)
FetchContent_MakeAvailable(open_simulation_interface)
set(OSI_INCLUDE_DIR ${open_simulation_interface_BINARY_DIR})
endif ()

# option to enable coverage reporting
option(CODE_COVERAGE "Enable coverage reporting" OFF)
if (CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(--coverage -O0 -g)
add_link_options(--coverage)
message(WARNING "Added coverage options")
endif ()

# build doxygen documentation
find_package(Doxygen)
if (DOXYGEN_FOUND AND PROJECT_IS_TOP_LEVEL)
message(STATUS "Doxygen found, generating API documentation")
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile)
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
# note the option ALL which allows to build the docs together with the application
add_custom_target(
library_api_doc
ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
endif (DOXYGEN_FOUND AND PROJECT_IS_TOP_LEVEL)

add_subdirectory(src)
if (PROJECT_IS_TOP_LEVEL)
enable_testing()
add_subdirectory(tests)
endif ()
add_subdirectory(examples)
Loading