-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpers.cpp
More file actions
27 lines (21 loc) · 929 Bytes
/
Helpers.cpp
File metadata and controls
27 lines (21 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "Helpers.h"
std::shared_ptr<baseImage> ImgSlots::get(size_t slot, bool remove)
{
if (m_slots.size() <= slot || slot < 0) throw DMcError("Slot out of range: " + std::to_string(m_slots.size()));
if (!m_slots[slot]) throw DMcError("Slot empty");
std::shared_ptr<baseImage> tmp = m_slots[slot];
if (remove) m_slots[slot] = nullptr;
return tmp;
}
void ImgSlots::set(size_t slot, std::shared_ptr<baseImage> img)
{
if (slot < 0) throw DMcError("Slot out of range: " + std::to_string(m_slots.size()));
if (m_slots.size() <= slot) m_slots.resize(slot + 1);
m_slots[slot] = img;
}
std::ostream& operator<<(std::ostream& stream, const baseImage& rhs)
{
stream << " size=" << rhs.w_virtual() << "x" << rhs.h_virtual() << (rhs.is_integer_virtual() ? " INT" : " FLOAT") << " chan=" << rhs.chan_virtual()
<< " bytes_per_element=" << rhs.size_element_virtual();
return stream;
}