init view abstractions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user