core/database: Convert DatabaseEntry class into a struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
1c0235c8c7
commit
3eb27debfb
|
@ -4,14 +4,14 @@
|
|||
#include <core/database.h>
|
||||
|
||||
|
||||
DatabaseEntry :: DatabaseEntry()
|
||||
: _index(0)
|
||||
db_entry :: db_entry()
|
||||
: dbe_index(0)
|
||||
{
|
||||
}
|
||||
|
||||
DatabaseEntry :: ~DatabaseEntry() {}
|
||||
db_entry :: ~db_entry() {}
|
||||
|
||||
const unsigned int DatabaseEntry :: index()
|
||||
const unsigned int db_entry :: index()
|
||||
{
|
||||
return _index;
|
||||
return dbe_index;
|
||||
}
|
||||
|
|
|
@ -16,13 +16,12 @@ extern "C" {
|
|||
* The DatabaseEntry class is the base class for storing
|
||||
* generic data inside a Database.
|
||||
*/
|
||||
class DatabaseEntry {
|
||||
public:
|
||||
unsigned int _index; /**< The location of an item in the Database. */
|
||||
struct db_entry {
|
||||
unsigned int dbe_index; /* The db_entry's position in the database. */
|
||||
|
||||
DatabaseEntry(); /**< Initialize _index to 0. */
|
||||
DatabaseEntry(const std::string);
|
||||
virtual ~DatabaseEntry() = 0; /**< Virtual destructor */
|
||||
db_entry(); /**< Initialize _index to 0. */
|
||||
db_entry(const std::string);
|
||||
virtual ~db_entry() = 0; /**< Virtual destructor */
|
||||
|
||||
/**
|
||||
* Called to access a DatabaseEntry's index.
|
||||
|
|
|
@ -71,7 +71,7 @@ void db_load(struct database<T> *db)
|
|||
db->db_entries[i] = NULL;
|
||||
} else {
|
||||
db->db_entries[i] = new T;
|
||||
db->db_entries[i]->_index = i;
|
||||
db->db_entries[i]->dbe_index = i;
|
||||
db->db_entries[i]->read(db->db_file);
|
||||
str = db->db_entries[i]->primary_key();
|
||||
db->db_keys[str] = i;
|
||||
|
@ -88,13 +88,13 @@ T *db_insert(struct database<T> *db, T *item)
|
|||
if (!item)
|
||||
return NULL;
|
||||
|
||||
item->_index = db_actual_size(db);
|
||||
item->dbe_index = db_actual_size(db);
|
||||
db->db_entries.push_back(item);
|
||||
|
||||
db->db_keys[item->primary_key()] = item->index();
|
||||
db->db_size++;
|
||||
db_autosave(db);
|
||||
return db->db_entries[item->_index];
|
||||
return db->db_entries[item->dbe_index];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
|
|
@ -16,7 +16,7 @@ extern "C" {
|
|||
* The index_entry struct is used to associate a specific key with a set of
|
||||
* integer identifiers. This lets us use a Database as an inverted index.
|
||||
*/
|
||||
struct index_entry : public DatabaseEntry {
|
||||
struct index_entry : public db_entry {
|
||||
std::string ie_key;
|
||||
struct set ie_set;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* ... << year2 << GenericTag::write()
|
||||
* ... << year3 << GenericTag::write()
|
||||
*/
|
||||
struct album : public DatabaseEntry {
|
||||
struct album : public db_entry {
|
||||
unsigned int al_year; /* This album's year. */
|
||||
std::string al_name; /* This album's name. */
|
||||
std::string al_lower; /* This album's name (lowercased). */
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* The Artist tag is used to store the name of artists added
|
||||
* to the tag database.
|
||||
*/
|
||||
struct artist : public DatabaseEntry {
|
||||
struct artist : public db_entry {
|
||||
std::string ar_name; /* This artist's name. */
|
||||
std::string ar_lower; /* This artist's name (lowercased). */
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* The Genre tag is used to store the name of genres added
|
||||
* to the tag database.
|
||||
*/
|
||||
struct genre : public DatabaseEntry {
|
||||
struct genre : public db_entry {
|
||||
public:
|
||||
std::string ge_name; /* This genre's name. */
|
||||
std::string ge_lower; /* This genre's name (lowercased). */
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* ... << enabled2 << path2
|
||||
* ... << enabled3 << path3
|
||||
*/
|
||||
struct library : public DatabaseEntry {
|
||||
struct library : public db_entry {
|
||||
unsigned int li_size; /* This library's track count. */
|
||||
bool li_enabled;/* True if this library is enabled. */
|
||||
std::string li_path; /* This library's root path. */
|
||||
|
|
|
@ -18,7 +18,7 @@ extern "C" {
|
|||
* The Track tag is used to store information about tracks that
|
||||
* have been added to the tag database.
|
||||
*/
|
||||
struct track : public DatabaseEntry {
|
||||
struct track : public db_entry {
|
||||
struct album *tr_album; /* This track's associated album. */
|
||||
struct artist *tr_artist; /* This track's associated artist. */
|
||||
struct genre *tr_genre; /* This track's associated genre. */
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
|
||||
/*
|
||||
* Derive a DatabaseEntry for storing integerss
|
||||
* Derive a db_entry for storing integerss
|
||||
*/
|
||||
struct int_entry : public DatabaseEntry {
|
||||
struct int_entry : public db_entry {
|
||||
unsigned int ie_val;
|
||||
|
||||
int_entry() : ie_val(0) {};
|
||||
|
|
Loading…
Reference in New Issue