/src/bag/api/bag_layerdescriptor.h
Line | Count | Source |
1 | | #ifndef BAG_LAYERDESCRIPTOR_H |
2 | | #define BAG_LAYERDESCRIPTOR_H |
3 | | |
4 | | #include "bag_config.h" |
5 | | #include "bag_fordec.h" |
6 | | #include "bag_types.h" |
7 | | |
8 | | #include <limits> |
9 | | #include <memory> |
10 | | #include <string> |
11 | | #include <tuple> |
12 | | |
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 | | namespace BAG { |
20 | | |
21 | | //! Describe a layer. |
22 | | class BAG_API LayerDescriptor : public std::enable_shared_from_this<LayerDescriptor> |
23 | | { |
24 | | public: |
25 | 195 | virtual ~LayerDescriptor() = default; |
26 | | |
27 | | LayerDescriptor(const LayerDescriptor&) = delete; |
28 | | LayerDescriptor(LayerDescriptor&&) = delete; |
29 | | |
30 | | LayerDescriptor& operator=(const LayerDescriptor&) = delete; |
31 | | LayerDescriptor& operator=(LayerDescriptor&&) = delete; |
32 | | |
33 | 0 | bool operator==(const LayerDescriptor &rhs) const noexcept { |
34 | 0 | return m_id == rhs.m_id && |
35 | 0 | m_layerType == rhs.m_layerType && |
36 | 0 | m_internalPath == rhs.m_internalPath && |
37 | 0 | m_name == rhs.m_name && |
38 | 0 | m_compressionLevel == rhs.m_compressionLevel && |
39 | 0 | m_chunkSize == rhs.m_chunkSize && |
40 | 0 | m_minMax == rhs.m_minMax; |
41 | 0 | } |
42 | | |
43 | 0 | bool operator!=(const LayerDescriptor &rhs) const noexcept { |
44 | 0 | return !(rhs == *this); |
45 | 0 | } |
46 | | |
47 | | uint64_t getChunkSize() const noexcept; |
48 | | int getCompressionLevel() const noexcept; |
49 | | DataType getDataType() const noexcept; |
50 | | uint8_t getElementSize() const noexcept; |
51 | | uint32_t getId() const noexcept; |
52 | | const std::string& getInternalPath() const & noexcept; |
53 | | LayerType getLayerType() const noexcept; |
54 | | std::tuple<float, float> getMinMax() const noexcept; |
55 | | const std::string& getName() const & noexcept; |
56 | | std::tuple<uint32_t, uint32_t> getDims() const & noexcept; |
57 | | |
58 | | LayerDescriptor& setName(std::string inName) & noexcept; |
59 | | LayerDescriptor& setMinMax(float min, float max) & noexcept; |
60 | | LayerDescriptor& setDims(uint64_t rows, uint64_t cols) & noexcept; |
61 | | |
62 | | protected: |
63 | | LayerDescriptor(uint32_t id, std::string internalPath, std::string name, |
64 | | LayerType type, uint64_t rows, uint64_t cols, uint64_t chunkSize, |
65 | | int compressionLevel); |
66 | | LayerDescriptor(const Dataset& dataset, LayerType type, |
67 | | uint64_t rows, uint64_t cols, |
68 | | std::string internalPath = {}, std::string name = {}); |
69 | | |
70 | | size_t getReadBufferSize(uint64_t rows, uint64_t columns) const noexcept; |
71 | | |
72 | | LayerDescriptor& setInternalPath(std::string inPath) & noexcept; |
73 | | |
74 | | private: |
75 | | virtual DataType getDataTypeProxy() const noexcept = 0; |
76 | | virtual uint8_t getElementSizeProxy() const noexcept = 0; |
77 | | |
78 | | //! The unique id. |
79 | | uint32_t m_id = kInvalidLayerId; |
80 | | //! The layer type. |
81 | | LayerType m_layerType = UNKNOWN_LAYER_TYPE; |
82 | | //! The path of the DataSet in the HDF5 file. |
83 | | std::string m_internalPath; |
84 | | //! The name of the layer. |
85 | | std::string m_name; |
86 | | //! The compression level of this layer (0-9). |
87 | | int m_compressionLevel = 0; |
88 | | //! The chunk size of this layer. |
89 | | uint64_t m_chunkSize = 0; |
90 | | //! The minimum and maximum value of this dataset. |
91 | | std::tuple<float, float> m_minMax{}; |
92 | | //! The dimensions of the layer. These are uint64_t (rather than uint32_t like elsewhere in the API) because |
93 | | //! dimensions are initialized from HDF5 hsize_t values, which are uint64_t. |
94 | | std::tuple<uint64_t, uint64_t> m_dims{}; |
95 | | |
96 | | friend GeorefMetadataLayer; |
97 | | friend InterleavedLegacyLayer; |
98 | | friend SurfaceCorrections; |
99 | | friend SimpleLayer; |
100 | | friend VRMetadata; |
101 | | }; |
102 | | |
103 | | #ifdef _MSC_VER |
104 | | #pragma warning(pop) |
105 | | #endif |
106 | | |
107 | | } // namespace BAG |
108 | | |
109 | | #endif // BAG_LAYERDESCRIPTOR_H |
110 | | |