Design: Create an index class
This will be used for groups, both stored and temporary. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
08b0513578
commit
5a7fcdb305
46
design.txt
46
design.txt
|
@ -20,11 +20,13 @@ Files:
|
|||
database.h
|
||||
database.hpp
|
||||
group.h
|
||||
index.h
|
||||
library.h
|
||||
playlist.h
|
||||
ocarina/lib/
|
||||
database.cpp
|
||||
group.cpp
|
||||
index.cpp
|
||||
library.cpp
|
||||
playlist.cpp
|
||||
ocarina/tests/
|
||||
|
@ -134,6 +136,47 @@ API:
|
|||
|
||||
|
||||
|
||||
Index: (lib/index.cpp)
|
||||
An inverted index allows me to map multiple values to a single key.
|
||||
|
||||
Index:
|
||||
class Index {
|
||||
private:
|
||||
map<string, set<int>>
|
||||
string filename;
|
||||
public:
|
||||
Index::Index(filename);
|
||||
void load();
|
||||
void save();
|
||||
void insert(key, int);
|
||||
void delete(key, int);
|
||||
const set<int> &operator[](string);
|
||||
};
|
||||
|
||||
File << key << map[key].size() << endl;
|
||||
File << int_0 << int_1 << ... << int_n << endl;
|
||||
|
||||
API:
|
||||
Index.Index(filename);
|
||||
Initializes an index using ~/.ocarina{-debug}/filename
|
||||
Index.load();
|
||||
Reads data from a file. Call after static initialization of
|
||||
Ocarina to ensure idle tasks are configured
|
||||
Index.save();
|
||||
Saves data to file
|
||||
Index.insert(key, int);
|
||||
1) If key does not exist, create it.
|
||||
2) Add int to the list
|
||||
3) Index.save()
|
||||
Index.delete(key, int);
|
||||
1) Remove int from the set of values associated with key
|
||||
2) Do not delete key if set is empty
|
||||
3) Index.save()
|
||||
Index.operator[](string key);
|
||||
Return the set associated with key
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
@ -222,7 +265,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.
|
||||
2b) Else, add track to the library and to the library group
|
||||
3) Save all databases
|
||||
|
||||
The taglib library should be used for finding artist, album, etc. tags
|
||||
for each track.
|
||||
|
|
Loading…
Reference in New Issue