some decouplings (#2)

* logger business

* code review

* rm c-style array

* extract image rendering to view

* missing view files

* init view abstractions

* leverage concepts and provide a templateized Enumerate function

* RVO

* get rid of some warnings

* logger business

* code review

* rm c-style array

* extract image rendering to view

* missing view files

* init view abstractions

* leverage concepts and provide a templateized Enumerate function

* RVO

* get rid of some warnings

* logger business

* code review

* rm c-style array

* init view abstractions

* leverage concepts and provide a templateized Enumerate function

* RVO

* get rid of some warnings

* logger business

* code review

* rm c-style array

* init view abstractions

* leverage concepts and provide a templateized Enumerate function

* RVO

* get rid of some warnings

* Factor out AppGLFW base class

The intention here is to get rid of scaffolding in the consumer
application class and allow to focus on the "important bits".

* Some cleanup

* dump unnecessary dependency

* link stuff where needed & use only what's needed

* remove deprecation warnings

* add gallery toggle

* make some includes private

* add presets

* remove dir locals, use presets instead

`projectile-configure-project' in conjunction with CMakePresets.json
will allow to configure the project.
`projectile-compile-project' does sth similar for the compile command.

This is equivalent to something like
~cmake --preset clang-debug && cmake --build build --preset clang-debug~

* use presets in pipeline

---------

Co-authored-by: m-aXimilian <keuffnermax@gmail.com>
This commit is contained in:
m-aXimilian
2025-08-18 22:39:43 +00:00
committed by GitHub
parent 566dd112ff
commit d71f4168fb
30 changed files with 548 additions and 259 deletions
+1
View File
@@ -1,6 +1,7 @@
#include "resource.hpp"
#include <atomic>
#include <functional>
#include <optional>
using pixelarium::imaging::PixelariumImage;
+19 -6
View File
@@ -1,5 +1,6 @@
#pragma once
#include <concepts>
#include <functional>
#include <memory>
#include <optional>
@@ -17,17 +18,17 @@ struct IResource
template <typename R>
concept ResT = requires(R& r) { static_cast<IResource&>(r); };
// template <ResT R>
template <typename R>
template <typename ResT>
class IResourcePool
{
public:
virtual ~IResourcePool() = default;
virtual std::optional<const R*> GetResource(size_t id) const = 0;
virtual size_t SetResource(std::unique_ptr<R> res) = 0;
virtual bool ModifyResource(size_t id, std::unique_ptr<R> res) = 0;
virtual std::optional<const ResT*> GetResource(size_t id) const = 0;
virtual size_t SetResource(std::unique_ptr<ResT> res) = 0;
virtual bool ModifyResource(size_t id, std::unique_ptr<ResT> res) = 0;
virtual bool DeleteResource(size_t id) = 0;
virtual void EnumerateResources(const std::function<void(size_t, const R&)>& func) = 0;
virtual void EnumerateResources(const std::function<void(size_t, const ResT&)>& func) = 0;
virtual size_t GetTotalSize() const = 0;
};
// Now with the =GetResource= method, I do not want to transfer ownership to the caller of that method. The ownership
@@ -52,6 +53,18 @@ class ImageResourcePool : public IResourcePool<imaging::PixelariumImage>
void EnumerateResources(const std::function<void(size_t, const imaging::PixelariumImage&)>& func) override;
template <typename Callable>
requires std::invocable<Callable, size_t, const imaging::PixelariumImage&>
void Enumerate(Callable&& func) const
{
for (const auto& e : this->resources_)
{
func(e.first, *e.second);
}
}
size_t GetTotalSize() const override { return resources_.size(); }
private:
std::unordered_map<size_t, std::unique_ptr<imaging::PixelariumImage>> resources_;
};