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

Cpp17 #20

Merged
merged 8 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ jobs:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
test_executable: \test\Release\DsVeosCoSimTest.exe
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
test_executable: /test/DsVeosCoSimTest
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
test_executable: /test/DsVeosCoSimTest
exclude:
- os: windows-latest
c_compiler: gcc
Expand Down Expand Up @@ -65,6 +68,7 @@ jobs:
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DDSVEOSCOSIM_BUILD_TESTS=ON
-S ${{ github.workspace }}

- name: Build
Expand All @@ -75,4 +79,4 @@ jobs:
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
run: ${{ steps.strings.outputs.build-output-dir }}${{ matrix.test_executable }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ obj/
tmplin/
tmpwin/
.mono/

debug.log
98 changes: 97 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,101 @@
"swappable",
"vecu",
"vpus"
]
],
"files.associations": {
"algorithm": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"coroutine": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"deque": "cpp",
"exception": "cpp",
"expected": "cpp",
"filesystem": "cpp",
"format": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"functional": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"list": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"numeric": "cpp",
"optional": "cpp",
"ostream": "cpp",
"queue": "cpp",
"random": "cpp",
"ranges": "cpp",
"ratio": "cpp",
"regex": "cpp",
"set": "cpp",
"source_location": "cpp",
"span": "cpp",
"sstream": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"utility": "cpp",
"variant": "cpp",
"vector": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp"
}
}
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ option(BUILD_SHARED_LIBS "Compile dSPACE VEOS CoSim as a shared library" OFF)
option(DSVEOSCOSIM_BUILD_TESTS "Create tests for dSPACE VEOS CoSim" OFF)
option(DSVEOSCOSIM_BUILD_BENCHMARKS "Create benchmarks for dSPACE VEOS CoSim" OFF)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

set(DSVEOSCOSIM_TYPE STATIC)
Expand All @@ -27,12 +27,12 @@ if(DSVEOSCOSIM_BUILD_TESTS)
add_subdirectory(test)
add_subdirectory(utilities/TestClient)
add_subdirectory(utilities/TestServer)
add_subdirectory(utilities/PerformanceTestClient)
add_subdirectory(utilities/PerformanceTestServer)
endif()

if(DSVEOSCOSIM_BUILD_BENCHMARKS)
add_subdirectory(benchmark)
add_subdirectory(utilities/PerformanceTestClient)
add_subdirectory(utilities/PerformanceTestServer)
endif()

install(EXPORT DsVeosCoSimTargets
Expand Down
14 changes: 8 additions & 6 deletions benchmark/BenchmarkBusBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ void RunTest(benchmark::State& state,
bool stopThread{};
Event endEvent;

std::jthread thread(ReceiveMessages<TypeParam>,
count,
std::ref(receiverBusBuffer),
std::ref(receiverChannel),
std::ref(stopThread),
std::ref(endEvent));
std::thread thread(ReceiveMessages<TypeParam>,
count,
std::ref(receiverBusBuffer),
std::ref(receiverChannel),
std::ref(stopThread),
std::ref(endEvent));

TMessage sendMessage{};
FillWithRandom(sendMessage, controller.id);
Expand All @@ -91,6 +91,8 @@ void RunTest(benchmark::State& state,

MUST_BE_TRUE(transmitterBusBuffer.Serialize(senderChannel.GetWriter()));
MUST_BE_TRUE(senderChannel.GetWriter().EndWrite());

thread.join();
}

template <typename TypeParam>
Expand Down
14 changes: 8 additions & 6 deletions benchmark/BenchmarkIoBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ void RunTest(benchmark::State& state,
bool stopThread{};
Event endEvent;

std::jthread thread(Receive,
std::ref(signal),
std::ref(readerIoBuffer),
std::ref(receiverChannel),
std::ref(stopThread),
std::ref(endEvent));
std::thread thread(Receive,
std::ref(signal),
std::ref(readerIoBuffer),
std::ref(receiverChannel),
std::ref(stopThread),
std::ref(endEvent));

for (auto _ : state) {
writeValue[0]++;
Expand All @@ -75,6 +75,8 @@ void RunTest(benchmark::State& state,

MUST_BE_TRUE(writerIoBuffer.Serialize(senderChannel.GetWriter()));
MUST_BE_TRUE(senderChannel.GetWriter().EndWrite());

thread.join();
}

void TcpIo(benchmark::State& state) {
Expand Down
4 changes: 3 additions & 1 deletion benchmark/Communication/BenchmarkChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void RunTest(benchmark::State& state, Channel& channel1, Channel& channel2) {
size_t size = state.range(0);

bool stopThread{};
std::jthread thread(CounterPart, std::ref(channel1), std::ref(stopThread), size);
std::thread thread(CounterPart, std::ref(channel1), std::ref(stopThread), size);

std::vector<uint8_t> buffer;
buffer.resize(size);
Expand All @@ -48,6 +48,8 @@ void RunTest(benchmark::State& state, Channel& channel1, Channel& channel2) {
stopThread = true;
MUST_BE_TRUE(channel2.GetWriter().Write(buffer.data(), buffer.size()));
MUST_BE_TRUE(channel2.GetWriter().EndWrite());

thread.join();
}

void TcpChannelRoundtrip(benchmark::State& state) {
Expand Down
4 changes: 3 additions & 1 deletion benchmark/OsAbstraction/BenchmarkNamedEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void EventRoundtrip(benchmark::State& state) {
NamedEvent event2 = NamedEvent::CreateOrOpen(eventName2);

stopThread = false;
std::jthread thread(WaitAndSet, eventName1, eventName2);
std::thread thread(WaitAndSet, eventName1, eventName2);

for (auto _ : state) {
event1.Set();
Expand All @@ -63,6 +63,8 @@ void EventRoundtrip(benchmark::State& state) {

stopThread = true;
event1.Set();

thread.join();
}

} // namespace
Expand Down
4 changes: 3 additions & 1 deletion benchmark/OsAbstraction/BenchmarkSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void RunTest(benchmark::State& state, Socket& socket1, Socket& socket2) {
buffer.resize(size);

bool stopThread{};
std::jthread thread(CounterPart, std::ref(socket1), std::ref(stopThread), size);
std::thread thread(CounterPart, std::ref(socket1), std::ref(stopThread), size);

for (auto _ : state) {
MUST_BE_TRUE(SendComplete(socket2, buffer.data(), buffer.size()));
Expand All @@ -41,6 +41,8 @@ void RunTest(benchmark::State& state, Socket& socket1, Socket& socket2) {

stopThread = true;
MUST_BE_TRUE(SendComplete(socket2, buffer.data(), buffer.size()));

thread.join();
}

void SocketTcpRoundtrip(benchmark::State& state) {
Expand Down
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ echo Building %config% %platformToUse% ...
set buildDir=%currentDir%\tmpwin\%config%\%platformToUse%
if not exist "%buildDir%" mkdir "%buildDir%" || exit /b 1
cd "%buildDir%"
cmake ..\..\.. -GNinja -DCMAKE_BUILD_TYPE=%config% -DDSVEOSCOSIM_BUILD_TESTS=ON -DDSVEOSCOSIM_BUILD_BENCHMARKS=ON || exit /b 1
cmake ..\..\.. -GNinja -DCMAKE_BUILD_TYPE=%config% -DDSVEOSCOSIM_BUILD_TESTS=ON || exit /b 1
cmake --build . --config %config% || exit /b 1

echo Building %config% %platformToUse% finished successfully.
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo Building $config ...
mkdir -p "$currentDir/tmplin/$config" || exit 1
cd "$currentDir/tmplin/$config"

cmake ../.. -GNinja -DCMAKE_BUILD_TYPE=$config -DDSVEOSCOSIM_BUILD_TESTS=ON -DDSVEOSCOSIM_BUILD_BENCHMARKS=ON || exit 1
cmake ../.. -GNinja -DCMAKE_BUILD_TYPE=$config -DDSVEOSCOSIM_BUILD_TESTS=ON || exit 1
cmake --build . || exit 1

echo Building $config finished successfully.
Expand Down
40 changes: 40 additions & 0 deletions include/DsVeosCoSim/DsVeosCoSim.h
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,48 @@ DSVEOSCOSIM_DECL DsVeosCoSim_Result DsVeosCoSim_ReceiveLinMessage(DsVeosCoSim_Ha
DSVEOSCOSIM_DECL DsVeosCoSim_Result DsVeosCoSim_TransmitLinMessage(DsVeosCoSim_Handle handle,
const DsVeosCoSim_LinMessage* message);

DSVEOSCOSIM_DECL DsVeosCoSim_Result DsVeosCoSim_StartSimulation(DsVeosCoSim_Handle handle);
DSVEOSCOSIM_DECL DsVeosCoSim_Result DsVeosCoSim_StopSimulation(DsVeosCoSim_Handle handle);
DSVEOSCOSIM_DECL DsVeosCoSim_Result DsVeosCoSim_PauseSimulation(DsVeosCoSim_Handle handle);
DSVEOSCOSIM_DECL DsVeosCoSim_Result DsVeosCoSim_ContinueSimulation(DsVeosCoSim_Handle handle);
DSVEOSCOSIM_DECL DsVeosCoSim_Result DsVeosCoSim_TerminateSimulation(DsVeosCoSim_Handle handle,
DsVeosCoSim_TerminateReason terminateReason);

#ifdef __cplusplus
extern DSVEOSCOSIM_API std::string DsVeosCoSim_SimulationTimeToString(DsVeosCoSim_SimulationTime simulationTime);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_ResultToString(DsVeosCoSim_Result result);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_CommandToString(DsVeosCoSim_Command command);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_SeverityToString(DsVeosCoSim_Severity severity);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_TerminateReasonToString(DsVeosCoSim_TerminateReason terminateReason);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_ConnectionStateToString(DsVeosCoSim_ConnectionState connectionState);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_DataTypeToString(DsVeosCoSim_DataType dataType);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_SizeKindToString(DsVeosCoSim_SizeKind sizeKind);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_IoSignalToString(const DsVeosCoSim_IoSignal& ioSignal);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_CanControllerToString(const DsVeosCoSim_CanController& controller);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_EthControllerToString(const DsVeosCoSim_EthController& controller);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_LinControllerToString(const DsVeosCoSim_LinController& controller);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_ValueToString(DsVeosCoSim_DataType dataType,
uint32_t length,
const void* value);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_DataToString(const uint8_t* data, size_t dataLength, char separator = 0);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_IoDataToString(DsVeosCoSim_SimulationTime simulationTime,
const DsVeosCoSim_IoSignal& ioSignal,
uint32_t length,
const void* value);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_CanMessageToString(DsVeosCoSim_SimulationTime simulationTime,
const DsVeosCoSim_CanController& controller,
const DsVeosCoSim_CanMessage& message);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_EthMessageToString(DsVeosCoSim_SimulationTime simulationTime,
const DsVeosCoSim_EthController& controller,
const DsVeosCoSim_EthMessage& message);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_LinMessageToString(DsVeosCoSim_SimulationTime simulationTime,
const DsVeosCoSim_LinController& controller,
const DsVeosCoSim_LinMessage& message);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_LinControllerTypeToString(
DsVeosCoSim_LinControllerType linControllerType);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_CanMessageFlagsToString(DsVeosCoSim_CanMessageFlags flags);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_EthMessageFlagsToString(DsVeosCoSim_EthMessageFlags flags);
extern DSVEOSCOSIM_API std::string DsVeosCoSim_LinMessageFlagsToString(DsVeosCoSim_LinMessageFlags flags);

extern DSVEOSCOSIM_API size_t DsVeosCoSim_GetDataTypeSize(DsVeosCoSim_DataType dataType);
#endif
28 changes: 0 additions & 28 deletions shared/BackgroundService.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions shared/BackgroundService.h

This file was deleted.

Loading