Update design.txt
To include changes to: - Idle queue - Library - Playlist Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
f417b48df8
commit
6a29066ac7
68
design.txt
68
design.txt
|
@ -325,8 +325,17 @@ Idle queue: (lib/idle.cpp)
|
|||
tasks must inherit from the IdleBase class so that multiple templated
|
||||
IdleTask pointers can be placed on the same idle queue.
|
||||
|
||||
Creating an idle queue in idle.hpp will create a new queue for every
|
||||
file that idle.h is included in. I want to have a single, shared
|
||||
idle queue used by the entire application so to get around this the
|
||||
IdleBase class is used and implemented in lib/idle.cpp.
|
||||
|
||||
- IdleBase:
|
||||
class IdleBase {
|
||||
private:
|
||||
schedule();
|
||||
|
||||
public:
|
||||
IdleBase();
|
||||
~IdleBase();
|
||||
virtual void run() = 0;
|
||||
|
@ -336,30 +345,34 @@ Idle queue: (lib/idle.cpp)
|
|||
template <class T>
|
||||
class IdleTask : IdleBase {
|
||||
private:
|
||||
void (*func)(T *);
|
||||
T *data;
|
||||
void (*func)(T &);
|
||||
T &data;
|
||||
|
||||
public:
|
||||
IdleTask(void (*)(T *), T *);
|
||||
IdleTask(void (*)(T &), T);
|
||||
void run();
|
||||
};
|
||||
|
||||
- Queue:
|
||||
deque(IdleBase *> idle_queue;
|
||||
queue<IdleBase *> idle_queue;
|
||||
float queued = 0.0
|
||||
float serviced = 0.0
|
||||
|
||||
- API:
|
||||
void IdleBase :: schedule();
|
||||
Add the idle task to the idle queue. This should be called
|
||||
by the IdleTask constructor.
|
||||
queued++;
|
||||
|
||||
template <class T>
|
||||
void idle :: schedule(void (*)(T *), T *);
|
||||
Schedule a function to run later (queued++). This should
|
||||
be written in the idle.hpp file since it is a function
|
||||
template.
|
||||
static inline void idle :: schedule(void (*)(T &), T);
|
||||
Create a new IdleTask to run the function later.
|
||||
|
||||
bool idle :: run_task()
|
||||
If there are tasks on the queue:
|
||||
run the next task
|
||||
scheduled++
|
||||
If there are still tasks on the queue:
|
||||
return true
|
||||
else:
|
||||
queued = 0
|
||||
|
@ -368,7 +381,8 @@ Idle queue: (lib/idle.cpp)
|
|||
|
||||
float idle :: get_progress()
|
||||
Return (serviced / queued) to the caller. If there are no
|
||||
tasks, return 1.0 to indicate that the queue is finished.
|
||||
tasks, return 1.0 to indicate that the queue is finished (and
|
||||
to avoid a divide-by-zero error).
|
||||
|
||||
|
||||
|
||||
|
@ -522,6 +536,7 @@ Library: (lib/library.cpp)
|
|||
|
||||
- Album:
|
||||
class library :: Album : public DatabaseEntry {
|
||||
public:
|
||||
string name;
|
||||
short year;
|
||||
};
|
||||
|
@ -530,6 +545,7 @@ Library: (lib/library.cpp)
|
|||
|
||||
- Artist:
|
||||
class library :: Artist : public DatabaseEntry {
|
||||
public:
|
||||
string name;
|
||||
};
|
||||
|
||||
|
@ -537,6 +553,7 @@ Library: (lib/library.cpp)
|
|||
|
||||
- Genre:
|
||||
class library :: Genre : public DatabaseEntry {
|
||||
public:
|
||||
string name;
|
||||
};
|
||||
|
||||
|
@ -544,6 +561,7 @@ Library: (lib/library.cpp)
|
|||
|
||||
- Path:
|
||||
class library :: Path : public DatabaseEntry {
|
||||
public:
|
||||
string root_path;
|
||||
bool enabled;
|
||||
};
|
||||
|
@ -552,6 +570,7 @@ Library: (lib/library.cpp)
|
|||
|
||||
- Track:
|
||||
class library :: Track : public DatabaseEntry {
|
||||
public:
|
||||
unsigned int artist_id;
|
||||
unsigned int album_id;
|
||||
unsigned int genre_id;
|
||||
|
@ -586,7 +605,7 @@ Library: (lib/library.cpp)
|
|||
- Databases:
|
||||
Database<library :: Album> album_db(album.db);
|
||||
Database<library :: Artist> artist_db(artist.db);
|
||||
Database<library :: Album> genre_db(genre.db);
|
||||
Database<library :: Genre> genre_db(genre.db);
|
||||
Database<library :: Library> library_db(library.db);
|
||||
Database<library :: Track> track_db(track.db);
|
||||
|
||||
|
@ -619,17 +638,26 @@ Library: (lib/library.cpp)
|
|||
|
||||
- API
|
||||
library :: init();
|
||||
Initialize all databases
|
||||
Initialize databases and read files from disk. Fill out
|
||||
groups and prepare filter as tracks are read.
|
||||
library :: add_path(string dir);
|
||||
Add new row to paths table, update
|
||||
library :: del_path(unsigned int lib_id);
|
||||
Invalidate a path row
|
||||
Invalidate a path row and all tracks owned by that path
|
||||
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
|
||||
const Database<library :: Album> &library :: get_albums();
|
||||
Return the album database.
|
||||
const Database<library :: Artist> &library :: get_artists();
|
||||
Return the artist database.
|
||||
const Database<library :: Genre> &library :: get_genres();
|
||||
Return the genre database.
|
||||
const Database<library :: Library> &library :: get_libraries();
|
||||
Return the library database.
|
||||
const Database<library :: Track> &library :: get_tracks();
|
||||
Return the track database.
|
||||
|
||||
|
||||
|
||||
|
@ -671,7 +699,15 @@ Playlist: (lib/playlist.cpp)
|
|||
void next();
|
||||
}
|
||||
|
||||
File << flags << cur << tracks[0] << tracks[1] << ... << tracks[N];
|
||||
File << flags << tracks.size() << tracks[0] << tracks[1] << ... << tracks[N];
|
||||
|
||||
- Deck:
|
||||
list<Playlist> deck;
|
||||
unsigned int current_track;
|
||||
|
||||
File << current_track << deck.size() << endl;
|
||||
File << deck[0] << endl;
|
||||
File << deck[1] << endl;
|
||||
|
||||
- Deck:
|
||||
list<Playlist> deck;
|
||||
|
@ -688,6 +724,8 @@ Playlist: (lib/playlist.cpp)
|
|||
Removes playlist N from the deck
|
||||
Playlist *deck :: get(N)
|
||||
Return playlist N from the deck
|
||||
deck :: next()
|
||||
Play the next song from the deck
|
||||
|
||||
- TODO <<<<<
|
||||
What if each playlist has its own playlist_id for tracks? This would
|
||||
|
|
|
@ -24,6 +24,7 @@ Library: (lib/library.cpp)
|
|||
|
||||
- Album:
|
||||
class library :: Album : public DatabaseEntry {
|
||||
public:
|
||||
string name;
|
||||
short year;
|
||||
};
|
||||
|
@ -32,6 +33,7 @@ Library: (lib/library.cpp)
|
|||
|
||||
- Artist:
|
||||
class library :: Artist : public DatabaseEntry {
|
||||
public:
|
||||
string name;
|
||||
};
|
||||
|
||||
|
@ -39,6 +41,7 @@ Library: (lib/library.cpp)
|
|||
|
||||
- Genre:
|
||||
class library :: Genre : public DatabaseEntry {
|
||||
public:
|
||||
string name;
|
||||
};
|
||||
|
||||
|
@ -46,6 +49,7 @@ Library: (lib/library.cpp)
|
|||
|
||||
- Path:
|
||||
class library :: Path : public DatabaseEntry {
|
||||
public:
|
||||
string root_path;
|
||||
bool enabled;
|
||||
};
|
||||
|
@ -54,6 +58,7 @@ Library: (lib/library.cpp)
|
|||
|
||||
- Track:
|
||||
class library :: Track : public DatabaseEntry {
|
||||
public:
|
||||
unsigned int artist_id;
|
||||
unsigned int album_id;
|
||||
unsigned int genre_id;
|
||||
|
@ -88,7 +93,7 @@ Library: (lib/library.cpp)
|
|||
- Databases:
|
||||
Database<library :: Album> album_db(album.db);
|
||||
Database<library :: Artist> artist_db(artist.db);
|
||||
Database<library :: Album> genre_db(genre.db);
|
||||
Database<library :: Genre> genre_db(genre.db);
|
||||
Database<library :: Library> library_db(library.db);
|
||||
Database<library :: Track> track_db(track.db);
|
||||
|
||||
|
@ -121,14 +126,23 @@ Library: (lib/library.cpp)
|
|||
|
||||
- API
|
||||
library :: init();
|
||||
Initialize all databases
|
||||
Initialize databases and read files from disk. Fill out
|
||||
groups and prepare filter as tracks are read.
|
||||
library :: add_path(string dir);
|
||||
Add new row to paths table, update
|
||||
library :: del_path(unsigned int lib_id);
|
||||
Invalidate a path row
|
||||
Invalidate a path row and all tracks owned by that path
|
||||
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
|
||||
const Database<library :: Album> &library :: get_albums();
|
||||
Return the album database.
|
||||
const Database<library :: Artist> &library :: get_artists();
|
||||
Return the artist database.
|
||||
const Database<library :: Genre> &library :: get_genres();
|
||||
Return the genre database.
|
||||
const Database<library :: Library> &library :: get_libraries();
|
||||
Return the library database.
|
||||
const Database<library :: Track> &library :: get_tracks();
|
||||
Return the track database.
|
||||
|
|
|
@ -47,7 +47,15 @@ Playlist: (lib/playlist.cpp)
|
|||
void next();
|
||||
}
|
||||
|
||||
File << flags << cur << tracks[0] << tracks[1] << ... << tracks[N];
|
||||
File << flags << tracks.size() << tracks[0] << tracks[1] << ... << tracks[N];
|
||||
|
||||
- Deck:
|
||||
list<Playlist> deck;
|
||||
unsigned int current_track;
|
||||
|
||||
File << current_track << deck.size() << endl;
|
||||
File << deck[0] << endl;
|
||||
File << deck[1] << endl;
|
||||
|
||||
- Deck:
|
||||
list<Playlist> deck;
|
||||
|
@ -64,6 +72,8 @@ Playlist: (lib/playlist.cpp)
|
|||
Removes playlist N from the deck
|
||||
Playlist *deck :: get(N)
|
||||
Return playlist N from the deck
|
||||
deck :: next()
|
||||
Play the next song from the deck
|
||||
|
||||
- TODO <<<<<
|
||||
What if each playlist has its own playlist_id for tracks? This would
|
||||
|
|
Loading…
Reference in New Issue