/src/bag/api/bag_interleavedlegacylayerdescriptor.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | |
2 | | #include "bag_exceptions.h" |
3 | | #include "bag_interleavedlegacylayer.h" |
4 | | #include "bag_interleavedlegacylayerdescriptor.h" |
5 | | #include "bag_private.h" |
6 | | |
7 | | |
8 | | namespace BAG { |
9 | | |
10 | | //! The constructor. |
11 | | /*! |
12 | | \param id |
13 | | The unique layer id. |
14 | | \param layerType |
15 | | The type of layer to be read. |
16 | | \param groupType |
17 | | The type of group to be read. |
18 | | NODE or ELEVATION. |
19 | | */ |
20 | | InterleavedLegacyLayerDescriptor::InterleavedLegacyLayerDescriptor( |
21 | | uint32_t id, |
22 | | LayerType layerType, |
23 | | GroupType groupType) |
24 | 0 | : LayerDescriptor(id, Layer::getInternalPath(layerType), |
25 | 0 | kLayerTypeMapString.at(layerType), layerType, 0, 0) |
26 | 0 | , m_groupType(groupType) |
27 | 0 | , m_elementSize(Layer::getElementSize(Layer::getDataType(layerType))) |
28 | 0 | { |
29 | 0 | this->setInternalPath(groupType == NODE ? |
30 | 0 | NODE_GROUP_PATH : ELEVATION_SOLUTION_GROUP_PATH); |
31 | |
|
32 | 0 | InterleavedLegacyLayerDescriptor::validateTypes(layerType, groupType); |
33 | 0 | } |
34 | | |
35 | | //! The constructor. |
36 | | /*! |
37 | | \param dataset |
38 | | The BAG Dataset this layer belongs to. |
39 | | \param layerType |
40 | | The type of layer to be read. |
41 | | \param groupType |
42 | | The type of group to be read. |
43 | | NODE or ELEVATION. |
44 | | */ |
45 | | InterleavedLegacyLayerDescriptor::InterleavedLegacyLayerDescriptor( |
46 | | const Dataset& dataset, |
47 | | LayerType layerType, |
48 | | GroupType groupType) |
49 | 0 | : LayerDescriptor(dataset, layerType, |
50 | 0 | groupType == NODE |
51 | 0 | ? NODE_GROUP_PATH |
52 | 0 | : groupType == ELEVATION |
53 | 0 | ? ELEVATION_SOLUTION_GROUP_PATH |
54 | 0 | : "") |
55 | 0 | , m_groupType(groupType) |
56 | 0 | , m_elementSize(Layer::getElementSize(Layer::getDataType(layerType))) |
57 | 0 | { |
58 | 0 | InterleavedLegacyLayerDescriptor::validateTypes(layerType, groupType); |
59 | 0 | } |
60 | | |
61 | | //! Create an interleaved layer descriptor. |
62 | | /*! |
63 | | \param dataset |
64 | | The BAG Dataset this layer belongs to. |
65 | | \param layerType |
66 | | The type of layer to be read. |
67 | | \param groupType |
68 | | The type of group to be read. |
69 | | NODE or ELEVATION. |
70 | | |
71 | | \return |
72 | | The newly created interleaved layer descriptor. |
73 | | */ |
74 | | std::shared_ptr<InterleavedLegacyLayerDescriptor> InterleavedLegacyLayerDescriptor::create( |
75 | | const Dataset& dataset, |
76 | | LayerType layerType, |
77 | | GroupType groupType) |
78 | 0 | { |
79 | 0 | return std::shared_ptr<InterleavedLegacyLayerDescriptor>( |
80 | 0 | new InterleavedLegacyLayerDescriptor{dataset.getNextId(), layerType, |
81 | 0 | groupType}); |
82 | 0 | } |
83 | | |
84 | | //! Open an interleaved layer descriptor. |
85 | | /*! |
86 | | \param dataset |
87 | | The BAG Dataset this layer belongs to. |
88 | | \param layerType |
89 | | The type of layer to be read. |
90 | | \param groupType |
91 | | The type of group to be read. |
92 | | NODE or ELEVATION. |
93 | | |
94 | | \return |
95 | | The newly opened interleaved layer descriptor. |
96 | | */ |
97 | | std::shared_ptr<InterleavedLegacyLayerDescriptor> InterleavedLegacyLayerDescriptor::open( |
98 | | const Dataset& dataset, |
99 | | LayerType layerType, |
100 | | GroupType groupType) |
101 | 0 | { |
102 | 0 | return std::shared_ptr<InterleavedLegacyLayerDescriptor>( |
103 | 0 | new InterleavedLegacyLayerDescriptor{dataset, layerType, groupType}); |
104 | 0 | } |
105 | | |
106 | | |
107 | | //! \copydoc LayerDescriptor::getDataType |
108 | | DataType InterleavedLegacyLayerDescriptor::getDataTypeProxy() const noexcept |
109 | 0 | { |
110 | 0 | return Layer::getDataType(this->getLayerType()); |
111 | 0 | } |
112 | | |
113 | | //! \copydoc LayerDescriptor::getElementSize |
114 | | uint8_t InterleavedLegacyLayerDescriptor::getElementSizeProxy() const noexcept |
115 | 0 | { |
116 | 0 | return m_elementSize; |
117 | 0 | } |
118 | | |
119 | | //! Return the group type of this layer. |
120 | | /*! |
121 | | \return |
122 | | The group type of this layer. |
123 | | */ |
124 | | GroupType InterleavedLegacyLayerDescriptor::getGroupType() const noexcept |
125 | 0 | { |
126 | 0 | return m_groupType; |
127 | 0 | } |
128 | | |
129 | | //! Verify the proper group and layer combination is given. |
130 | | /*! |
131 | | Validate the specified layer type is allowed for the group type. If the |
132 | | layer type is not valid for the specified group, an exception of type |
133 | | UnsupportedInterleavedLayer is thrown. |
134 | | |
135 | | \param layerType |
136 | | The type of layer to be read. |
137 | | \param groupType |
138 | | The type of group to be read. |
139 | | NODE or ELEVATION. |
140 | | */ |
141 | | void InterleavedLegacyLayerDescriptor::validateTypes( |
142 | | LayerType layerType, |
143 | | GroupType groupType) |
144 | 0 | { |
145 | 0 | if (groupType == ELEVATION) |
146 | 0 | { |
147 | 0 | if (layerType != Shoal_Elevation && layerType != Std_Dev && |
148 | 0 | layerType != Num_Soundings) |
149 | 0 | throw UnsupportedInterleavedLayer{}; |
150 | 0 | } |
151 | 0 | else if (groupType == NODE) |
152 | 0 | { |
153 | 0 | if (layerType != Hypothesis_Strength && layerType != Num_Hypotheses) |
154 | 0 | throw UnsupportedInterleavedLayer{}; |
155 | 0 | } |
156 | 0 | else |
157 | 0 | throw UnsupportedInterleavedLayer{}; |
158 | 0 | } |
159 | | |
160 | | } // namespace BAG |
161 | | |