2013-10-27 17:25:26 -04:00
|
|
|
/*
|
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#ifndef OCARINA_LIBRARY_H
|
|
|
|
#define OCARINA_LIBRARY_H
|
|
|
|
|
|
|
|
#include <database.h>
|
|
|
|
#include <string>
|
|
|
|
|
2013-11-10 16:57:28 -05:00
|
|
|
#include <taglib/tag.h>
|
2013-11-10 17:37:35 -05:00
|
|
|
#include <taglib/fileref.h>
|
2013-11-10 16:57:28 -05:00
|
|
|
|
2013-10-27 17:25:26 -04:00
|
|
|
namespace library
|
|
|
|
{
|
|
|
|
|
|
|
|
enum DB_Type {
|
|
|
|
DB_ALBUM,
|
|
|
|
DB_ARTIST,
|
|
|
|
DB_GENRE,
|
|
|
|
DB_LIBRARY,
|
|
|
|
DB_TRACK,
|
|
|
|
};
|
|
|
|
|
2013-11-10 16:09:31 -05:00
|
|
|
|
2013-12-31 20:14:52 -05:00
|
|
|
class Artist : public DatabaseEntry {
|
2013-11-10 16:09:31 -05:00
|
|
|
public:
|
2013-12-08 20:52:14 -05:00
|
|
|
std :: string name;
|
2013-11-10 16:09:31 -05:00
|
|
|
|
|
|
|
Artist();
|
2013-11-10 16:57:28 -05:00
|
|
|
Artist(TagLib :: Tag *);
|
2013-11-10 16:09:31 -05:00
|
|
|
void read(File &);
|
|
|
|
void write(File &);
|
|
|
|
#ifdef CONFIG_DEBUG
|
|
|
|
void print();
|
|
|
|
#endif /* CONFIG_DEBUG */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-12-31 20:14:52 -05:00
|
|
|
class Album : public DatabaseEntry {
|
2013-11-10 16:45:52 -05:00
|
|
|
public:
|
2013-12-10 17:38:42 -05:00
|
|
|
std :: string name;
|
2013-11-10 16:45:52 -05:00
|
|
|
unsigned int year;
|
|
|
|
unsigned int artist_id;
|
|
|
|
|
|
|
|
Album();
|
2013-11-10 16:57:28 -05:00
|
|
|
Album(TagLib :: Tag *, unsigned int);
|
2013-11-10 16:45:52 -05:00
|
|
|
void read(File &);
|
|
|
|
void write(File &);
|
|
|
|
#ifdef CONFIG_DEBUG
|
|
|
|
void print();
|
|
|
|
#endif /* CONFIG_DEBUG */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-12-31 20:14:52 -05:00
|
|
|
class Genre : public DatabaseEntry {
|
2013-11-10 16:45:52 -05:00
|
|
|
public:
|
|
|
|
std:: string name;
|
|
|
|
|
|
|
|
Genre();
|
2013-11-10 16:57:28 -05:00
|
|
|
Genre(TagLib :: Tag *);
|
2013-11-10 16:45:52 -05:00
|
|
|
void read(File &);
|
|
|
|
void write(File &);
|
|
|
|
#ifdef CONFIG_DEBUG
|
|
|
|
void print();
|
|
|
|
#endif /* CONFIG_DEBUG */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-12-31 20:14:52 -05:00
|
|
|
class Library : public DatabaseEntry {
|
2013-10-27 17:25:26 -04:00
|
|
|
public:
|
|
|
|
std::string root_path;
|
|
|
|
bool enabled;
|
|
|
|
|
2013-11-03 16:03:01 -05:00
|
|
|
Library();
|
2013-10-27 17:25:26 -04:00
|
|
|
Library(const std::string &, bool);
|
|
|
|
void read(File &);
|
|
|
|
void write(File &);
|
|
|
|
#ifdef CONFIG_DEBUG
|
|
|
|
void print();
|
|
|
|
#endif /* CONFIG_DEBUG */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-12-31 20:14:52 -05:00
|
|
|
class Track : public DatabaseEntry {
|
2013-11-10 17:37:35 -05:00
|
|
|
public:
|
|
|
|
unsigned int library_id;
|
|
|
|
unsigned int artist_id;
|
|
|
|
unsigned int album_id;
|
|
|
|
unsigned int genre_id;
|
|
|
|
|
|
|
|
unsigned int track;
|
|
|
|
unsigned int last_year;
|
|
|
|
unsigned int last_month;
|
|
|
|
unsigned int last_day;
|
|
|
|
unsigned int play_count;
|
|
|
|
unsigned int length;
|
|
|
|
|
|
|
|
bool banned;
|
|
|
|
std :: string title;
|
|
|
|
std :: string length_str;
|
|
|
|
std :: string filepath;
|
|
|
|
|
|
|
|
Track();
|
|
|
|
Track(TagLib :: Tag *, TagLib :: AudioProperties *,
|
|
|
|
unsigned int, unsigned int, unsigned int,
|
|
|
|
unsigned int, const std :: string &);
|
|
|
|
void read(File &);
|
|
|
|
void write(File &);
|
|
|
|
#ifdef CONFIG_DEBUG
|
|
|
|
void print();
|
|
|
|
#endif /* CONFIG_DEBUG */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-11-17 14:41:22 -05:00
|
|
|
struct Song {
|
|
|
|
library :: Album *album;
|
|
|
|
library :: Artist *artist;
|
|
|
|
library :: Genre *genre;
|
|
|
|
library :: Library *library;
|
|
|
|
library :: Track *track;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-11-03 16:03:01 -05:00
|
|
|
void init();
|
2013-10-27 17:25:26 -04:00
|
|
|
bool add_path(const std::string &);
|
|
|
|
void del_path(unsigned int);
|
2013-11-10 16:09:31 -05:00
|
|
|
void update_path(unsigned int);
|
2013-11-17 14:41:22 -05:00
|
|
|
bool lookup(unsigned int, library :: Song *);
|
2013-10-27 17:25:26 -04:00
|
|
|
#ifdef CONFIG_DEBUG
|
|
|
|
void print_db(DB_Type);
|
|
|
|
void reset();
|
|
|
|
#endif /* CONFIG_DEBUG */
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* OCARINA_LIBRARY_H */
|