-
Notifications
You must be signed in to change notification settings - Fork 12
/
bag_vrtrackinglist.h
139 lines (110 loc) · 3.87 KB
/
bag_vrtrackinglist.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef BAG_VRTRACKINGLIST_H
#define BAG_VRTRACKINGLIST_H
#include "bag_config.h"
#include "bag_deleteh5dataset.h"
#include "bag_fordec.h"
#include "bag_types.h"
#include <memory>
#include <vector>
namespace H5 {
class DataSet;
} // namespace H5
namespace BAG {
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // std classes do not have DLL-interface when exporting
#endif
//! The interface for the variable resolution tracking list.
class BAG_API VRTrackingList final
{
public:
using value_type = VRTrackingItem;
using iterator = std::vector<value_type>::iterator;
using const_iterator = std::vector<value_type>::const_iterator;
using reference = value_type&;
using const_reference = const value_type&;
VRTrackingList(const Dataset& dataset, int compressionLevel);
VRTrackingList(const VRTrackingList&) = delete;
VRTrackingList(VRTrackingList&&) = delete;
// Allow std::make_shared() to call our constructor
explicit VRTrackingList(const Dataset& dataset);
VRTrackingList& operator=(const VRTrackingList&) = delete;
VRTrackingList& operator=(VRTrackingList&&) = delete;
bool operator==(const VRTrackingList &rhs) const noexcept {
return m_pH5dataSet == rhs.m_pH5dataSet &&
weak_ptr_equals(m_pBagDataset, rhs.m_pBagDataset) &&
itemsEqual(rhs.m_items);
}
bool operator!=(const VRTrackingList &rhs) const noexcept {
return !(rhs == *this);
}
iterator begin() & noexcept;
const_iterator begin() const & noexcept;
iterator end() & noexcept;
const_iterator end() const & noexcept;
const_iterator cbegin() const & noexcept;
const_iterator cend() const & noexcept;
void clear() noexcept;
void push_back(const value_type& value);
void push_back(value_type&& value);
template <typename... Args>
void emplace_back(Args&&... args) &;
reference front() &;
const_reference front() const &;
reference back() &;
const_reference back() const &;
void reserve(size_t newCapacity);
void resize(size_t count);
value_type* data() & noexcept;
const value_type* data() const & noexcept;
bool empty() const noexcept;
size_t size() const noexcept;
reference operator[](size_t index) & noexcept;
const_reference operator[](size_t index) const & noexcept;
void write() const;
protected:
private:
std::unique_ptr<::H5::DataSet, DeleteH5dataSet> createH5dataSet(
int compressionLevel);
std::unique_ptr<::H5::DataSet, DeleteH5dataSet> openH5dataSet();
//! The associated BAG Dataset.
std::weak_ptr<const Dataset> m_pBagDataset;
//! The items making up the tracking list.
std::vector<value_type> m_items;
//! The HDF5 DataSet this class relates to.
std::unique_ptr<::H5::DataSet, DeleteH5dataSet> m_pH5dataSet;
bool itemsEqual(std::vector<value_type> other) const {
auto size = m_items.size();
bool areEqual = size == other.size();
if (!areEqual) return areEqual;
for (size_t i = 0; i < size; i++) {
auto ours = m_items[i];
auto theirs = other[i];
if (ours.row != theirs.row ||
ours.col != theirs.col ||
ours.depth != theirs.depth ||
ours.uncertainty != theirs.uncertainty ||
ours.track_code != theirs.track_code ||
ours.list_series != theirs.list_series) {
return false;
}
}
return areEqual;
}
friend Dataset;
};
//! Add an item to the end of the tracking list.
/*!
\param args
One or more parameters to hand to the constructor of VRTrackingItem.
*/
template <typename... Args>
void VRTrackingList::emplace_back(Args&&... args) &
{
m_items.emplace_back(std::forward<Args>(args)...);
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
} // namespace BAG
#endif // BAG_VRTRACKINGLIST_H