init view abstractions

This commit is contained in:
m-aXimilian
2025-06-16 13:19:28 +02:00
parent 189c11aea4
commit 08e27170a3
7 changed files with 72 additions and 26 deletions
+6 -2
View File
@@ -14,8 +14,12 @@ class PixelariumImage
// get back the defaults
PixelariumImage() = default;
// we cannot copy an Image since this conflicts with the _img field
PixelariumImage(const PixelariumImage& other) = delete;
PixelariumImage(const PixelariumImage& other)
{
// be ware!!
// we make a copy of the image data here!
img_ = std::make_unique<cv::Mat>(*other.img_);
};
PixelariumImage(PixelariumImage&& other) noexcept
: img_(std::move(other.img_)) {}
// requires a copy ctor which we don't have
+2
View File
@@ -28,6 +28,7 @@ class IResourcePool
virtual bool UpdateResource(size_t id, std::unique_ptr<R> res) = 0;
virtual bool DeleteResource(size_t id) = 0;
virtual void EnumerateResources(const std::function<void(size_t, const R&)>& 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,7 @@ class ImageResourcePool : public IResourcePool<imaging::PixelariumImage>
void EnumerateResources(const std::function<void(size_t, const imaging::PixelariumImage&)>& func) override;
size_t GetTotalSize() const override { return resources_.size();}
private:
std::unordered_map<size_t, std::unique_ptr<imaging::PixelariumImage>> resources_;
};