/* * Copyright 2013 (c) Anna Schumaker. */ #ifndef OCARINA_LIBRARY_H #define OCARINA_LIBRARY_H #include #include #include #include namespace library { enum DB_Type { DB_ALBUM, DB_ARTIST, DB_GENRE, DB_LIBRARY, DB_TRACK, }; class Artist : public DatabaseEntry { public: std :: string name; Artist(); Artist(TagLib :: Tag *); void read(File &); void write(File &); #ifdef CONFIG_DEBUG void print(); #endif /* CONFIG_DEBUG */ }; class Album : public DatabaseEntry { public: std :: string name; unsigned int year; unsigned int artist_id; Album(); Album(TagLib :: Tag *, unsigned int); void read(File &); void write(File &); #ifdef CONFIG_DEBUG void print(); #endif /* CONFIG_DEBUG */ }; class Genre : public DatabaseEntry { public: std:: string name; Genre(); Genre(TagLib :: Tag *); void read(File &); void write(File &); #ifdef CONFIG_DEBUG void print(); #endif /* CONFIG_DEBUG */ }; class Library : public DatabaseEntry { public: std::string root_path; bool enabled; Library(); Library(const std::string &, bool); void read(File &); void write(File &); #ifdef CONFIG_DEBUG void print(); #endif /* CONFIG_DEBUG */ }; 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; 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 */ }; struct Song { library :: Album *album; library :: Artist *artist; library :: Genre *genre; library :: Library *library; library :: Track *track; }; void init(); bool add_path(const std::string &); void del_path(unsigned int); void update_path(unsigned int); bool lookup(unsigned int, library :: Song *); #ifdef CONFIG_DEBUG void print_db(DB_Type); void reset(); #endif /* CONFIG_DEBUG */ }; #endif /* OCARINA_LIBRARY_H */