Design: Update library information
I decided to put the library into a namespace to keep the code clean. I also added an update algorithm and made minor naming changes. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
2ea1ea8d26
commit
59f08cfc51
82
design.txt
82
design.txt
|
@ -130,30 +130,34 @@ API:
|
|||
|
||||
|
||||
Library: (lib/library.cpp)
|
||||
The library manages databases containing track information added by the
|
||||
user. Ocarina 6 splits the library into multiple database tables for
|
||||
storing content. The library will exist in a library namespace to
|
||||
to make functions and classes more unique.
|
||||
|
||||
This file will manage and control access to the library. The library
|
||||
will be split into 5 database tables based on the content being stored,
|
||||
and should be initialized before access attempts.
|
||||
When a library : Track is created, it should be added to the "Library"
|
||||
group if it is NOT a member of the banned songs group.
|
||||
|
||||
class Album : public DatabaseEntry {
|
||||
Structures:
|
||||
class library :: Album : public DatabaseEntry {
|
||||
string name;
|
||||
short year;
|
||||
};
|
||||
|
||||
class Artist : public DatabaseEntry {
|
||||
class library :: Artist : public DatabaseEntry {
|
||||
string name;
|
||||
};
|
||||
|
||||
class Genre : public DatabaseEntry {
|
||||
class library :: Genre : public DatabaseEntry {
|
||||
string name;
|
||||
};
|
||||
|
||||
class Library : public DatabaseEntry {
|
||||
string base_path;
|
||||
class library :: Root : public DatabaseEntry {
|
||||
string root_path;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
class Track : public DatabaseEntry {
|
||||
class library :: Track : public DatabaseEntry {
|
||||
unsigned int artist_id;
|
||||
unsigned int album_id;
|
||||
unsigned int genre_id;
|
||||
|
@ -170,11 +174,19 @@ Library: (lib/library.cpp)
|
|||
string filepath;
|
||||
};
|
||||
|
||||
Database album_db;
|
||||
Database artist_db;
|
||||
Database genre_db;
|
||||
Database library_db;
|
||||
Database track_db;
|
||||
struct Track { /* Leave this outside of the namespace */
|
||||
library :: Album *album;
|
||||
library :: Artist *artist;
|
||||
library :: Genre *genre;
|
||||
library :: Library *library;
|
||||
library :: Track *track;
|
||||
};
|
||||
|
||||
Database<library :: Album> album_db;
|
||||
Database<library :: Artist> artist_db;
|
||||
Database<library :: Album> genre_db;
|
||||
Database<library :: Library> library_db;
|
||||
Database<library :: Track> track_db;
|
||||
|
||||
File formats:
|
||||
Album:
|
||||
|
@ -187,30 +199,44 @@ File formats:
|
|||
name
|
||||
|
||||
Track:
|
||||
artist_id album_id genre_id library_id track last_year last_month last_day play_count length
|
||||
artist_id album_id genre_id library_id track last_year last_month last_day play_count length length_str
|
||||
title
|
||||
length_str
|
||||
filepath
|
||||
|
||||
Library:
|
||||
enabled base_path;
|
||||
|
||||
Updating algorithm:
|
||||
set<pair<lib_id, track_path>> known_tracks;
|
||||
|
||||
1) For each track currently in the library, check if the track exists
|
||||
in the filesystem.
|
||||
1a) If the track does exist, add to the known_tracks map.
|
||||
1b) Else, mark track invalid.
|
||||
2) For each file in the scan directory, check if (lib_id, track_path)
|
||||
exists in the known_tracks map.
|
||||
2a) If the file is in the map, do nothing.
|
||||
2b) Else, add track to the library.
|
||||
|
||||
The taglib library should be used for finding artist, album, etc. tags
|
||||
for each track.
|
||||
|
||||
Use idle tasks for step 2 to break up tagging new files into chunks.
|
||||
This way the user will still be able to use Ocarina and scanning can
|
||||
happen while idle.
|
||||
|
||||
- API
|
||||
/* Path management */
|
||||
add_path_to_library(dir);
|
||||
library :: add_path(string dir);
|
||||
Add new row to paths table, update
|
||||
rm_path_from_library(dir);
|
||||
Remove row from paths table
|
||||
update_path(dir);
|
||||
Scan tracks table, remove paths that don't exist
|
||||
Scan dir, add new files to database
|
||||
Consider having SQLite create an index on tracks.filepath
|
||||
update_all();
|
||||
Call update_path() for each paths.dirpath
|
||||
list_paths(list<>);
|
||||
Tell the caller basic information about library paths
|
||||
(dir, enabled, size,...)
|
||||
library :: del_path(unsigned int lib_id);
|
||||
Invalidate a path row
|
||||
library :: update_path(lib_id);
|
||||
Update the given library path, if valid.
|
||||
const Database<LibraryEntry> &library :: get_db();
|
||||
Returns the database containing library information.
|
||||
struct Track library :: resolve(track_id)
|
||||
Fill out a Track structure for the provided track_id
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue