cleanup: move dive_table from dive.h to divelist.h

This allows us to decouple dive.h and divelist.h, a small step in
include disentangling.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-05-01 13:43:52 +02:00 committed by Dirk Hohndel
parent c13040798c
commit 95284c026e
34 changed files with 54 additions and 23 deletions

View file

@ -3,6 +3,7 @@
#include <QDir> #include <QDir>
#include <QtConcurrent> #include <QtConcurrent>
#include "core/membuffer.h" #include "core/membuffer.h"
#include "core/dive.h"
#include "core/divesite.h" #include "core/divesite.h"
#include "core/gettextfromc.h" #include "core/gettextfromc.h"
#include "core/tag.h" #include "core/tag.h"

View file

@ -6,6 +6,7 @@
#include "core/divesite.h" #include "core/divesite.h"
#include "core/trip.h" #include "core/trip.h"
#include "core/dive.h"
#include <QUndoCommand> #include <QUndoCommand>
#include <QCoreApplication> // For Q_DECLARE_TR_FUNCTIONS #include <QCoreApplication> // For Q_DECLARE_TR_FUNCTIONS

View file

@ -16,6 +16,7 @@
#include "device.h" #include "device.h"
#include "file.h" #include "file.h"
#include "divesite.h" #include "divesite.h"
#include "dive.h"
#include "errorhelper.h" #include "errorhelper.h"
#include "ssrf.h" #include "ssrf.h"
#include "tag.h" #include "tag.h"

View file

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <limits.h> #include <limits.h>
#include "dive.h"
#include "gettext.h" #include "gettext.h"
#include "subsurface-string.h" #include "subsurface-string.h"
#include "libdivecomputer.h" #include "libdivecomputer.h"
@ -3921,13 +3922,6 @@ struct dive *get_dive(int nr)
return dive_table.dives[nr]; return dive_table.dives[nr];
} }
struct dive *get_dive_from_table(int nr, const struct dive_table *dt)
{
if (nr >= dt->nr || nr < 0)
return NULL;
return dt->dives[nr];
}
struct dive_site *get_dive_site_for_dive(const struct dive *dive) struct dive_site *get_dive_site_for_dive(const struct dive *dive)
{ {
return dive->dive_site; return dive->dive_site;

View file

@ -128,16 +128,10 @@ struct divecomputer {
struct divecomputer *next; struct divecomputer *next;
}; };
typedef struct dive_table {
int nr, allocated;
struct dive **dives;
} dive_table_t;
static const dive_table_t empty_dive_table = { 0, 0, (struct dive **)0 };
struct picture; struct picture;
struct dive_site; struct dive_site;
struct dive_site_table; struct dive_site_table;
struct dive_table;
struct dive_trip; struct dive_trip;
struct trip_table; struct trip_table;
struct full_text_cache; struct full_text_cache;
@ -248,7 +242,6 @@ extern int quit, force_root, ignore_bt;
extern char *testqml; extern char *testqml;
#endif #endif
extern struct dive_table dive_table;
extern struct dive displayed_dive; extern struct dive displayed_dive;
extern unsigned int dc_number; extern unsigned int dc_number;
extern struct dive *current_dive; extern struct dive *current_dive;

View file

@ -1,11 +1,12 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
/* divelist.c */ /* divelist.c */
#include "divelist.h"
#include "subsurface-string.h" #include "subsurface-string.h"
#include "deco.h" #include "deco.h"
#include "device.h" #include "device.h"
#include "divesite.h" #include "divesite.h"
#include "divelist.h" #include "dive.h"
#include "fulltext.h" #include "fulltext.h"
#include "planner.h" #include "planner.h"
#include "qthelper.h" #include "qthelper.h"
@ -745,6 +746,13 @@ void delete_dive_from_table(struct dive_table *table, int idx)
remove_from_dive_table(table, idx); remove_from_dive_table(table, idx);
} }
struct dive *get_dive_from_table(int nr, const struct dive_table *dt)
{
if (nr >= dt->nr || nr < 0)
return NULL;
return dt->dives[nr];
}
/* This removes a dive from the global dive table but doesn't free the /* This removes a dive from the global dive table but doesn't free the
* resources associated with the dive. The caller must removed the dive * resources associated with the dive. The caller must removed the dive
* from the trip-list. Returns a pointer to the unregistered dive. * from the trip-list. Returns a pointer to the unregistered dive.

View file

@ -2,15 +2,25 @@
#ifndef DIVELIST_H #ifndef DIVELIST_H
#define DIVELIST_H #define DIVELIST_H
#include "dive.h" #include "units.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
struct dive;
struct trip_table;
struct dive_site_table;
struct deco_state; struct deco_state;
extern int shown_dives; extern int shown_dives;
struct dive_table {
int nr, allocated;
struct dive **dives;
};
static const struct dive_table empty_dive_table = { 0, 0, (struct dive **)0 };
extern struct dive_table dive_table;
/* this is used for both git and xml format */ /* this is used for both git and xml format */
#define DATAFORMAT_VERSION 3 #define DATAFORMAT_VERSION 3

View file

@ -4,7 +4,7 @@
#include "units.h" #include "units.h"
#include "taxonomy.h" #include "taxonomy.h"
#include "dive.h" #include "divelist.h"
#include <stdlib.h> #include <stdlib.h>
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -3,6 +3,7 @@
#define FILE_H #define FILE_H
#include <sys/stat.h> #include <sys/stat.h>
#include <stdio.h>
struct memblock { struct memblock {
void *buffer; void *buffer;

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "core/gpslocation.h" #include "core/gpslocation.h"
#include "core/divesite.h" #include "core/divesite.h"
#include "core/dive.h"
#include "qt-models/gpslistmodel.h" #include "qt-models/gpslistmodel.h"
#include "core/pref.h" #include "core/pref.h"
#include "core/qthelper.h" #include "core/qthelper.h"

View file

@ -17,7 +17,7 @@
#include "divesite.h" #include "divesite.h"
#include "subsurface-string.h" #include "subsurface-string.h"
#include "device.h" #include "device.h"
#include "divelist.h" #include "dive.h"
#include "display.h" #include "display.h"
#include "errorhelper.h" #include "errorhelper.h"
#include "sha1.h" #include "sha1.h"

View file

@ -3,7 +3,7 @@
#include "ssrf.h" #include "ssrf.h"
#include "divesite.h" #include "divesite.h"
#include "divelist.h" #include "dive.h"
#include "file.h" #include "file.h"
#include "strndup.h" #include "strndup.h"

View file

@ -15,6 +15,7 @@
#include "gettext.h" #include "gettext.h"
#include "dive.h"
#include "divesite.h" #include "divesite.h"
#include "errorhelper.h" #include "errorhelper.h"
#include "trip.h" #include "trip.h"

View file

@ -7,7 +7,7 @@
#include "ssrf.h" #include "ssrf.h"
#include "subsurface-string.h" #include "subsurface-string.h"
#include "gettext.h" #include "gettext.h"
#include "divelist.h" #include "dive.h"
#include "file.h" #include "file.h"
#include "libdivecomputer.h" #include "libdivecomputer.h"

View file

@ -4,6 +4,8 @@
#define MAX_EVENT_NAME 128 #define MAX_EVENT_NAME 128
#include "dive.h" // for struct event!
#include <sqlite3.h> #include <sqlite3.h>
typedef union { typedef union {

View file

@ -10,7 +10,8 @@
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include "ssrf.h" #include "ssrf.h"
#include "divelist.h" #include "dive.h"
#include "divelist.h" // for init_decompression()
#include "subsurface-string.h" #include "subsurface-string.h"
#include "deco.h" #include "deco.h"
#include "errorhelper.h" #include "errorhelper.h"

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "qthelper.h" #include "qthelper.h"
#include "dive.h"
#include "core/settings/qPrefLanguage.h" #include "core/settings/qPrefLanguage.h"
#include "core/settings/qPrefUpdateManager.h" #include "core/settings/qPrefUpdateManager.h"
#include "subsurface-string.h" #include "subsurface-string.h"

View file

@ -17,6 +17,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <git2.h> #include <git2.h>
#include "dive.h"
#include "divesite.h" #include "divesite.h"
#include "subsurface-string.h" #include "subsurface-string.h"
#include "trip.h" #include "trip.h"

View file

@ -5,6 +5,7 @@
#endif #endif
#include "save-html.h" #include "save-html.h"
#include "dive.h"
#include "qthelper.h" #include "qthelper.h"
#include "gettext.h" #include "gettext.h"
#include "divesite.h" #include "divesite.h"

View file

@ -13,6 +13,7 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include "dive.h"
#include "divesite.h" #include "divesite.h"
#include "errorhelper.h" #include "errorhelper.h"
#include "subsurface-string.h" #include "subsurface-string.h"

View file

@ -4,6 +4,7 @@
#include <QDateTime> #include <QDateTime>
#include <QTextDocument> #include <QTextDocument>
#include "core/dive.h"
#include "core/qthelper.h" #include "core/qthelper.h"
#include "core/divesite.h" #include "core/divesite.h"
#include "core/trip.h" #include "core/trip.h"

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "trip.h" #include "trip.h"
#include "dive.h"
#include "subsurface-string.h" #include "subsurface-string.h"
#include "selection.h" #include "selection.h"
#include "table.h" #include "table.h"

View file

@ -9,6 +9,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "dive.h"
#include "membuffer.h" #include "membuffer.h"
#include "divesite.h" #include "divesite.h"
#include "errorhelper.h" #include "errorhelper.h"

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "desktop-widgets/importgps.h" #include "desktop-widgets/importgps.h"
#include "core/dive.h" // for utc_mkdate()
/* Import dive coordinates from a GPS device and synchronise them with the dive profile information /* Import dive coordinates from a GPS device and synchronise them with the dive profile information
of a dive computer. This file contains the infrastructure to: of a dive computer. This file contains the infrastructure to:
@ -152,4 +153,3 @@ void ImportGPS::timeZoneEditChanged()
getCoordsFromGPXFile(&coords, fileName); getCoordsFromGPXFile(&coords, fileName);
updateUI(); updateUI();
} }

View file

@ -4,6 +4,7 @@
#include <list> #include <list>
#include "templatelayout.h" #include "templatelayout.h"
#include "core/divelist.h"
#include "core/selection.h" #include "core/selection.h"
QList<QString> grantlee_templates, grantlee_statistics_templates; QList<QString> grantlee_templates, grantlee_statistics_templates;

View file

@ -2,6 +2,7 @@
#include "qt-models/divepicturemodel.h" #include "qt-models/divepicturemodel.h"
#include "core/metrics.h" #include "core/metrics.h"
#include "core/divelist.h" // for mark_divelist_changed() #include "core/divelist.h" // for mark_divelist_changed()
#include "core/dive.h"
#include "core/imagedownloader.h" #include "core/imagedownloader.h"
#include "core/picture.h" #include "core/picture.h"
#include "core/qthelper.h" #include "core/qthelper.h"

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "diveplannermodel.h" #include "diveplannermodel.h"
#include "core/divelist.h"
#include "core/subsurface-string.h" #include "core/subsurface-string.h"
#include "qt-models/cylindermodel.h" #include "qt-models/cylindermodel.h"
#include "core/planner.h" #include "core/planner.h"

View file

@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "core/dive.h" #include "core/dive.h"
#include "core/divelist.h"
#include "smrtk2ssrfc_window.h" #include "smrtk2ssrfc_window.h"
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>

View file

@ -6,6 +6,7 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include "core/dive.h"
#include "core/color.h" #include "core/color.h"
#include "core/downloadfromdcthread.h" #include "core/downloadfromdcthread.h"
#include "core/qt-gui.h" #include "core/qt-gui.h"

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testAirPressure.h" #include "testAirPressure.h"
#include "core/dive.h"
#include "core/divesite.h" #include "core/divesite.h"
#include "core/trip.h" #include "core/trip.h"
#include "core/file.h" #include "core/file.h"

View file

@ -2,6 +2,7 @@
#include "testgitstorage.h" #include "testgitstorage.h"
#include "git2.h" #include "git2.h"
#include "core/dive.h"
#include "core/divesite.h" #include "core/divesite.h"
#include "core/file.h" #include "core/file.h"
#include "core/qthelper.h" #include "core/qthelper.h"

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testmerge.h" #include "testmerge.h"
#include "core/dive.h" // for save_dives()
#include "core/divesite.h" #include "core/divesite.h"
#include "core/file.h" #include "core/file.h"
#include "core/trip.h" #include "core/trip.h"

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testpicture.h" #include "testpicture.h"
#include "core/dive.h"
#include "core/divesite.h" #include "core/divesite.h"
#include "core/errorhelper.h" #include "core/errorhelper.h"
#include "core/picture.h" #include "core/picture.h"

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testrenumber.h" #include "testrenumber.h"
#include "core/dive.h"
#include "core/divesite.h" #include "core/divesite.h"
#include "core/trip.h" #include "core/trip.h"
#include "core/file.h" #include "core/file.h"