mirror of
https://github.com/hyprwm/aquamarine.git
synced 2024-11-17 10:46:00 +01:00
34 lines
902 B
C++
34 lines
902 B
C++
|
#include <aquamarine/misc/Attachment.hpp>
|
||
|
|
||
|
using namespace Aquamarine;
|
||
|
using namespace Hyprutils::Memory;
|
||
|
#define SP CSharedPointer
|
||
|
|
||
|
bool Aquamarine::CAttachmentManager::has(eAttachmentType type) {
|
||
|
for (auto& a : attachments) {
|
||
|
if (a->type() == type)
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
SP<IAttachment> Aquamarine::CAttachmentManager::get(eAttachmentType type) {
|
||
|
for (auto& a : attachments) {
|
||
|
if (a->type() == type)
|
||
|
return a;
|
||
|
}
|
||
|
return nullptr;
|
||
|
}
|
||
|
|
||
|
void Aquamarine::CAttachmentManager::add(SP<IAttachment> attachment) {
|
||
|
attachments.emplace_back(attachment);
|
||
|
}
|
||
|
|
||
|
void Aquamarine::CAttachmentManager::remove(SP<IAttachment> attachment) {
|
||
|
std::erase(attachments, attachment);
|
||
|
}
|
||
|
|
||
|
void Aquamarine::CAttachmentManager::removeByType(eAttachmentType type) {
|
||
|
std::erase_if(attachments, [type](const auto& e) { return e->type() == type; });
|
||
|
}
|