ocarina/include/core/tags/genre.h
Anna Schumaker c2178bc265 core: Cut back on hardcoded dbe_index uses
The dbe_index of a given database item might change in the future, so we
can't rely on it everywhere.  Let's just use it for saving and loading
files, with the expectation that changes will happen sometime after
startup.

Implements #69: Reduce use of dbe_index in Ocarina code
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-11 10:50:45 -04:00

56 lines
1.4 KiB
C

/*
* Copyright 2014 (c) Anna Schumaker.
*
* The Genre tag is used to store the name of genres
* added to the tag database.
*
* When writing a Genre tag to disk, nol ywrite out the
* genre_name field:
*
* ... Video Game Music
* ... Game Music
*/
#ifndef OCARINA_CORE_TAGS_GENRE_H
#define OCARINA_CORE_TAGS_GENRE_H
#include <core/database.h>
struct genre {
gchar *ge_name; /* This genre's name. */
gchar **ge_tokens; /* This genre's tokenized strings. */
gchar **ge_alts; /* This genre's alternate ascii tokens. */
struct db_entry ge_dbe;
};
#define GENRE(dbe) ((struct genre *)DBE_DATA(dbe))
/* Called to initialize the genre database. */
void genre_db_init();
/* Called to clean up the genre database. */
void genre_db_deinit();
/* Called to find a genre tag by name. */
struct genre *genre_find(const gchar *);
/* Called to get a genre tag with a specific index. */
struct genre *genre_get(const unsigned int);
/* Called to compare two genre tags. */
int genre_compare(struct genre *, struct genre *);
/* Called to check if a genre has a token that matches the given string. */
bool genre_match_token(struct genre *, const gchar *);
/* Called to find the database index of the genre tag. */
static inline unsigned int genre_index(struct genre *genre)
{
return genre->ge_dbe.dbe_index;
}
#ifdef CONFIG_TESTING
const struct db_ops *test_genre_ops();
#endif /* CONFIG_TESTING */
#endif /* OCARINA_CORE_TAGS_GENRE_H */