/src/bag/api/bag_descriptor.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef BAG_DESCRIPTOR_H |
2 | | #define BAG_DESCRIPTOR_H |
3 | | |
4 | | #include "bag_config.h" |
5 | | #include "bag_fordec.h" |
6 | | #include "bag_layerdescriptor.h" |
7 | | #include "bag_types.h" |
8 | | |
9 | | #include <exception> |
10 | | #include <memory> |
11 | | #include <vector> |
12 | | |
13 | | |
14 | | namespace BAG { |
15 | | |
16 | | #ifdef _MSC_VER |
17 | | #pragma warning(push) |
18 | | #pragma warning(disable: 4251) // std classes do not have DLL-interface when exporting |
19 | | #endif |
20 | | |
21 | | //! Describe a BAG. |
22 | | class BAG_API Descriptor final |
23 | | { |
24 | | public: |
25 | 332 | Descriptor() = default; |
26 | | explicit Descriptor(const Metadata& metadata); |
27 | | |
28 | | Descriptor(const Descriptor&) = delete; |
29 | | Descriptor(Descriptor&&) = delete; |
30 | | |
31 | | Descriptor& operator=(const Descriptor&) = delete; |
32 | 242 | Descriptor& operator=(Descriptor&&) = default; |
33 | | |
34 | 0 | bool operator==(const Descriptor &rhs) const noexcept { |
35 | 0 | return m_version == rhs.m_version && |
36 | 0 | m_isReadOnly == rhs.m_isReadOnly && |
37 | 0 | layerDescriptorsEqual(rhs.m_layerDescriptors) && |
38 | 0 | m_horizontalReferenceSystem == rhs.m_horizontalReferenceSystem && |
39 | 0 | m_verticalReferenceSystem == rhs.m_verticalReferenceSystem && |
40 | 0 | m_dims == rhs.m_dims && |
41 | 0 | m_projectedCover == rhs.m_projectedCover && |
42 | 0 | m_origin == rhs.m_origin && |
43 | 0 | m_gridSpacing == rhs.m_gridSpacing; |
44 | 0 | } |
45 | | |
46 | 0 | bool operator!=(const Descriptor &rhs) const noexcept { |
47 | 0 | return !(rhs == *this); |
48 | 0 | } |
49 | | |
50 | | std::vector<LayerType> getLayerTypes() const; |
51 | | bool isReadOnly() const noexcept; |
52 | | std::vector<uint32_t> getLayerIds() const noexcept; |
53 | | const std::vector<std::weak_ptr<const LayerDescriptor>>& |
54 | | getLayerDescriptors() const & noexcept; |
55 | | const LayerDescriptor& getLayerDescriptor(uint32_t id) const &; |
56 | | const LayerDescriptor* getLayerDescriptor(LayerType type, |
57 | | const std::string& name) const &; |
58 | | const std::string& getVersion() const & noexcept; |
59 | | const std::string& getHorizontalReferenceSystem() const & noexcept; |
60 | | const std::string& getVerticalReferenceSystem() const & noexcept; |
61 | | const std::tuple<uint32_t, uint32_t>& getDims() const & noexcept; |
62 | | const std::tuple<double, double, double, double>& |
63 | | getProjectedCover() const & noexcept; |
64 | | const std::tuple<double, double>& getOrigin() const & noexcept; |
65 | | const std::tuple<double, double>& getGridSpacing() const & noexcept; |
66 | | |
67 | | Descriptor& setVerticalReferenceSystem( |
68 | | const std::string& verticalReferenceSystem) & noexcept; |
69 | | Descriptor& setDims(uint32_t rows, uint32_t columns) & noexcept; |
70 | | Descriptor& setProjectedCover(double llX, double llY, double urX, |
71 | | double urY) & noexcept; |
72 | | Descriptor& setOrigin(double llX, double llY) & noexcept; |
73 | | Descriptor& setGridSpacing(double xSpacing, double ySpacing) & noexcept; |
74 | | Descriptor& setHorizontalReferenceSystem( |
75 | | const std::string& horizontalReferenceSystem) & noexcept; |
76 | | Descriptor& setReadOnly(bool readOnly) & noexcept; |
77 | | Descriptor& setVersion(std::string inVersion) & noexcept; |
78 | | |
79 | | private: |
80 | | Descriptor& addLayerDescriptor(const LayerDescriptor& inDescriptor) &; |
81 | | |
82 | | //! The version of the BAG. |
83 | | std::string m_version; |
84 | | //! True if the BAG is read only. |
85 | | bool m_isReadOnly = true; |
86 | | //! The layer descriptors (owned by each Layer). |
87 | | std::vector<std::weak_ptr<const LayerDescriptor>> m_layerDescriptors; |
88 | | //! The name of the horizontal reference system. |
89 | | std::string m_horizontalReferenceSystem; |
90 | | //! The name of the vertical reference system. |
91 | | std::string m_verticalReferenceSystem; |
92 | | //! The dimensions of the bag. |
93 | | std::tuple<uint32_t, uint32_t> m_dims{}; |
94 | | //! The projected cover of the bag. |
95 | | std::tuple<double, double, double, double> m_projectedCover{}; |
96 | | //! The origin of the bag. |
97 | | std::tuple<double, double> m_origin{}; |
98 | | //! The grid spacing of the bag. |
99 | | std::tuple<double, double> m_gridSpacing{}; |
100 | | |
101 | 0 | bool layerDescriptorsEqual(std::vector<std::weak_ptr<const LayerDescriptor>> other) const { |
102 | 0 | auto size = m_layerDescriptors.size(); |
103 | 0 | bool areEqual = size == other.size(); |
104 | 0 | if (!areEqual) return areEqual; |
105 | 0 |
|
106 | 0 | for (size_t i = 0; i < size; i++) { |
107 | 0 | if (!weak_ptr_equals(m_layerDescriptors[i], other[i])) return false; |
108 | 0 | } |
109 | 0 |
|
110 | 0 | return areEqual; |
111 | 0 | } |
112 | | |
113 | | friend Dataset; |
114 | | }; |
115 | | |
116 | | #ifdef _MSC_VER |
117 | | #pragma warning(pop) |
118 | | #endif |
119 | | |
120 | | } // namespace BAG |
121 | | |
122 | | #endif // BAG_DESCRIPTOR_H |
123 | | |