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