Misc Improvements (#7)

* get rid of optional<ptr> -> double indirection

* more optional cleanup

* fix

* add more render pixel type options

* towards different views

* missing virtual declaration of ShowImage

* fix runtime

* init image view factory

* fix build

Render Image close button re-enable

add readme

init documentation

use awesomeDoxygen

ci build docs

install doxygen

id token permission

add pages write permission
This commit is contained in:
m-aXimilian
2025-09-23 21:57:08 +02:00
committed by Maximilian Kueffner
parent 0be064bb8e
commit 235d00192a
34 changed files with 418 additions and 173 deletions
+2 -1
View File
@@ -1,9 +1,10 @@
set(PIXELARIUM_TITLE ${CMAKE_PROJECT_NAME})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/app_resources_default.h.in
${CMAKE_BINARY_DIR}/app_resources_default.h @ONLY)
set(APPLIBSRC
AppGLFW.hpp
AppGLFW.cpp
DefaultApp.hpp
DefaultApp.cpp
${imgui_DIR}/imgui.cpp
${imgui_DIR}/imgui_demo.cpp
+1 -2
View File
@@ -57,7 +57,7 @@ void pixelarium::ui::DefaultApp::RenderImages()
void pixelarium::ui::DefaultApp::ImageGalleryRender()
{
ImGui::SetNextWindowSize(ImVec2(300, 500));
ImGui::SetNextWindowSize(ImVec2(300, 550));
ImGui::Begin(SHOWIMAGEGALLERY, &this->image_listp_);
// this updates the render collection
@@ -121,7 +121,6 @@ void pixelarium::ui::DefaultApp::ImageGalleryRender()
void pixelarium::ui::DefaultApp::LoadImage()
{
size_t last_id{};
auto res{pfd::open_file("Load Inputs", pfd::path::home(), {"All Files", "*"}, pfd::opt::multiselect).result()};
for (auto& p : res)
{
+4
View File
@@ -7,9 +7,13 @@ message(STATUS "OpenCV_LIBs from: " ${OpenCV_LIBS})
set(IMAGELIBSRC
IPixelariumImage.hpp
PixelariumImageFactory.hpp
PixelariumImageFactory.cpp
impl/PixelariumJpg.hpp
impl/PixelariumJpg.cpp
impl/PixelariumPng.hpp
impl/PixelariumPng.cpp
impl/PixelariumCzi.hpp
impl/PixelariumCzi.cpp
)
+16 -5
View File
@@ -4,7 +4,6 @@
#include <functional>
#include <memory>
#include <opencv2/core/mat.hpp>
#include <optional>
#include <string>
namespace pixelarium::imaging
@@ -35,15 +34,27 @@ class IPixelariumImage
virtual ~IPixelariumImage() = default;
// this will have to throw or something for multidimensional images
virtual std::optional<std::unique_ptr<cv::Mat>> TryGetImage() = 0;
virtual std::unique_ptr<cv::Mat> TryGetImage() = 0;
virtual std::optional<std::unique_ptr<cv::Mat>> TryGetImage(const IImageQuery&) = 0;
virtual std::unique_ptr<cv::Mat> TryGetImage(const IImageQuery&) = 0;
virtual std::string Name() const noexcept = 0;
virtual std::vector<std::unique_ptr<cv::Mat>> TryGetImages(const IImageQuery&) = 0;
virtual bool Empty() const noexcept = 0;
virtual std::filesystem::path Uri() const noexcept = 0;
// default implemented
public:
virtual std::filesystem::path Uri() const noexcept { return this->uri_; }
virtual std::string Name() const noexcept
{
if (!this->uri_.empty())
{
return this->uri_.filename().string();
}
return {};
}
public:
const static ImageFileType type_{ImageFileType::ABSTRACT};
-20
View File
@@ -8,26 +8,6 @@
#include "impl/PixelariumJpg.hpp"
#include "impl/PixelariumPng.hpp"
constexpr pixelarium::imaging::ImageFileType ExtensionToType(const std::string& extension)
{
std::string lower_ext{extension};
std::ranges::transform(extension, lower_ext.begin(), [](const char c) -> char { return std::tolower(c); });
if (lower_ext == ".jpg" || lower_ext == ".jpeg")
{
return pixelarium::imaging::ImageFileType::JPG;
}
if (lower_ext == ".png")
{
return pixelarium::imaging::ImageFileType::PNG;
}
if (lower_ext == ".czi")
{
return pixelarium::imaging::ImageFileType::CZI;
}
return pixelarium::imaging::ImageFileType::UNKNOWN;
}
/*static*/ std::unique_ptr<pixelarium::imaging::IPixelariumImage>
pixelarium::imaging::PixelariumImageFactory::CreateImage(const std::string& uri)
+21
View File
@@ -5,6 +5,27 @@
#include "IPixelariumImage.hpp"
namespace pixelarium::imaging
{
constexpr pixelarium::imaging::ImageFileType ExtensionToType(const std::string& extension)
{
std::string lower_ext{extension};
std::ranges::transform(extension, lower_ext.begin(), [](const char c) -> char { return std::tolower(c); });
if (lower_ext == ".jpg" || lower_ext == ".jpeg")
{
return pixelarium::imaging::ImageFileType::JPG;
}
if (lower_ext == ".png")
{
return pixelarium::imaging::ImageFileType::PNG;
}
if (lower_ext == ".czi")
{
return pixelarium::imaging::ImageFileType::CZI;
}
return pixelarium::imaging::ImageFileType::UNKNOWN;
}
class PixelariumImageFactory
{
public:
+1 -1
View File
@@ -92,7 +92,7 @@ pixelarium::imaging::PixelariumCzi::PixelariumCzi(const std::string& uri)
this->uri_ = std::filesystem::path(uri);
}
std::optional<std::unique_ptr<cv::Mat>> pixelarium::imaging::PixelariumCzi::TryGetImage()
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumCzi::TryGetImage()
{
auto stream = libCZI::CreateStreamFromFile(this->uri_.wstring().c_str());
auto cziReader = libCZI::CreateCZIReader();
+10 -11
View File
@@ -6,6 +6,11 @@
namespace pixelarium::imaging
{
struct CziParams : public IImageQuery
{
};
class PixelariumCzi : public IPixelariumImage
{
public:
@@ -13,26 +18,20 @@ class PixelariumCzi : public IPixelariumImage
// IPixelariumImage member implementations
public:
std::optional<std::unique_ptr<cv::Mat>> TryGetImage() override;
std::unique_ptr<cv::Mat> TryGetImage() override;
std::optional<std::unique_ptr<cv::Mat>> TryGetImage(const IImageQuery&) override
std::unique_ptr<cv::Mat> TryGetImage(const IImageQuery&) override
{
// ToDo: proper error
throw std::runtime_error("Not implemented.");
}
std::string Name() const noexcept override
std::vector<std::unique_ptr<cv::Mat>> TryGetImages(const IImageQuery&) override
{
if (!this->uri_.empty())
{
return this->uri_.filename().string();
}
return {};
// ToDo: proper error
throw std::runtime_error("Not implemented.");
}
std::filesystem::path Uri() const noexcept override { return this->uri_.string(); }
bool Empty() const noexcept override { return this->is_empty_; }
public:
+1 -1
View File
@@ -16,7 +16,7 @@ pixelarium::imaging::PixelariumJpg::PixelariumJpg(const std::string& uri)
this->uri_ = std::filesystem::path(uri);
}
std::optional<std::unique_ptr<cv::Mat>> pixelarium::imaging::PixelariumJpg::TryGetImage()
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumJpg::TryGetImage()
{
try
{
+5 -14
View File
@@ -14,27 +14,18 @@ class PixelariumJpg : public IPixelariumImage
// IPixelariumImage member implementations
public:
std::optional<std::unique_ptr<cv::Mat>> TryGetImage() override;
std::unique_ptr<cv::Mat> TryGetImage() override;
std::optional<std::unique_ptr<cv::Mat>> TryGetImage(const IImageQuery&) override
std::unique_ptr<cv::Mat> TryGetImage(const IImageQuery&) override
{
// ToDo: proper error
throw std::runtime_error("Not possible with jpg.");
}
std::string Name() const noexcept override
std::vector<std::unique_ptr<cv::Mat>> TryGetImages(const IImageQuery&) override
{
if (!this->uri_.empty())
{
return this->uri_.filename().string();
}
return {};
}
std::filesystem::path Uri() const noexcept override
{
return this->uri_.string();
// ToDo: proper error
throw std::runtime_error("Not possible with jpg.");
}
bool Empty() const noexcept override { return this->is_empty_; }
+1 -1
View File
@@ -16,7 +16,7 @@ pixelarium::imaging::PixelariumPng::PixelariumPng(const std::string& uri)
this->uri_ = std::filesystem::path(uri);
}
std::optional<std::unique_ptr<cv::Mat>> pixelarium::imaging::PixelariumPng::TryGetImage()
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumPng::TryGetImage()
{
try
{
+5 -14
View File
@@ -14,27 +14,18 @@ class PixelariumPng : public IPixelariumImage
// IPixelariumImage member implementations
public:
std::optional<std::unique_ptr<cv::Mat>> TryGetImage() override;
std::unique_ptr<cv::Mat> TryGetImage() override;
std::optional<std::unique_ptr<cv::Mat>> TryGetImage(const IImageQuery&) override
std::unique_ptr<cv::Mat> TryGetImage(const IImageQuery&) override
{
// ToDo: proper error
throw std::runtime_error("Not possible with png.");
}
std::string Name() const noexcept override
std::vector<std::unique_ptr<cv::Mat>> TryGetImages(const IImageQuery&) override
{
if (!this->uri_.empty())
{
return this->uri_.filename().string();
}
return {};
}
std::filesystem::path Uri() const noexcept override
{
return this->uri_.string();
// ToDo: proper error
throw std::runtime_error("Not possible with png.");
}
bool Empty() const noexcept override { return this->is_empty_; }
+6 -1
View File
@@ -1,9 +1,14 @@
set(RENDERLIBNAME pixelariumrenderlib)
set(RENDERLIBSRC
CvMatRender.hpp
CvMatRender.cpp
RenderImageManager.hpp
RenderImageManager.cpp
PixelariumImageView.cpp
IPixelariumImageView.hpp
PixelariumImageViewDefault.hpp
PixelariumImageViewDefault.cpp
ImageViewFactory.hpp
ImageViewFactory.cpp)
add_library(${RENDERLIBNAME} STATIC
+22 -21
View File
@@ -61,24 +61,30 @@ GLuint pixelarium::render::CvMatRender::uploadTexture()
glBindTexture(GL_TEXTURE_2D, this->texture_);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
const int width = img_.cols;
const int height = img_.rows;
GLenum format = (img_.type() == CV_32FC3 || img_.type() == CV_32FC1) ? GL_RGB : GL_RGBA;
GLenum type = (img_.type() == CV_16U || img_.type() == CV_16UC3) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
GLenum internalFormat = GL_RGBA;
if (img_.type() == CV_32FC3 || img_.type() == CV_32FC1)
{
internalFormat = GL_RGB;
switch (img_.type()) {
case CV_16U:
case CV_16UC3:
case 26:
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT, img_.data);
break;
case 5:
case 29:
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_FLOAT, img_.data);
break;
default:
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img_.cols, img_.rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, img_.data);
break;
}
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, img_.data);
GLenum error = glGetError();
if (error != GL_NO_ERROR)
{
@@ -98,9 +104,9 @@ GLuint pixelarium::render::CvMatRender::Render() { return this->uploadTexture();
GLuint pixelarium::render::CvMatRender::Render(float factor)
{
auto res_val {this->base_->TryGetImage()};
if (res_val.has_value())
if (res_val)
{
cv::resize(*res_val.value(), this->img_, cv::Size(0, 0), factor, factor, cv::INTER_LINEAR_EXACT);
cv::resize(*res_val, this->img_, cv::Size(0, 0), factor, factor, cv::INTER_LINEAR_EXACT);
}
return this->uploadTexture();
@@ -114,12 +120,12 @@ GLuint pixelarium::render::CvMatRender::Render(size_t width, size_t height)
{
auto res_val {this->base_->TryGetImage()};
if (!res_val.has_value())
if (!res_val)
{
return this->Render(1.0f);
}
const auto sz{res_val.value()->size()};
const auto sz{res_val->size()};
const auto get_factor = [](auto opt1, auto opt2) -> float { return opt1 < opt2 ? opt1 : opt2; };
@@ -137,16 +143,11 @@ void pixelarium::render::CvMatRender::ResetRenderImage()
auto root_res = this->base_->TryGetImage();
if (!root_res.has_value())
{
return;
}
if (root_res.value() == nullptr)
if (!root_res)
{
return;
}
// we copy here
this->img_ = (*root_res.value()).clone();
this->img_ = root_res->clone();
}
+28
View File
@@ -0,0 +1,28 @@
#pragma once
#include <memory>
#include "imaging/IPixelariumImage.hpp"
#include "rendering/CvMatRender.hpp"
namespace pixelarium::render
{
class IPixelariumImageView
{
public:
virtual ~IPixelariumImageView() = default;
virtual void ShowImage() = 0;
// default implemented
public:
virtual const bool* GetStatus() const noexcept { return &this->open_p; }
virtual void ForceUpdate() noexcept { this->is_dirty_ = true; }
protected:
std::shared_ptr<imaging::IPixelariumImage> img_{};
std::unique_ptr<cv::Mat> cached_image_{};
render::CvMatRender render_;
bool open_p{true};
bool is_dirty_{true};
};
} // namespace pixelarium::render
+27 -7
View File
@@ -1,29 +1,49 @@
#include "ImageViewFactory.hpp"
#include <memory>
#include <optional>
#include "imaging/PixelariumImageFactory.hpp"
#include "rendering/IPixelariumImageView.hpp"
#include "rendering/PixelariumImageViewDefault.hpp"
/// @brief Creates a PixelariumImageView from a resource image.
/// @param image_id The ID of the image resource to render.
/// @return A unique pointer to the PixelariumImageView, or nullptr if the image resource is not found or is empty. The image data is copied.
std::unique_ptr<pixelarium::render::PixelariumImageView> pixelarium::render::ImageViewFactory::RenderImage(
std::unique_ptr<pixelarium::render::IPixelariumImageView> pixelarium::render::ImageViewFactory::RenderImage(
size_t image_id)
{
auto res{this->image_pool_.GetResource(image_id)};
if (!res.has_value())
auto img{res.lock()};
if (img == nullptr)
{
return {};
}
auto img {res.value().lock()};
if (img->Empty())
{
return {};
}
// beware: here we copy the actual image resource over to the new image
return std::make_unique<PixelariumImageView>(img);
auto type = imaging::ExtensionToType(img->Uri().extension().string());
switch (type)
{
case imaging::ImageFileType::UNKNOWN:
case imaging::ImageFileType::ABSTRACT:
return {};
case imaging::ImageFileType::PNG:
case imaging::ImageFileType::JPG:
log_.Info("Creating a Default View");
// beware: here we copy the actual image resource over to the new image
return std::make_unique<PixelariumImageViewDefault>(img);
case imaging::ImageFileType::CZI:
log_.Info("{}: Creating a CZI View");
// beware: here we copy the actual image resource over to the new image
return std::make_unique<PixelariumImageViewDefault>(img);
// return std::make_unique<PixelariumImageViewCzi>(img);
default:
return {};
}
}
+7 -3
View File
@@ -1,20 +1,24 @@
#pragma once
#include "PixelariumImageView.hpp"
#include "PixelariumImageViewDefault.hpp"
#include "rendering/IPixelariumImageView.hpp"
#include "resources/resource.hpp"
#include "utilities/ILog.hpp"
namespace pixelarium::render
{
class ImageViewFactory
{
using Image = imaging::IPixelariumImage;
using Pool = resources::ImageResourcePool;
using Log = utils::log::ILog;
public:
explicit ImageViewFactory(Pool& pool) : image_pool_(pool) {}
explicit ImageViewFactory(Pool& pool, const Log& log) : image_pool_(pool), log_(log) {}
std::unique_ptr<PixelariumImageView> RenderImage(size_t id);
std::unique_ptr<IPixelariumImageView> RenderImage(size_t id);
private:
Pool& image_pool_;
const Log& log_;
};
} // namespace pixelarium::render
-36
View File
@@ -1,36 +0,0 @@
#pragma once
#include <memory>
#include "imaging/IPixelariumImage.hpp"
#include "imgui.h"
#include "rendering/CvMatRender.hpp"
namespace pixelarium::render
{
class PixelariumImageView
{
using Image = imaging::IPixelariumImage;
using Render = render::CvMatRender;
public:
explicit PixelariumImageView(std::shared_ptr<Image> img) : img_(img) { render_ = Render(img_); }
PixelariumImageView() = delete;
PixelariumImageView(PixelariumImageView&) = delete;
PixelariumImageView(const PixelariumImageView&) = delete;
PixelariumImageView(PixelariumImageView&&) = delete;
PixelariumImageView& operator=(PixelariumImageView&) = delete;
PixelariumImageView& operator=(PixelariumImageView&&) = delete;
// void ToggleView(bool target) { open_p = target; }
const bool* GetStatus() const noexcept { return &this->open_p; }
void ShowImage();
private:
std::shared_ptr<Image> img_;
std::optional<std::unique_ptr<cv::Mat>> cached_image_ {};
Render render_;
bool open_p{true};
ImVec2 curr_dim_{};
};
} // namespace pixelarium::render
@@ -1,4 +1,4 @@
#include "PixelariumImageView.hpp"
#include "PixelariumImageViewDefault.hpp"
#include <format>
@@ -39,14 +39,15 @@ ImVec2 aspect_const_dimensions(const ImVec2& raw_dim, const ImVec2& curr_dim)
/// If the image is null, empty, or has an empty name, the function returns immediately. Otherwise, it creates an ImGui
/// window with a horizontal scrollbar and menu bar. The image is rendered using the CvMatRender object, resizing it to
/// fit the available window space. The raw and rendered dimensions are displayed below the image.
void pixelarium::render::PixelariumImageView::ShowImage()
void pixelarium::render::PixelariumImageViewDefault::ShowImage()
{
if (!this->cached_image_.has_value())
if (!this->cached_image_ || this->is_dirty_)
{
this->cached_image_ = this->img_->TryGetImage();
this->is_dirty_ = false;
}
if (this->img_->Empty() || this->img_->type_ == imaging::ImageFileType::UNKNOWN || !cached_image_.has_value() || this->img_->Name().empty())
if (this->img_->Empty() || this->img_->type_ == imaging::ImageFileType::UNKNOWN || !cached_image_ || this->img_->Name().empty())
{
// do nothing
return;
@@ -63,7 +64,7 @@ void pixelarium::render::PixelariumImageView::ShowImage()
this->curr_dim_ = new_dim;
ImVec2 dim(cached_image_.value()->cols, cached_image_.value()->rows);
ImVec2 dim(cached_image_->cols, cached_image_->rows);
ImGui::Image(reinterpret_cast<ImTextureID>(reinterpret_cast<void*>(texture)),
aspect_const_dimensions(dim, new_dim));
@@ -0,0 +1,35 @@
#pragma once
#include <memory>
#include "imaging/IPixelariumImage.hpp"
#include "imgui.h"
#include "rendering/CvMatRender.hpp"
#include "rendering/IPixelariumImageView.hpp"
namespace pixelarium::render
{
class PixelariumImageViewDefault : public IPixelariumImageView
{
using Image = imaging::IPixelariumImage;
using Render = render::CvMatRender;
public:
explicit PixelariumImageViewDefault(std::shared_ptr<Image> img)
{
img_ = img;
render_ = Render(img_);
}
PixelariumImageViewDefault() = delete;
PixelariumImageViewDefault(PixelariumImageViewDefault&) = delete;
PixelariumImageViewDefault(const PixelariumImageViewDefault&) = delete;
PixelariumImageViewDefault(PixelariumImageViewDefault&&) = delete;
PixelariumImageViewDefault& operator=(PixelariumImageViewDefault&) = delete;
PixelariumImageViewDefault& operator=(PixelariumImageViewDefault&&) = delete;
void ShowImage() override;
private:
ImVec2 curr_dim_{};
};
} // namespace pixelarium::render
-1
View File
@@ -64,7 +64,6 @@ void pixelarium::render::RenderImageManager::Add(resources::ResourceKey key) noe
RenderImageStateWrapper
{
.view{ std::move(current_view) },
.show_state = current_view->GetStatus(),
}
}
);
+7 -3
View File
@@ -5,7 +5,8 @@
#include <unordered_set>
#include "ImageViewFactory.hpp"
#include "PixelariumImageView.hpp"
#include "PixelariumImageViewDefault.hpp"
#include "rendering/IPixelariumImageView.hpp"
#include "resources/resource.hpp"
#include "utilities/ILog.hpp"
@@ -13,9 +14,12 @@
// aggregating views that should be rendered (or not)
namespace pixelarium::render
{
/// @brief Instead of directly using the view, we
/// proxy it through a wrapper. This allows for arbitrary additional data
/// to be added in future
struct RenderImageStateWrapper
{
std::unique_ptr<PixelariumImageView> view;
std::unique_ptr<IPixelariumImageView> view;
const bool* show_state;
};
@@ -25,7 +29,7 @@ class RenderImageManager
public:
explicit RenderImageManager(Pool& pool, const utils::log::ILog& log)
: view_factory_(std::make_unique<ImageViewFactory>(pool)), log_(log)
: view_factory_(std::make_unique<ImageViewFactory>(pool, log)), log_(log)
{
}
+1
View File
@@ -1,6 +1,7 @@
set(RESOURCELIBNAME pixelariumresourcelib)
set(RESOURCELIBSRC
resource.hpp
resource.cpp)
add_library(${RESOURCELIBNAME} STATIC
+3 -4
View File
@@ -4,7 +4,6 @@
#include <cstddef>
#include <functional>
#include <mutex>
#include <optional>
using pixelarium::imaging::IPixelariumImage;
using namespace std;
@@ -22,10 +21,10 @@ size_t GenerateId() { return id_.fetch_add(1, memory_order_relaxed); }
/// @brief Retrieves a resource from the pool.
/// @param id The ID of the resource to retrieve.
/// @return A pointer to the resource if found, otherwise an empty optional.
std::optional<std::weak_ptr<IPixelariumImage>> pixelarium::resources::ImageResourcePool::GetResource(ResourceKey id) const
std::weak_ptr<IPixelariumImage> pixelarium::resources::ImageResourcePool::GetResource(ResourceKey id) const
{
auto search{this->resources_.find(id)};
if (search == this->resources_.end()) return std::nullopt;
if (search == this->resources_.end()) return {};
return search->second;
}
@@ -81,7 +80,7 @@ bool pixelarium::resources::ImageResourcePool::DeleteResource(ResourceKey id)
/// @param func A function to call for each resource. The function should accept the resource ID and a const reference
/// to a PixelariumImage.
void pixelarium::resources::ImageResourcePool::EnumerateResources(
const std::function<void(ResourceKey, size_t, const imaging:: IPixelariumImage&)>& func)
const std::function<void(ResourceKey, size_t, const imaging::IPixelariumImage&)>& func)
{
size_t idx{0};
for (const auto& e : this->resources_)
+6 -6
View File
@@ -4,7 +4,6 @@
#include <functional>
#include <memory>
#include <mutex>
#include <optional>
#include <unordered_map>
#include "imaging/IPixelariumImage.hpp"
@@ -16,13 +15,14 @@ using ResourceKey = size_t;
struct empty_resource_exception : public std::exception
{
empty_resource_exception() {};
empty_resource_exception(const char* msg) : message_(msg) {};
const char* what() { return message_; }
empty_resource_exception(std::string& msg) : message_(msg) {};
const std::string& what() { return message_; }
private:
const char* message_ = "Empty Resource";
std::string message_ = "Empty Resource";
};
struct IResource
{
virtual ~IResource() = default;
@@ -36,7 +36,7 @@ class IResourcePool
{
public:
virtual ~IResourcePool() = default;
virtual std::optional<std::weak_ptr<ResT>> GetResource(size_t id) const = 0;
virtual std::weak_ptr<ResT> GetResource(size_t id) const = 0;
virtual ResourceKey SetResource(std::unique_ptr<ResT> res) = 0;
virtual bool ModifyResource(ResourceKey id, std::unique_ptr<ResT> res) = 0;
virtual bool DeleteResource(ResourceKey id) = 0;
@@ -61,7 +61,7 @@ class ImageResourcePool : public IResourcePool<imaging::IPixelariumImage>
ImageResourcePool& operator=(ImageResourcePool&) = delete;
ImageResourcePool& operator=(ImageResourcePool&&) = delete;
std::optional<std::weak_ptr<imaging::IPixelariumImage>> GetResource(ResourceKey id) const override;
std::weak_ptr<imaging::IPixelariumImage> GetResource(ResourceKey id) const override;
ResourceKey SetResource(std::unique_ptr<imaging::IPixelariumImage> res) override;
bool ModifyResource(ResourceKey id, std::unique_ptr<imaging::IPixelariumImage> res) override;
bool DeleteResource(ResourceKey id) override;
+2
View File
@@ -1,6 +1,8 @@
set(UTILSLIBNAME pixelariumutilslib)
set(UTILSLIBSRC
ILog.hpp
SpdLogger.hpp
SpdLogger.cpp)
add_library(${UTILSLIBNAME} STATIC ${UTILSLIBSRC})