Design: Update groups
Groups now use an index to manage their data. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
5a7fcdb305
commit
fc40a9f77f
88
design.txt
88
design.txt
|
@ -35,6 +35,7 @@ Files:
|
|||
album.db
|
||||
artist.db
|
||||
genre.db
|
||||
groups.idx
|
||||
library.db
|
||||
track.db
|
||||
|
||||
|
@ -106,7 +107,7 @@ Database:
|
|||
Database::Database(filename);
|
||||
void load();
|
||||
void save();
|
||||
void insert(T);
|
||||
unsigned int insert(T);
|
||||
void delete(unsigned int);
|
||||
const unsigned int &size();
|
||||
const T &operator[](unsigned int);
|
||||
|
@ -126,7 +127,7 @@ API:
|
|||
Database.save();
|
||||
Saves data to file.
|
||||
Database.insert(T &);
|
||||
Adds a new item to the db
|
||||
Adds a new item to the db, returns the id of the item
|
||||
Database.delete(unsigned int index);
|
||||
Mark db[index] as invalid (quick deletion)
|
||||
Database.size();
|
||||
|
@ -150,6 +151,7 @@ Index:
|
|||
void save();
|
||||
void insert(key, int);
|
||||
void delete(key, int);
|
||||
const set<string> &keys();
|
||||
const set<int> &operator[](string);
|
||||
};
|
||||
|
||||
|
@ -172,6 +174,8 @@ API:
|
|||
1) Remove int from the set of values associated with key
|
||||
2) Do not delete key if set is empty
|
||||
3) Index.save()
|
||||
Index.keys();
|
||||
Return a set of index keys
|
||||
Index.operator[](string key);
|
||||
Return the set associated with key
|
||||
|
||||
|
@ -249,11 +253,11 @@ Track: /* This struct lies outside the library namespace */
|
|||
};
|
||||
|
||||
Databases:
|
||||
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;
|
||||
Database<library :: Album> album_db(album.db);
|
||||
Database<library :: Artist> artist_db(artist.db);
|
||||
Database<library :: Album> genre_db(genre.db);
|
||||
Database<library :: Library> library_db(library.db);
|
||||
Database<library :: Track> track_db(track.db);
|
||||
|
||||
Updating algorithm:
|
||||
set<pair<lib_id, track_path>> known_tracks;
|
||||
|
@ -265,7 +269,8 @@ Updating algorithm:
|
|||
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 and to the library group
|
||||
2b) Else, add track to the library and to the "All Music" and
|
||||
"Library" and "Unplayed Tracks" groups
|
||||
3) Save all databases
|
||||
|
||||
The taglib library should be used for finding artist, album, etc. tags
|
||||
|
@ -290,6 +295,37 @@ Updating algorithm:
|
|||
|
||||
|
||||
|
||||
Groups: (lib/group.cpp)
|
||||
Groups are going to be a new feature in Ocarina 6 and can compare
|
||||
directly to Gmail-style labels. Ocarina 6 will create dynamic groups
|
||||
that cannot be deleted by the user based on library status. Similar
|
||||
to the library, groups should exist in their own namespace.
|
||||
|
||||
Index:
|
||||
Index group_idx(groups.idx)
|
||||
|
||||
Default groups:
|
||||
All music
|
||||
All tracks are added to this group
|
||||
Library
|
||||
Banned Songs
|
||||
These groups are mutually exclusive. A track is either
|
||||
in the Library or the Banned Songs group
|
||||
Unplayed tracks
|
||||
Tracks with a play count of 0
|
||||
|
||||
- API
|
||||
group :: list();
|
||||
return group_idx.keys();
|
||||
group :: get_tracks(name):
|
||||
return group_idx[name]
|
||||
group :: add(name, track_id)
|
||||
group_idx.insert(name, track_id);
|
||||
group :: del(name, track_id)
|
||||
grou_idx.delete(name, track_id)
|
||||
|
||||
|
||||
|
||||
Playlist: (lib/playlist.cpp)
|
||||
A playlist is a simple list of songs that can be played either randomly
|
||||
or in a user-defined order. It would probably be best to use a linked
|
||||
|
@ -314,42 +350,6 @@ Playlist: (lib/playlist.cpp)
|
|||
|
||||
|
||||
|
||||
Groups: (lib/group.cpp)
|
||||
Groups are going to be a new feature in Ocarina 6 and can compare
|
||||
directly to Gmail-style labels. Ocarina 6 will create dynamic groups
|
||||
that cannot be deleted by the user based on library status.
|
||||
|
||||
Default groups:
|
||||
All music
|
||||
All tracks are added to this group
|
||||
Library
|
||||
Banned Songs
|
||||
These groups are mutually exclusive. A track is either
|
||||
in the Library or the Banned Songs group
|
||||
Unplayed tracks
|
||||
Tracks with a play count of 0
|
||||
|
||||
|
||||
- API
|
||||
list_groups();
|
||||
Return a list of group names
|
||||
group_get_tracks(name):
|
||||
Return a list of tracks that are in group "name"
|
||||
|
||||
Track.add_to_group(name);
|
||||
Add a track to a group
|
||||
Track.rm_from_group(name);
|
||||
Remove a track from a group
|
||||
|
||||
- Design TODO <<<<<
|
||||
- I need a way to loop over each track in the library to create
|
||||
dynamic groups. Whole library iterator?
|
||||
- A "Track" class with functions for accessing tags and with access
|
||||
to groups. Perhaps make "Track" its own file, outside of the
|
||||
library and group code?
|
||||
|
||||
|
||||
|
||||
Future work:
|
||||
I want to set reasonable expectations for Ocarina 6 so that I don't
|
||||
have to spend a large amount of time coding before releasing something
|
||||
|
|
Loading…
Reference in New Issue