mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
408b31b6ce
Makes the code much nicer to read. Default initialize cylinder_t to the empty cylinder. This produces lots of warnings, because most structure are now not PODs anymore and shouldn't be erased using memset(). These memset()s will be removed one-by-one and replaced by proper constructors. The whole ordeal made it necessary to add a constructor to struct event. To simplify things the whole optimization of the variable-size event names was removed. In upcoming commits this will be replaced by std::string anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
47 lines
1.7 KiB
C
47 lines
1.7 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef PICTURE_H
|
|
#define PICTURE_H
|
|
|
|
// picture (more precisely media) related strutures and functions
|
|
#include "units.h"
|
|
#include <stddef.h> // For NULL
|
|
|
|
struct dive;
|
|
|
|
struct picture {
|
|
char *filename = nullptr;
|
|
offset_t offset;
|
|
location_t location;
|
|
};
|
|
|
|
/* loop through all pictures of a dive */
|
|
#define FOR_EACH_PICTURE(_dive) \
|
|
if ((_dive) && (_dive)->pictures.nr) \
|
|
for (struct picture *picture = (_dive)->pictures.pictures; \
|
|
picture < (_dive)->pictures.pictures + (_dive)->pictures.nr; \
|
|
picture++)
|
|
|
|
/* Table of pictures. Attention: this stores pictures,
|
|
* *not* pointers to pictures. This has two crucial consequences:
|
|
* 1) Pointers to pictures are not stable. They may be
|
|
* invalidated if the table is reallocated.
|
|
* 2) add_to_picture_table(), etc. take ownership of the
|
|
* picture. Notably of the filename. */
|
|
struct picture_table {
|
|
int nr, allocated;
|
|
struct picture *pictures;
|
|
};
|
|
|
|
/* picture table functions */
|
|
extern void clear_picture_table(struct picture_table *);
|
|
extern void add_to_picture_table(struct picture_table *, int idx, struct picture pic);
|
|
extern void copy_pictures(const struct picture_table *s, struct picture_table *d);
|
|
extern void add_picture(struct picture_table *, struct picture newpic);
|
|
extern void remove_from_picture_table(struct picture_table *, int idx);
|
|
extern int get_picture_idx(const struct picture_table *, const char *filename); /* Return -1 if not found */
|
|
extern void sort_picture_table(struct picture_table *);
|
|
|
|
extern struct picture *create_picture(const char *filename, timestamp_t shift_time, bool match_all, struct dive **dive);
|
|
extern bool picture_check_valid_time(timestamp_t timestamp, timestamp_t shift_time);
|
|
|
|
#endif // PICTURE_H
|