mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
d242198c99
Since everything is C++ now, we can use unique_ptr<>s. This makes the code significantly shorter, because we can now use the default move constructor and assignment operators. This has a semantic change when std::move()-ing the divelog: now not the contents of the tables are moved, but the pointers. That is, the moved-from object now has no more tables and must not be used anymore. This made it necessary to replace std::move()s by std::swap()s. In that regard, the old code was in principle broken: it used moved-from objects, which may work but usually doesn't. This commit adds a myriad of .get() function calls where the code expects a C-style pointer. The plan is to remove virtually all of them, when we move free-standing functions into the class it acts on. Or, replace C-style pointers by references where we don't support NULL. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
33 lines
776 B
C++
33 lines
776 B
C++
// SPDX-License-Identifier: GPL-2.0
|
|
// A structure that contains all the data we store in a divelog files
|
|
#ifndef DIVELOG_H
|
|
#define DIVELOG_H
|
|
|
|
#include <memory>
|
|
|
|
struct dive_table;
|
|
struct trip_table;
|
|
class dive_site_table;
|
|
struct device_table;
|
|
struct filter_preset_table;
|
|
|
|
struct divelog {
|
|
std::unique_ptr<dive_table> dives;
|
|
std::unique_ptr<trip_table> trips;
|
|
std::unique_ptr<dive_site_table> sites;
|
|
std::unique_ptr<device_table> devices;
|
|
std::unique_ptr<filter_preset_table> filter_presets;
|
|
bool autogroup;
|
|
|
|
divelog();
|
|
~divelog();
|
|
divelog(divelog &&); // move constructor (argument is consumed).
|
|
divelog &operator=(divelog &&); // move assignment (argument is consumed).
|
|
|
|
void delete_single_dive(int idx);
|
|
void clear();
|
|
};
|
|
|
|
extern struct divelog divelog;
|
|
|
|
#endif
|