mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: move add_to_weightsystem_table() to weightsystem_table
Feels natural in a C++ code base. In analogy to other tables, this creates a struct that derives from std::vector<>. This is generally frowned upon, but it works and is the pragmatic thing for now. If someone wants to "fix" that, they may just do it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
498302dcc6
commit
650fda3221
4 changed files with 8 additions and 7 deletions
|
|
@ -312,10 +312,10 @@ void remove_weightsystem(struct dive *dive, int idx)
|
|||
dive->weightsystems.erase(dive->weightsystems.begin() + idx);
|
||||
}
|
||||
|
||||
void add_to_weightsystem_table(weightsystem_table *table, int idx, weightsystem_t ws)
|
||||
void weightsystem_table::add(int idx, weightsystem_t ws)
|
||||
{
|
||||
idx = std::clamp(idx, 0, static_cast<int>(table->size()));
|
||||
table->insert(table->begin() + idx, std::move(ws));
|
||||
idx = std::clamp(idx, 0, static_cast<int>(size()));
|
||||
insert(begin() + idx, std::move(ws));
|
||||
}
|
||||
|
||||
void set_weightsystem(struct dive *dive, int idx, weightsystem_t ws)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,9 @@ struct weightsystem_t
|
|||
* *not* pointers * to weightsystems. Therefore pointers to
|
||||
* weightsystems are *not* stable.
|
||||
*/
|
||||
using weightsystem_table = std::vector<weightsystem_t>;
|
||||
struct weightsystem_table : public std::vector<weightsystem_t> {
|
||||
void add(int idx, weightsystem_t ws);
|
||||
};
|
||||
|
||||
extern enum cylinderuse cylinderuse_from_text(const char *text);
|
||||
extern void copy_cylinder_types(const struct dive *s, struct dive *d);
|
||||
|
|
@ -88,7 +90,6 @@ extern void dump_cylinders(struct dive *dive, bool verbose);
|
|||
#endif
|
||||
|
||||
/* Weightsystem table functions */
|
||||
extern void add_to_weightsystem_table(weightsystem_table *, int idx, weightsystem_t ws);
|
||||
|
||||
/* Cylinder table functions */
|
||||
extern void add_cylinder(struct cylinder_table *, int idx, cylinder_t cyl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue