Skip to content

Commit

Permalink
dev: Add an improved image model.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin42 committed Sep 29, 2024
1 parent 90cb6b5 commit e89c0ef
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 22 deletions.
22 changes: 17 additions & 5 deletions PB/include/pb/entities/CollageImage.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#pragma once

namespace PB
{
class CollageImage
{
#include <pb/entities/GenericImage.h>

namespace PB {
class CollageImage : public GenericImage {
public:
explicit CollageImage(Path projectPath, std::string hash,
std::vector<Path> sources)
: GenericImage(projectPath, hash), mSources(sources)
{
}
~CollageImage() = default;

std::vector<Path> sources() const { return mSources; }

private:
std::vector<Path> mSources;
};
}
} // namespace PB
21 changes: 16 additions & 5 deletions PB/include/pb/entities/GenericImage.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
#pragma once

namespace PB
{
class GenericImage
{
#include <pb/util/Traits.h>

namespace PB {
class GenericImage {
public:
explicit GenericImage(Path projectPath, std::string hash);
virtual ~GenericImage() = default;

Path full() const;
Path medium() const;
Path small() const;

private:
Path mProjectPath;
std::string mHash;
};
}
} // namespace PB
21 changes: 16 additions & 5 deletions PB/include/pb/entities/RegularImageV2.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
#pragma once

namespace PB
{
class RegularImageV2
{
#include <pb/entities/GenericImage.h>

namespace PB {
class RegularImageV2 final : public GenericImage {
public:
explicit RegularImageV2(Path projectPath, std::string hash, Path original)
: GenericImage(projectPath, hash), maybeOriginal(original)
{
}
~RegularImageV2() = default;

std::optional<Path> original() const { return maybeOriginal; }

private:
std::optional<Path> maybeOriginal;
};
}
} // namespace PB
21 changes: 16 additions & 5 deletions PB/include/pb/entities/TextImageV2.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
#pragma once

namespace PB
{
class TextImageV2
{
#include <pb/entities/GenericImage.h>

namespace PB {
class TextImageV2 final : public GenericImage {
public:
explicit TextImageV2(Path projectPath, std::string hash, std::string text)
: GenericImage(projectPath, hash), mText(text)
{
}
~TextImageV2() = default;

std::string text() const { return mText; }

private:
std::string mText;
};
}
} // namespace PB
22 changes: 20 additions & 2 deletions PB/src/GenericImage.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
#include <pb/GenericImage.h>
#include <pb/entities/GenericImage.h>

namespace PB {
GenericImage::GenericImage(Path projectPath, std::string hash)
: mProjectPath(std::move(projectPath)), mHash(std::move(hash))
{
}

Path GenericImage::full() const
{
return mProjectPath / (mHash + "-full" + ".jpg");
}

namespace PB
Path GenericImage::medium() const
{
return mProjectPath / (mHash + "-medium" + ".jpg");
}

Path GenericImage::small() const
{
return mProjectPath / (mHash + "-small" + ".jpg");
}

} // namespace PB

0 comments on commit e89c0ef

Please sign in to comment.