77616aa8d2
Conflicts: Sconstruct tests/Sconscript
132 lines
2.2 KiB
C++
132 lines
2.2 KiB
C++
/*
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#ifndef OCARINA_CORE_TAGS_H
|
|
#define OCARINA_CORE_TAGS_H
|
|
|
|
#include <core/database.h>
|
|
|
|
|
|
enum sort_t {
|
|
SORT_ARTIST,
|
|
SORT_ALBUM,
|
|
SORT_COUNT,
|
|
SORT_GENRE,
|
|
SORT_LENGTH,
|
|
SORT_PLAYED,
|
|
SORT_TITLE,
|
|
SORT_TRACK,
|
|
SORT_YEAR,
|
|
};
|
|
|
|
|
|
class Artist : public DatabaseEntry {
|
|
public:
|
|
std::string name;
|
|
std::string lower;
|
|
|
|
Artist();
|
|
Artist(const std::string &);
|
|
const std::string primary_key() const;
|
|
void read(File &);
|
|
void write(File &);
|
|
};
|
|
|
|
|
|
class Album : public DatabaseEntry {
|
|
public:
|
|
std::string name;
|
|
std::string lower;
|
|
unsigned int year;
|
|
|
|
Album();
|
|
Album(const std::string &, unsigned int);
|
|
const std::string primary_key() const;
|
|
void read(File &);
|
|
void write(File &);
|
|
};
|
|
|
|
|
|
class Genre : public DatabaseEntry {
|
|
public:
|
|
std::string name;
|
|
std::string lower;
|
|
|
|
Genre();
|
|
Genre(const std::string &);
|
|
const std::string primary_key() const;
|
|
void read(File &);
|
|
void write(File &);
|
|
};
|
|
|
|
|
|
class Library : public DatabaseEntry {
|
|
public:
|
|
std::string root_path;
|
|
unsigned int count;
|
|
bool enabled;
|
|
|
|
Library();
|
|
Library(const std::string &);
|
|
const std::string primary_key() const;
|
|
void read(File &);
|
|
void write(File &);
|
|
};
|
|
|
|
|
|
class Track : public DatabaseEntry {
|
|
private:
|
|
void set_length_str();
|
|
|
|
public:
|
|
Library *library;
|
|
Artist *artist;
|
|
Album *album;
|
|
Genre *genre;
|
|
|
|
unsigned int track;
|
|
unsigned int length;
|
|
unsigned int play_count;
|
|
unsigned int last_year;
|
|
unsigned int last_month;
|
|
unsigned int last_day;
|
|
|
|
std :: string title;
|
|
std :: string title_lower;
|
|
std :: string filepath;
|
|
std :: string length_str;
|
|
|
|
Track();
|
|
Track(const std::string &, Library *);
|
|
~Track();
|
|
const std::string primary_key() const;
|
|
void read(File &);
|
|
void write(File &);
|
|
|
|
bool tag();
|
|
const std::string path() const;
|
|
void played();
|
|
int less_than(Track *, sort_t);
|
|
};
|
|
|
|
|
|
namespace tagdb
|
|
{
|
|
|
|
void init();
|
|
void commit();
|
|
void commit_library();
|
|
|
|
Track *add_track(const std::string &, Library *);
|
|
Library *add_library(const std::string &);
|
|
void remove_track(unsigned int);
|
|
void remove_library(unsigned int);
|
|
Track *lookup(unsigned int);
|
|
Library *lookup_library(unsigned int);
|
|
Database<Track> &get_track_db();
|
|
Database<Library> &get_library_db();
|
|
|
|
}
|
|
|
|
#endif /* OCARINA_CORE_TAGS_H */
|