-
Notifications
You must be signed in to change notification settings - Fork 12
/
bag_layer.h
87 lines (61 loc) · 2.27 KB
/
bag_layer.h
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef BAG_LAYER_H
#define BAG_LAYER_H
#include "bag_config.h"
#include "bag_fordec.h"
#include "bag_types.h"
#include "bag_uint8array.h"
#include <memory>
namespace BAG {
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // std classes do not have DLL-interface when exporting
#endif
//! The interface for a layer.
class BAG_API Layer
{
public:
virtual ~Layer() = default;
Layer(const Layer&) = delete;
Layer(Layer&&) = delete;
Layer& operator=(const Layer&) = delete;
Layer& operator=(Layer&&) = delete;
bool operator==(const Layer &rhs) const noexcept {
return m_pLayerDescriptor == rhs.m_pLayerDescriptor &&
weak_ptr_equals(m_pBagDataset, rhs.m_pBagDataset);
}
bool operator!=(const Layer &rhs) const noexcept {
return !(rhs == *this);
}
static DataType getDataType(LayerType layerType) noexcept;
static uint8_t getElementSize(DataType type);
static std::string getInternalPath(LayerType layerType,
GroupType groupType = UNKNOWN_GROUP_TYPE);
std::shared_ptr<LayerDescriptor> getDescriptor() & noexcept;
std::shared_ptr<const LayerDescriptor> getDescriptor() const & noexcept;
UInt8Array read(uint32_t rowStart,
uint32_t columnStart, uint32_t rowEnd, uint32_t columnEnd) const;
void write(uint32_t rowStart, uint32_t columnStart, uint32_t rowEnd,
uint32_t columnEnd, const uint8_t* buffer);
void writeAttributes() const;
protected:
Layer(Dataset& dataset, LayerDescriptor& descriptor);
std::weak_ptr<Dataset> getDataset() & noexcept;
std::weak_ptr<const Dataset> getDataset() const & noexcept;
private:
virtual UInt8Array readProxy(uint32_t rowStart,
uint32_t columnStart, uint32_t rowEnd, uint32_t columnEnd) const = 0;
virtual void writeProxy(uint32_t rowStart, uint32_t columnStart,
uint32_t rowEnd, uint32_t columnEnd, const uint8_t* buffer) = 0;
virtual void writeAttributesProxy() const = 0;
//! The HDF5 DataSet this layer is stored in.
std::weak_ptr<Dataset> m_pBagDataset;
//! The layer's descriptor (owned).
std::shared_ptr<LayerDescriptor> m_pLayerDescriptor;
friend Dataset;
friend ValueTable;
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif
} // namespace BAG
#endif //BAG_LAYER_H