/src/bag/api/bag_simplelayerdescriptor.cpp
Line | Count | Source |
1 | | |
2 | | #include "bag_dataset.h" |
3 | | #include "bag_simplelayerdescriptor.h" |
4 | | |
5 | | |
6 | | namespace BAG { |
7 | | |
8 | | //! Constructor. |
9 | | /*! |
10 | | \param id |
11 | | The unique layer id. |
12 | | \param type |
13 | | The layer type. |
14 | | \param chunkSize |
15 | | The chunk size the HDF5 DataSet will use. |
16 | | \param compressionLevel |
17 | | The compression level the HDF5 DataSet will use. |
18 | | */ |
19 | | SimpleLayerDescriptor::SimpleLayerDescriptor( |
20 | | uint32_t id, |
21 | | LayerType type, |
22 | | uint32_t rows, uint32_t cols, |
23 | | uint64_t chunkSize, |
24 | | int compressionLevel) |
25 | 0 | : LayerDescriptor(id, Layer::getInternalPath(type), |
26 | 0 | kLayerTypeMapString.at(type), type, rows, cols, chunkSize, compressionLevel) |
27 | 0 | , m_elementSize(Layer::getElementSize(Layer::getDataType(type))) |
28 | 0 | { |
29 | 0 | } |
30 | | |
31 | | //! Constructor. |
32 | | /*! |
33 | | \param dataset |
34 | | The BAG Dataset this layer will belong to. |
35 | | \param type |
36 | | The layer type. |
37 | | */ |
38 | | SimpleLayerDescriptor::SimpleLayerDescriptor( |
39 | | const Dataset& dataset, |
40 | | LayerType type, |
41 | | uint32_t rows, uint32_t cols) |
42 | 120 | : LayerDescriptor(dataset, type, rows, cols) |
43 | 120 | , m_elementSize(Layer::getElementSize(Layer::getDataType(type))) |
44 | 120 | { |
45 | 120 | } |
46 | | |
47 | | //! Create a new simple layer descriptor. |
48 | | /*! |
49 | | \param dataset |
50 | | The BAG Dataset this layer will belong to. |
51 | | \param type |
52 | | The layer type. |
53 | | \param chunkSize |
54 | | The chunk size the HDF5 DataSet will use. |
55 | | \param compressionLevel |
56 | | The compression level the HDF5 DataSet will use. |
57 | | |
58 | | \return |
59 | | The new simple layer descriptor. |
60 | | */ |
61 | | std::shared_ptr<SimpleLayerDescriptor> SimpleLayerDescriptor::create( |
62 | | const Dataset& dataset, |
63 | | LayerType type, |
64 | | uint32_t rows, uint32_t cols, |
65 | | uint64_t chunkSize, |
66 | | int compressionLevel) |
67 | 0 | { |
68 | 0 | return std::shared_ptr<SimpleLayerDescriptor>( |
69 | 0 | new SimpleLayerDescriptor{dataset.getNextId(), type, rows, cols, chunkSize, |
70 | 0 | compressionLevel}); |
71 | 0 | } |
72 | | |
73 | | //! Open an existing simple layer descriptor. |
74 | | /*! |
75 | | \param dataset |
76 | | The BAG Dataset this layer will belong to. |
77 | | \param type |
78 | | The layer type. |
79 | | |
80 | | \return |
81 | | The simple layer descriptor. |
82 | | */ |
83 | | std::shared_ptr<SimpleLayerDescriptor> SimpleLayerDescriptor::open( |
84 | | const Dataset& dataset, |
85 | | LayerType type, uint32_t rows, uint32_t cols) |
86 | 120 | { |
87 | 120 | return std::shared_ptr<SimpleLayerDescriptor>( |
88 | 120 | new SimpleLayerDescriptor{dataset, type, rows, cols}); |
89 | 120 | } |
90 | | |
91 | | |
92 | | //! \copydoc LayerDescriptor::getDataType |
93 | | DataType SimpleLayerDescriptor::getDataTypeProxy() const noexcept |
94 | 36 | { |
95 | 36 | return Layer::getDataType(this->getLayerType()); |
96 | 36 | } |
97 | | |
98 | | //! \copydoc LayerDescriptor::getElementSize |
99 | | uint8_t SimpleLayerDescriptor::getElementSizeProxy() const noexcept |
100 | 36 | { |
101 | 36 | return m_elementSize; |
102 | 36 | } |
103 | | |
104 | | } // namespace BAG |
105 | | |