From 9d8d705d635fdb20b291eb593fc9e4446497556f Mon Sep 17 00:00:00 2001 From: Michal Date: Mon, 1 Jun 2026 17:04:21 +0200 Subject: [PATCH 1/5] refactor: update Component class * add update() function * store weak_ptr to the owner of the object --- .clang-tidy | 3 +-- CMakeLists.txt | 2 +- include/parser/Parser.hpp | 2 +- include/scene/components/BlinkComponent.hpp | 10 ++++------ include/scene/components/Component.hpp | 13 ++++++++++++- include/scene/components/ComponentRegistry.hpp | 5 +++-- src/parser/Parser.cpp | 6 +++--- src/scene/components/BlinkComponent.cpp | 9 +++++++-- src/scene/components/ComponentRegistry.cpp | 4 ++-- 9 files changed, 34 insertions(+), 20 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 0842f8d..3def4bd 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,4 @@ Checks: 'bugprone-*,cppcoreguidelines-*,performance-*,readability-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-array-to-pointer-decay' WarningsAsErrors: '' -HeaderFilterRegex: '.*' -ExcludeHeaderFilterRegex: '.*\.(pb\.h|pb\.cc)$' +HeaderFilterRegex: '^(?!.*\.(pb\.h|pb\.cc)$).*$' FormatStyle: 'file' \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 326ad2e..cd61016 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.14) project(NeuronIDE CXX) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) enable_testing() diff --git a/include/parser/Parser.hpp b/include/parser/Parser.hpp index d19fb98..e4d6b93 100644 --- a/include/parser/Parser.hpp +++ b/include/parser/Parser.hpp @@ -22,7 +22,7 @@ class Parser { private: static std::shared_ptr buildSceneObject(const NeuronIDE::SceneObject& protoObj); - static std::unique_ptr buildComponent(const NeuronIDE::Component& protoComp); + static std::unique_ptr buildComponent(const NeuronIDE::Component& protoComp, const std::shared_ptr& owner); }; #endif // PARSER_HPP \ No newline at end of file diff --git a/include/scene/components/BlinkComponent.hpp b/include/scene/components/BlinkComponent.hpp index 59816b2..1c941c5 100644 --- a/include/scene/components/BlinkComponent.hpp +++ b/include/scene/components/BlinkComponent.hpp @@ -2,7 +2,6 @@ #define BLINKCOMPONENT_HPP #include -#include #include "Component.hpp" @@ -12,13 +11,12 @@ class Component; class BlinkComponent : public Component { public: - BlinkComponent(double freq) : blinkFrequencyHz(freq) { - std::cout << " + [BlinkComponent] Utworzono z czestotliwoscia: " << blinkFrequencyHz - << "Hz\n"; - } + BlinkComponent(std::shared_ptr owner, double freq) : Component(owner), blinkFrequencyHz(freq) {} void setFrequency(double freq); - static std::unique_ptr createBlinker(const NeuronIDE::Component& protoComp); + void update(const Context& context) override; + + static std::unique_ptr createBlinker(const NeuronIDE::Component& protoComp, const std::shared_ptr& owner); private: double blinkFrequencyHz = 0.0; diff --git a/include/scene/components/Component.hpp b/include/scene/components/Component.hpp index 1b15b63..475fb59 100644 --- a/include/scene/components/Component.hpp +++ b/include/scene/components/Component.hpp @@ -1,15 +1,26 @@ #ifndef COMPONENT_HPP #define COMPONENT_HPP +#include + +class SceneObject; +struct Context; + class Component { public: - Component() = default; + Component() = delete; + Component(std::shared_ptr owner) : owner(owner) {} virtual ~Component() = default; Component(const Component&) = default; Component(Component&&) = default; Component& operator=(const Component&) = default; Component& operator=(Component&&) = default; + + virtual void update(const Context& context) = 0; + + protected: + std::weak_ptr owner; }; #endif // COMPONENT_HPP \ No newline at end of file diff --git a/include/scene/components/ComponentRegistry.hpp b/include/scene/components/ComponentRegistry.hpp index da89f8a..1b1a4c2 100644 --- a/include/scene/components/ComponentRegistry.hpp +++ b/include/scene/components/ComponentRegistry.hpp @@ -9,8 +9,9 @@ class Component; namespace NeuronIDE { class Component; } +class SceneObject; -using ComponentCreatorFunc = std::function(const NeuronIDE::Component&)>; +using ComponentCreatorFunc = std::function(const NeuronIDE::Component&, const std::shared_ptr&)>; class ComponentRegistry { public: @@ -27,7 +28,7 @@ class ComponentRegistry { void registerCreator(int typeId, ComponentCreatorFunc creator); - std::unique_ptr build(const NeuronIDE::Component& protoComp); + std::unique_ptr build(const NeuronIDE::Component& protoComp, const std::shared_ptr& owner); private: ComponentRegistry() = default; diff --git a/src/parser/Parser.cpp b/src/parser/Parser.cpp index 79de0bc..dfa14c9 100644 --- a/src/parser/Parser.cpp +++ b/src/parser/Parser.cpp @@ -52,7 +52,7 @@ std::shared_ptr Parser::buildSceneObject(const NeuronIDE::SceneObje } seenComponentTypes.insert(typeId); - auto comp = buildComponent(protoComp); + auto comp = buildComponent(protoComp, obj); if (comp) { obj->addComponent(std::move(comp)); } @@ -61,6 +61,6 @@ std::shared_ptr Parser::buildSceneObject(const NeuronIDE::SceneObje return obj; } -std::unique_ptr Parser::buildComponent(const NeuronIDE::Component& protoComp) { - return ComponentRegistry::instance().build(protoComp); +std::unique_ptr Parser::buildComponent(const NeuronIDE::Component& protoComp, const std::shared_ptr& owner) { + return ComponentRegistry::instance().build(protoComp, owner); } \ No newline at end of file diff --git a/src/scene/components/BlinkComponent.cpp b/src/scene/components/BlinkComponent.cpp index 3830efa..61fcfdc 100644 --- a/src/scene/components/BlinkComponent.cpp +++ b/src/scene/components/BlinkComponent.cpp @@ -5,8 +5,13 @@ void BlinkComponent::setFrequency(double freq) { blinkFrequencyHz = freq; } -std::unique_ptr BlinkComponent::createBlinker(const NeuronIDE::Component& protoComp) { - return std::make_unique(protoComp.blinker().blink_frequency_hz()); +std::unique_ptr BlinkComponent::createBlinker( + const NeuronIDE::Component& protoComp, const std::shared_ptr& owner) { + return std::make_unique(owner, protoComp.blinker().blink_frequency_hz()); +} + +void BlinkComponent::update(const Context& context) { + //TODO: implement blinking logic based on blinkFrequencyHz and context.timestamp } REGISTER_COMPONENT(NeuronIDE::Component::kBlinker, BlinkComponent::createBlinker) \ No newline at end of file diff --git a/src/scene/components/ComponentRegistry.cpp b/src/scene/components/ComponentRegistry.cpp index 52faf24..ff05cd2 100644 --- a/src/scene/components/ComponentRegistry.cpp +++ b/src/scene/components/ComponentRegistry.cpp @@ -13,14 +13,14 @@ void ComponentRegistry::registerCreator(int typeId, ComponentCreatorFunc creator creators[typeId] = std::move(creator); } -std::unique_ptr ComponentRegistry::build(const NeuronIDE::Component& protoComp) { +std::unique_ptr ComponentRegistry::build(const NeuronIDE::Component& protoComp, const std::shared_ptr& owner) { auto activeCase = protoComp.component_type_case(); int typeId = static_cast(activeCase); auto it = creators.find(typeId); if (it != creators.end()) { - return it->second(protoComp); + return it->second(protoComp, owner); } return nullptr; From 4c804c2d6c33b4b20ac5cfbe44a27d503fddc063 Mon Sep 17 00:00:00 2001 From: Michal Date: Mon, 1 Jun 2026 17:15:36 +0200 Subject: [PATCH 2/5] fix: format code --- include/parser/Parser.hpp | 3 ++- include/scene/components/BlinkComponent.hpp | 6 ++++-- include/scene/components/ComponentRegistry.hpp | 6 ++++-- src/parser/Parser.cpp | 3 ++- src/scene/components/BlinkComponent.cpp | 2 +- src/scene/components/ComponentRegistry.cpp | 3 ++- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/parser/Parser.hpp b/include/parser/Parser.hpp index e4d6b93..26bf0dd 100644 --- a/include/parser/Parser.hpp +++ b/include/parser/Parser.hpp @@ -22,7 +22,8 @@ class Parser { private: static std::shared_ptr buildSceneObject(const NeuronIDE::SceneObject& protoObj); - static std::unique_ptr buildComponent(const NeuronIDE::Component& protoComp, const std::shared_ptr& owner); + static std::unique_ptr buildComponent(const NeuronIDE::Component& protoComp, + const std::shared_ptr& owner); }; #endif // PARSER_HPP \ No newline at end of file diff --git a/include/scene/components/BlinkComponent.hpp b/include/scene/components/BlinkComponent.hpp index 1c941c5..947bf51 100644 --- a/include/scene/components/BlinkComponent.hpp +++ b/include/scene/components/BlinkComponent.hpp @@ -11,12 +11,14 @@ class Component; class BlinkComponent : public Component { public: - BlinkComponent(std::shared_ptr owner, double freq) : Component(owner), blinkFrequencyHz(freq) {} + BlinkComponent(std::shared_ptr owner, double freq) + : Component(owner), blinkFrequencyHz(freq) {} void setFrequency(double freq); void update(const Context& context) override; - static std::unique_ptr createBlinker(const NeuronIDE::Component& protoComp, const std::shared_ptr& owner); + static std::unique_ptr createBlinker(const NeuronIDE::Component& protoComp, + const std::shared_ptr& owner); private: double blinkFrequencyHz = 0.0; diff --git a/include/scene/components/ComponentRegistry.hpp b/include/scene/components/ComponentRegistry.hpp index 1b1a4c2..668dc4a 100644 --- a/include/scene/components/ComponentRegistry.hpp +++ b/include/scene/components/ComponentRegistry.hpp @@ -11,7 +11,8 @@ class Component; } class SceneObject; -using ComponentCreatorFunc = std::function(const NeuronIDE::Component&, const std::shared_ptr&)>; +using ComponentCreatorFunc = std::function( + const NeuronIDE::Component&, const std::shared_ptr&)>; class ComponentRegistry { public: @@ -28,7 +29,8 @@ class ComponentRegistry { void registerCreator(int typeId, ComponentCreatorFunc creator); - std::unique_ptr build(const NeuronIDE::Component& protoComp, const std::shared_ptr& owner); + std::unique_ptr build(const NeuronIDE::Component& protoComp, + const std::shared_ptr& owner); private: ComponentRegistry() = default; diff --git a/src/parser/Parser.cpp b/src/parser/Parser.cpp index dfa14c9..235dba1 100644 --- a/src/parser/Parser.cpp +++ b/src/parser/Parser.cpp @@ -61,6 +61,7 @@ std::shared_ptr Parser::buildSceneObject(const NeuronIDE::SceneObje return obj; } -std::unique_ptr Parser::buildComponent(const NeuronIDE::Component& protoComp, const std::shared_ptr& owner) { +std::unique_ptr Parser::buildComponent(const NeuronIDE::Component& protoComp, + const std::shared_ptr& owner) { return ComponentRegistry::instance().build(protoComp, owner); } \ No newline at end of file diff --git a/src/scene/components/BlinkComponent.cpp b/src/scene/components/BlinkComponent.cpp index 61fcfdc..d483241 100644 --- a/src/scene/components/BlinkComponent.cpp +++ b/src/scene/components/BlinkComponent.cpp @@ -11,7 +11,7 @@ std::unique_ptr BlinkComponent::createBlinker( } void BlinkComponent::update(const Context& context) { - //TODO: implement blinking logic based on blinkFrequencyHz and context.timestamp + // TODO: implement blinking logic based on blinkFrequencyHz and context.timestamp } REGISTER_COMPONENT(NeuronIDE::Component::kBlinker, BlinkComponent::createBlinker) \ No newline at end of file diff --git a/src/scene/components/ComponentRegistry.cpp b/src/scene/components/ComponentRegistry.cpp index ff05cd2..b3419fc 100644 --- a/src/scene/components/ComponentRegistry.cpp +++ b/src/scene/components/ComponentRegistry.cpp @@ -13,7 +13,8 @@ void ComponentRegistry::registerCreator(int typeId, ComponentCreatorFunc creator creators[typeId] = std::move(creator); } -std::unique_ptr ComponentRegistry::build(const NeuronIDE::Component& protoComp, const std::shared_ptr& owner) { +std::unique_ptr ComponentRegistry::build(const NeuronIDE::Component& protoComp, + const std::shared_ptr& owner) { auto activeCase = protoComp.component_type_case(); int typeId = static_cast(activeCase); From 839f713e80045f933fc35878204f4736f3db6771 Mon Sep 17 00:00:00 2001 From: Michal Date: Tue, 2 Jun 2026 01:33:18 +0200 Subject: [PATCH 3/5] feat: add render and update functions to Scene, SceneObject and Component --- include/scene/Scene.hpp | 5 +++++ include/scene/SceneObject.hpp | 7 ++++++- include/scene/components/BlinkComponent.hpp | 1 + include/scene/components/Component.hpp | 2 ++ src/CMakeLists.txt | 1 + src/scene/Scene.cpp | 17 +++++++++++++++++ src/scene/SceneObject.cpp | 14 +++++++++++++- src/scene/components/BlinkComponent.cpp | 5 +++++ 8 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/scene/Scene.cpp diff --git a/include/scene/Scene.hpp b/include/scene/Scene.hpp index 77c6be5..d0c1025 100644 --- a/include/scene/Scene.hpp +++ b/include/scene/Scene.hpp @@ -6,6 +6,8 @@ #include class SceneObject; +class SDL_Renderer; +struct Context; class Scene { private: @@ -19,6 +21,9 @@ class Scene { const std::string& getExperimentName() const { return experimentName; } const std::vector>& getObjects() const { return objects; } + + void update(const Context& ctx); + void render(SDL_Renderer* renderer); }; #endif // SCENE_HPP \ No newline at end of file diff --git a/include/scene/SceneObject.hpp b/include/scene/SceneObject.hpp index bf6ef92..df63ea9 100644 --- a/include/scene/SceneObject.hpp +++ b/include/scene/SceneObject.hpp @@ -7,6 +7,8 @@ #include class Component; +class SDL_Renderer; +struct Context; class SceneObject { public: @@ -21,9 +23,12 @@ class SceneObject { SceneObject(std::string n, bool visible = true); - void setTransform(Transform t); + void setTransform(const Transform& transform); void addComponent(std::unique_ptr comp); + + void update(const Context& ctx); + void render(SDL_Renderer* renderer); }; #endif // SCENEOBJECT_HPP \ No newline at end of file diff --git a/include/scene/components/BlinkComponent.hpp b/include/scene/components/BlinkComponent.hpp index 947bf51..b4814e9 100644 --- a/include/scene/components/BlinkComponent.hpp +++ b/include/scene/components/BlinkComponent.hpp @@ -16,6 +16,7 @@ class BlinkComponent : public Component { void setFrequency(double freq); void update(const Context& context) override; + void render(SDL_Renderer* renderer) override; static std::unique_ptr createBlinker(const NeuronIDE::Component& protoComp, const std::shared_ptr& owner); diff --git a/include/scene/components/Component.hpp b/include/scene/components/Component.hpp index 475fb59..e17f0c6 100644 --- a/include/scene/components/Component.hpp +++ b/include/scene/components/Component.hpp @@ -4,6 +4,7 @@ #include class SceneObject; +class SDL_Renderer; struct Context; class Component { @@ -18,6 +19,7 @@ class Component { Component& operator=(Component&&) = default; virtual void update(const Context& context) = 0; + virtual void render(SDL_Renderer* renderer) = 0; protected: std::weak_ptr owner; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ced725f..62cd34d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,6 +6,7 @@ add_library(runtime_core OBJECT scene/components/ComponentRegistry.cpp scene/components/BlinkComponent.cpp scene/SceneObject.cpp + scene/Scene.cpp ${PROTO_SRCS} ${PROTO_HDRS} ) diff --git a/src/scene/Scene.cpp b/src/scene/Scene.cpp new file mode 100644 index 0000000..9360b5c --- /dev/null +++ b/src/scene/Scene.cpp @@ -0,0 +1,17 @@ +#include "scene/Scene.hpp" + +#include "scene/SceneObject.hpp" + +void Scene::update(const Context& ctx) { + for (const auto& obj : objects) { + obj->update(ctx); + } +} + +void Scene::render(SDL_Renderer* renderer) { + for (const auto& obj : objects) { + if (obj->isVisible) { + obj->render(renderer); + } + } +} \ No newline at end of file diff --git a/src/scene/SceneObject.cpp b/src/scene/SceneObject.cpp index 06d7dae..5a6d948 100644 --- a/src/scene/SceneObject.cpp +++ b/src/scene/SceneObject.cpp @@ -8,8 +8,20 @@ SceneObject::SceneObject(std::string n, bool visible) : name(std::move(n)), isVi std::cout << " [SceneObject] Utworzono obiekt: " << name << "\n"; } -void SceneObject::setTransform(Transform t) { transform = t; } +void SceneObject::setTransform(const Transform& transform) { this->transform = transform; } void SceneObject::addComponent(std::unique_ptr comp) { components.push_back(std::move(comp)); +} + +void SceneObject::update(const Context& ctx) { + for (const auto& comp : components) { + comp->update(ctx); + } +} + +void SceneObject::render(SDL_Renderer* renderer) { + for (const auto& comp : components) { + comp->render(renderer); + } } \ No newline at end of file diff --git a/src/scene/components/BlinkComponent.cpp b/src/scene/components/BlinkComponent.cpp index d483241..dbd9503 100644 --- a/src/scene/components/BlinkComponent.cpp +++ b/src/scene/components/BlinkComponent.cpp @@ -14,4 +14,9 @@ void BlinkComponent::update(const Context& context) { // TODO: implement blinking logic based on blinkFrequencyHz and context.timestamp } +void BlinkComponent::render(SDL_Renderer* renderer) { + // This component does not render anything itself, it only controls visibility of the owner + // object. +} + REGISTER_COMPONENT(NeuronIDE::Component::kBlinker, BlinkComponent::createBlinker) \ No newline at end of file From b202be41772e9ee462e166c8c182db18bc9b3e8a Mon Sep 17 00:00:00 2001 From: Michal Date: Tue, 2 Jun 2026 13:03:56 +0200 Subject: [PATCH 4/5] feat: create renderer class --- include/data_structures/Context.hpp | 12 ++++++++ include/data_structures/EEGData.hpp | 11 +++++++ include/data_structures/Marker.hpp | 11 +++++++ include/renderer/Renderer.hpp | 28 ++++++++++++++++++ src/CMakeLists.txt | 1 + src/renderer/Renderer.cpp | 45 +++++++++++++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 include/data_structures/Context.hpp create mode 100644 include/data_structures/EEGData.hpp create mode 100644 include/data_structures/Marker.hpp create mode 100644 include/renderer/Renderer.hpp create mode 100644 src/renderer/Renderer.cpp diff --git a/include/data_structures/Context.hpp b/include/data_structures/Context.hpp new file mode 100644 index 0000000..1e10942 --- /dev/null +++ b/include/data_structures/Context.hpp @@ -0,0 +1,12 @@ +#ifndef CONTEXT_HPP +#define CONTEXT_HPP + +#include +#include + +struct Context { + double timestamp; + std::vector markers; +}; + +#endif // CONTEXT_HPP \ No newline at end of file diff --git a/include/data_structures/EEGData.hpp b/include/data_structures/EEGData.hpp new file mode 100644 index 0000000..58eb0a6 --- /dev/null +++ b/include/data_structures/EEGData.hpp @@ -0,0 +1,11 @@ +#ifndef EEGDATA_HPP +#define EEGDATA_HPP + +#include + +struct EEGData { + double timestamp; + std::vector channelValues; +}; + +#endif // EEGDATA_HPP \ No newline at end of file diff --git a/include/data_structures/Marker.hpp b/include/data_structures/Marker.hpp new file mode 100644 index 0000000..6933e2f --- /dev/null +++ b/include/data_structures/Marker.hpp @@ -0,0 +1,11 @@ +#ifndef MARKER_HPP +#define MARKER_HPP + +#include + +struct Marker { + std::string name; + double timestamp; +}; + +#endif // MARKER_HPP \ No newline at end of file diff --git a/include/renderer/Renderer.hpp b/include/renderer/Renderer.hpp new file mode 100644 index 0000000..67268c9 --- /dev/null +++ b/include/renderer/Renderer.hpp @@ -0,0 +1,28 @@ +#ifndef RENDERER_HPP +#define RENDERER_HPP + +#include +#include + +#include +#include + +class Scene; +struct Marker; + +class Renderer { + public: + Renderer() = default; + ~Renderer() = default; + + void render(const std::stop_token& stoken); + + private: + std::unique_ptr window; + std::shared_ptr sdlRenderer; + std::weak_ptr currentScene; + std::shared_ptr> markerQueue; + std::jthread renderThread; +}; + +#endif // RENDERER_HPP \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 62cd34d..2d94a45 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,7 @@ add_library(runtime_core OBJECT scene/components/BlinkComponent.cpp scene/SceneObject.cpp scene/Scene.cpp + renderer/Renderer.cpp ${PROTO_SRCS} ${PROTO_HDRS} ) diff --git a/src/renderer/Renderer.cpp b/src/renderer/Renderer.cpp new file mode 100644 index 0000000..4b43e2e --- /dev/null +++ b/src/renderer/Renderer.cpp @@ -0,0 +1,45 @@ +#include "renderer/Renderer.hpp" + +#include "data_structures/Context.hpp" +#include "data_structures/Marker.hpp" +#include "lsl_cpp.h" +#include "scene/Scene.hpp" + +void Renderer::render(const std::stop_token& stoken) { + std::vector currentFrameMarkers; + auto lastTime = std::chrono::high_resolution_clock::now(); + + while (!stoken.stop_requested()) { + auto currentTime = std::chrono::high_resolution_clock::now(); + double deltaTime = std::chrono::duration(currentTime - lastTime).count(); + lastTime = currentTime; + + currentFrameMarkers.clear(); + Context ctx{deltaTime, currentFrameMarkers}; + + SDL_Event event; + while (SDL_PollEvent(&event) == 1) { + if (event.type == SDL_QUIT) { + return; + } + } + + if (auto scene = currentScene.lock()) { + scene->update(ctx); + } + + SDL_RenderClear(sdlRenderer.get()); + + if (auto scene = currentScene.lock()) { + scene->render(sdlRenderer.get()); + } + + SDL_RenderPresent(sdlRenderer.get()); + + double exactTime = lsl::local_clock(); + + for (const auto& markerName : currentFrameMarkers) { + markerQueue->enqueue(Marker{markerName, exactTime}); + } + } +} From 09f8512d4b369baabef2bb2e6bf8d25942ff50e7 Mon Sep 17 00:00:00 2001 From: Michal Date: Wed, 3 Jun 2026 16:22:12 +0200 Subject: [PATCH 5/5] refactor: create seperate libraries for scene, renderer and parser --- .clang-tidy | 3 ++- .github/workflows/ci.yml | 2 +- CMakeLists.txt | 2 +- cmake/Dependencies.cmake | 3 +++ cmake/StaticAnalysis.cmake | 2 +- src/CMakeLists.txt | 32 +++++++++++--------------------- src/parser/CMakeLists.txt | 7 +++++++ src/renderer/CMakeLists.txt | 15 +++++++++++++++ src/scene/CMakeLists.txt | 8 ++++++++ 9 files changed, 49 insertions(+), 25 deletions(-) create mode 100644 src/parser/CMakeLists.txt create mode 100644 src/renderer/CMakeLists.txt create mode 100644 src/scene/CMakeLists.txt diff --git a/.clang-tidy b/.clang-tidy index 3def4bd..0842f8d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,4 +1,5 @@ Checks: 'bugprone-*,cppcoreguidelines-*,performance-*,readability-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-array-to-pointer-decay' WarningsAsErrors: '' -HeaderFilterRegex: '^(?!.*\.(pb\.h|pb\.cc)$).*$' +HeaderFilterRegex: '.*' +ExcludeHeaderFilterRegex: '.*\.(pb\.h|pb\.cc)$' FormatStyle: 'file' \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6806370..4f722bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y cmake clang-format clang-tidy libsdl2-dev protobuf-compiler + sudo apt-get install -y cmake clang-format clang-tidy-20 libsdl2-dev protobuf-compiler - name: Check Code Formatting run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index cd61016..23a1575 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.25) project(NeuronIDE CXX) set(CMAKE_CXX_STANDARD 20) diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index bce5c33..64b0692 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -6,6 +6,7 @@ include(FetchContent) FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip + SYSTEM ) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) @@ -15,6 +16,7 @@ FetchContent_Declare( liblsl GIT_REPOSITORY https://github.com/sccn/liblsl.git GIT_TAG v1.16.2 + SYSTEM ) set(LSL_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) FetchContent_MakeAvailable(liblsl) @@ -24,6 +26,7 @@ FetchContent_Declare( concurrentqueue GIT_REPOSITORY https://github.com/cameron314/concurrentqueue.git GIT_TAG v1.0.4 + SYSTEM ) FetchContent_MakeAvailable(concurrentqueue) diff --git a/cmake/StaticAnalysis.cmake b/cmake/StaticAnalysis.cmake index 21b9b19..9b9d697 100644 --- a/cmake/StaticAnalysis.cmake +++ b/cmake/StaticAnalysis.cmake @@ -1,7 +1,7 @@ # cmake/StaticAnalysis.cmake # --- Clang-Tidy Configuration --- -find_program(CLANG_TIDY_EXE NAMES "clang-tidy") +find_program(CLANG_TIDY_EXE NAMES "clang-tidy-20") if(CLANG_TIDY_EXE) message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2d94a45..47c141c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,29 +1,19 @@ protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/../protoFiles/neuronide.proto) -add_library(runtime_core OBJECT - Runtime.cpp - parser/Parser.cpp - scene/components/ComponentRegistry.cpp - scene/components/BlinkComponent.cpp - scene/SceneObject.cpp - scene/Scene.cpp - renderer/Renderer.cpp - ${PROTO_SRCS} - ${PROTO_HDRS} -) +add_library(neuronide_proto STATIC ${PROTO_SRCS} ${PROTO_HDRS}) +set_target_properties(neuronide_proto PROPERTIES CXX_CLANG_TIDY "") +target_include_directories(neuronide_proto SYSTEM PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(neuronide_proto PUBLIC protobuf::libprotobuf) -target_include_directories(runtime_core SYSTEM PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_BINARY_DIR} - ${SDL2_INCLUDE_DIRS} -) +add_subdirectory(scene) +add_subdirectory(parser) +add_subdirectory(renderer) -target_link_libraries(runtime_core PUBLIC - lsl - concurrentqueue - protobuf::libprotobuf - ${SDL2_LIBRARIES} +add_library(runtime_core STATIC + Runtime.cpp ) +target_include_directories(runtime_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include) +target_link_libraries(runtime_core PUBLIC scene parser renderer) add_executable(NeuronIDE main.cpp) target_link_libraries(NeuronIDE PRIVATE runtime_core) \ No newline at end of file diff --git a/src/parser/CMakeLists.txt b/src/parser/CMakeLists.txt new file mode 100644 index 0000000..f06dab3 --- /dev/null +++ b/src/parser/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(parser OBJECT + Parser.cpp +) + +target_include_directories(parser PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include/parser) + +target_link_libraries(parser PUBLIC scene) \ No newline at end of file diff --git a/src/renderer/CMakeLists.txt b/src/renderer/CMakeLists.txt new file mode 100644 index 0000000..9f9daec --- /dev/null +++ b/src/renderer/CMakeLists.txt @@ -0,0 +1,15 @@ +add_library(renderer OBJECT + Renderer.cpp +) + +target_include_directories(renderer PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/renderer + ${SDL2_INCLUDE_DIRS} +) + +target_link_libraries(renderer PUBLIC + scene + lsl + concurrentqueue + ${SDL2_LIBRARIES} +) \ No newline at end of file diff --git a/src/scene/CMakeLists.txt b/src/scene/CMakeLists.txt new file mode 100644 index 0000000..1338a40 --- /dev/null +++ b/src/scene/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(scene OBJECT + SceneObject.cpp + Scene.cpp + components/ComponentRegistry.cpp + components/BlinkComponent.cpp +) +target_include_directories(scene PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include) +target_link_libraries(scene PUBLIC neuronide_proto) \ No newline at end of file