ocarina/include/library.h

131 lines
2.5 KiB
C++

/*
* Copyright 2013 (c) Anna Schumaker.
*/
#ifndef OCARINA_LIBRARY_H
#define OCARINA_LIBRARY_H
#include <database.h>
#include <string>
#include <taglib/tag.h>
#include <taglib/fileref.h>
struct ImportData;
namespace library
{
enum DB_Type {
DB_ALBUM,
DB_ARTIST,
DB_GENRE,
DB_LIBRARY,
DB_TRACK,
};
class AGInfo : public DatabaseEntry {
public:
DB_Type db_type;
std :: string name;
std :: string key_lower;
AGInfo();
AGInfo(DB_Type, TagLib :: Tag *);
AGInfo(DB_Type, const std::string &);
const std::string primary_key();
void read(File &);
void write(File &);
};
class Album : public DatabaseEntry {
public:
std :: string name;
std :: string name_lower;
unsigned int year;
unsigned int artist_id;
Album();
Album(TagLib :: Tag *, unsigned int);
Album(const std::string &, unsigned int, unsigned int);
const std::string primary_key();
void read(File &);
void write(File &);
};
class Library : public DatabaseEntry {
public:
std::string root_path;
unsigned int size;
bool enabled;
Library();
Library(const std::string &, bool);
const std::string primary_key();
void read(File &);
void write(File &);
};
class Track : public DatabaseEntry {
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;
std :: string title;
std :: string title_lower;
std :: string length_str;
std :: string filepath;
std :: string full_path;
Track();
Track(TagLib :: Tag *, TagLib :: AudioProperties *,
unsigned int, unsigned int, unsigned int,
unsigned int, const std :: string &);
Track(ImportData *, unsigned int, unsigned int,
unsigned int, unsigned int);
const std::string primary_key();
void read(File &);
void write(File &);
};
struct Song {
unsigned int track_id;
library :: Album *album;
library :: AGInfo *artist;
library :: AGInfo *genre;
library :: Library *library;
library :: Track *track;
};
void init();
void add_path(const std::string &);
void del_path(unsigned int);
void update_path(unsigned int);
void update_all();
void set_enabled(unsigned int, bool);
void lookup(unsigned int, library :: Song *);
Library *lookup_path(unsigned int);
void import();
void track_played(unsigned int);
#ifdef CONFIG_TEST
void print_db(DB_Type);
void reset();
#endif /* CONFIG_TEST */
};
#endif /* OCARINA_LIBRARY_H */