Improve on file format text
I think it's cleaner now. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
59f08cfc51
commit
08b0513578
68
design.txt
68
design.txt
|
@ -49,6 +49,12 @@ On-disk files:
|
|||
this into a single number shared across all files for simplicity, and
|
||||
then create a class to read and write data on disk.
|
||||
|
||||
Items should be written to a file with either a space or new line
|
||||
separating multiple values.
|
||||
|
||||
Notation:
|
||||
File << aaaaa << bbbbb << endl is translated into "aaaaa bbbbb\n"
|
||||
|
||||
|
||||
|
||||
Database: (lib/database.cpp)
|
||||
|
@ -72,9 +78,10 @@ Database: (lib/database.cpp)
|
|||
include/database.hpp, which will be included by database.h. Any
|
||||
function not relying on a template can be written in lib/database.cpp.
|
||||
|
||||
Structures and constants:
|
||||
File version:
|
||||
#define FILE_VERSION 4
|
||||
|
||||
DatabaseEntry:
|
||||
class DatabaseEntry { /* let database modify valid flag */
|
||||
private:
|
||||
bool valid;
|
||||
|
@ -84,6 +91,9 @@ Structures and constants:
|
|||
friend class Database;
|
||||
};
|
||||
|
||||
File << <CHILD_CLASS_DATA>
|
||||
|
||||
Database:
|
||||
template <class T>
|
||||
class Database {
|
||||
private:
|
||||
|
@ -100,15 +110,10 @@ Structures and constants:
|
|||
const T &operator[](unsigned int);
|
||||
};
|
||||
|
||||
File formats:
|
||||
Database:
|
||||
FILE_VERSION db.size()
|
||||
INDEX db[INDEX].valid DatabaseEntry
|
||||
INDEX db[INDEX].valid DatabaseEntry
|
||||
...
|
||||
|
||||
DatabaseEntry:
|
||||
<CHILD_CLASS_DATA>
|
||||
File << FILE_VERSION << db.size() << endl
|
||||
File << INDEX_0 << db[INDEX_0].valid << db[INDEX_0] << endl;
|
||||
File << Index_1 << db[INDEX_1].valid << db[INDEX_1] << endl;
|
||||
...
|
||||
|
||||
API:
|
||||
Database.Database(filename);
|
||||
|
@ -138,25 +143,37 @@ Library: (lib/library.cpp)
|
|||
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.
|
||||
|
||||
Structures:
|
||||
Album:
|
||||
class library :: Album : public DatabaseEntry {
|
||||
string name;
|
||||
short year;
|
||||
};
|
||||
|
||||
File << year << name
|
||||
|
||||
Artist:
|
||||
class library :: Artist : public DatabaseEntry {
|
||||
string name;
|
||||
};
|
||||
|
||||
File << name
|
||||
|
||||
Genre:
|
||||
class library :: Genre : public DatabaseEntry {
|
||||
string name;
|
||||
};
|
||||
|
||||
class library :: Root : public DatabaseEntry {
|
||||
File << name
|
||||
|
||||
Path:
|
||||
class library :: Path : public DatabaseEntry {
|
||||
string root_path;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
File << enabled << root_path
|
||||
|
||||
Track:
|
||||
class library :: Track : public DatabaseEntry {
|
||||
unsigned int artist_id;
|
||||
unsigned int album_id;
|
||||
|
@ -174,7 +191,13 @@ Structures:
|
|||
string filepath;
|
||||
};
|
||||
|
||||
struct Track { /* Leave this outside of the namespace */
|
||||
File << artist_id << album_id << genre_id << library_id << track << last_year
|
||||
File << last_year << last_month << last_day << play_count << length << endl
|
||||
File << title << endl;
|
||||
File << filepath << endl;
|
||||
|
||||
Track: /* This struct lies outside the library namespace */
|
||||
struct Track {
|
||||
library :: Album *album;
|
||||
library :: Artist *artist;
|
||||
library :: Genre *genre;
|
||||
|
@ -182,30 +205,13 @@ Structures:
|
|||
library :: Track *track;
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
File formats:
|
||||
Album:
|
||||
year name
|
||||
|
||||
Artist:
|
||||
name
|
||||
|
||||
Genre:
|
||||
name
|
||||
|
||||
Track:
|
||||
artist_id album_id genre_id library_id track last_year last_month last_day play_count length length_str
|
||||
title
|
||||
filepath
|
||||
|
||||
Library:
|
||||
enabled base_path;
|
||||
|
||||
Updating algorithm:
|
||||
set<pair<lib_id, track_path>> known_tracks;
|
||||
|
||||
|
|
Loading…
Reference in New Issue