Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef BAG_LAYER_H |
2 | | #define BAG_LAYER_H |
3 | | |
4 | | #include "bag_config.h" |
5 | | #include "bag_fordec.h" |
6 | | #include "bag_types.h" |
7 | | #include "bag_uint8array.h" |
8 | | |
9 | | #include <memory> |
10 | | |
11 | | |
12 | | namespace BAG { |
13 | | |
14 | | #ifdef _MSC_VER |
15 | | #pragma warning(push) |
16 | | #pragma warning(disable: 4251) // std classes do not have DLL-interface when exporting |
17 | | #endif |
18 | | |
19 | | //! The interface for a layer. |
20 | | class BAG_API Layer |
21 | | { |
22 | | public: |
23 | 260 | virtual ~Layer() = default; |
24 | | |
25 | | Layer(const Layer&) = delete; |
26 | | Layer(Layer&&) = delete; |
27 | | |
28 | | Layer& operator=(const Layer&) = delete; |
29 | | Layer& operator=(Layer&&) = delete; |
30 | | |
31 | 0 | bool operator==(const Layer &rhs) const noexcept { |
32 | 0 | return m_pLayerDescriptor == rhs.m_pLayerDescriptor && |
33 | 0 | weak_ptr_equals(m_pBagDataset, rhs.m_pBagDataset); |
34 | 0 | } |
35 | | |
36 | 0 | bool operator!=(const Layer &rhs) const noexcept { |
37 | 0 | return !(rhs == *this); |
38 | 0 | } |
39 | | |
40 | | static DataType getDataType(LayerType layerType) noexcept; |
41 | | static uint8_t getElementSize(DataType type); |
42 | | static std::string getInternalPath(LayerType layerType, |
43 | | GroupType groupType = UNKNOWN_GROUP_TYPE); |
44 | | |
45 | | std::shared_ptr<LayerDescriptor> getDescriptor() & noexcept; |
46 | | std::shared_ptr<const LayerDescriptor> getDescriptor() const & noexcept; |
47 | | |
48 | | UInt8Array read(uint32_t rowStart, |
49 | | uint32_t columnStart, uint32_t rowEnd, uint32_t columnEnd) const; |
50 | | |
51 | | void write(uint32_t rowStart, uint32_t columnStart, uint32_t rowEnd, |
52 | | uint32_t columnEnd, const uint8_t* buffer); |
53 | | |
54 | | void writeAttributes() const; |
55 | | |
56 | | protected: |
57 | | Layer(Dataset& dataset, LayerDescriptor& descriptor); |
58 | | |
59 | | std::weak_ptr<Dataset> getDataset() & noexcept; |
60 | | std::weak_ptr<const Dataset> getDataset() const & noexcept; |
61 | | |
62 | | private: |
63 | | virtual UInt8Array readProxy(uint32_t rowStart, |
64 | | uint32_t columnStart, uint32_t rowEnd, uint32_t columnEnd) const = 0; |
65 | | |
66 | | virtual void writeProxy(uint32_t rowStart, uint32_t columnStart, |
67 | | uint32_t rowEnd, uint32_t columnEnd, const uint8_t* buffer) = 0; |
68 | | |
69 | | virtual void writeAttributesProxy() const = 0; |
70 | | |
71 | | //! The HDF5 DataSet this layer is stored in. |
72 | | std::weak_ptr<Dataset> m_pBagDataset; |
73 | | //! The layer's descriptor (owned). |
74 | | std::shared_ptr<LayerDescriptor> m_pLayerDescriptor; |
75 | | |
76 | | friend Dataset; |
77 | | friend ValueTable; |
78 | | }; |
79 | | |
80 | | #ifdef _MSC_VER |
81 | | #pragma warning(pop) |
82 | | #endif |
83 | | |
84 | | } // namespace BAG |
85 | | |
86 | | #endif //BAG_LAYER_H |
87 | | |