libsaria: Created a SourceModel class
The source model class is used to more tightly control how songs are inserted into the UI. I provide an insert() function that the library's for_each() function can take advantage of. This allows me to directly insert songs into the UI rather than having to use a static function as the "middle man"
This commit is contained in:
parent
e5bd2471b0
commit
136f12bc7c
|
@ -2,6 +2,7 @@
|
||||||
#define LIBSARIA_LIBRARY_H
|
#define LIBSARIA_LIBRARY_H
|
||||||
|
|
||||||
#include <libsaria/track.h>
|
#include <libsaria/track.h>
|
||||||
|
#include <libsaria/model.h>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -26,7 +27,7 @@ namespace libsaria
|
||||||
void remove_path(string);
|
void remove_path(string);
|
||||||
void play_id(ino_t &);
|
void play_id(ino_t &);
|
||||||
void get_info(ino_t &, void(*)(Track &));
|
void get_info(ino_t &, void(*)(Track &));
|
||||||
void for_each(void (*)(Track &));
|
void for_each(SourceModel *);
|
||||||
void for_each_path(void (*)(struct PathInfo &));
|
void for_each_path(void (*)(struct PathInfo &));
|
||||||
|
|
||||||
unsigned int size();
|
unsigned int size();
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef LIBSARIA_SOURCE_H
|
||||||
|
#define LIBSARIA_SOURCE_H
|
||||||
|
|
||||||
|
#include <libsaria/track.h>
|
||||||
|
|
||||||
|
namespace libsaria
|
||||||
|
{
|
||||||
|
|
||||||
|
class SourceModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SourceModel();
|
||||||
|
virtual ~SourceModel() = 0;
|
||||||
|
|
||||||
|
virtual void insert(Track &) = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* LIBSARIA_SOURCE_H */
|
|
@ -4,6 +4,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include <libsaria/audio.h>
|
#include <libsaria/audio.h>
|
||||||
|
#include <libsaria/model.h>
|
||||||
#include <libsaria/callback.h>
|
#include <libsaria/callback.h>
|
||||||
#include <libsaria/library.h>
|
#include <libsaria/library.h>
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
|
@ -24,13 +25,13 @@ LibraryPath *get_library_path(string dir)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryPath::for_each(void (*ins_func)(Track &))
|
void LibraryPath::for_each(libsaria::SourceModel *model)
|
||||||
{
|
{
|
||||||
map<ino_t, TrackTag>::iterator it;
|
map<ino_t, TrackTag>::iterator it;
|
||||||
|
|
||||||
for (it = file_map.begin(); it != file_map.end(); it++) {
|
for (it = file_map.begin(); it != file_map.end(); it++) {
|
||||||
Track track = Track(it->first, &it->second);
|
Track track = Track(it->first, &it->second);
|
||||||
ins_func(track);
|
model->insert(track);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,11 +68,11 @@ bool LibraryPath::play_id(ino_t &id)
|
||||||
namespace libsaria
|
namespace libsaria
|
||||||
{
|
{
|
||||||
|
|
||||||
void library::for_each(void (*ins_func)(Track &))
|
void library::for_each(SourceModel *model)
|
||||||
{
|
{
|
||||||
map<string, LibraryPath>::iterator it;
|
map<string, LibraryPath>::iterator it;
|
||||||
for (it = path_map.begin(); it != path_map.end(); it++)
|
for (it = path_map.begin(); it != path_map.end(); it++)
|
||||||
it->second.for_each(ins_func);
|
it->second.for_each(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
void library::for_each_path(void (*info_func)(struct library::PathInfo &))
|
void library::for_each_path(void (*info_func)(struct library::PathInfo &))
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include <libsaria/library.h>
|
#include <libsaria/library.h>
|
||||||
|
#include <libsaria/model.h>
|
||||||
#include <libsaria/path.h>
|
#include <libsaria/path.h>
|
||||||
|
|
||||||
class LibraryPath
|
class LibraryPath
|
||||||
|
@ -19,7 +20,7 @@ class LibraryPath
|
||||||
LibraryPath(InFile &, string);
|
LibraryPath(InFile &, string);
|
||||||
~LibraryPath();
|
~LibraryPath();
|
||||||
|
|
||||||
void for_each(void (*)(Track &));
|
void for_each(libsaria::SourceModel *);
|
||||||
void get_info(void (*)(struct libsaria::library::PathInfo &));
|
void get_info(void (*)(struct libsaria::library::PathInfo &));
|
||||||
bool get_info_id(ino_t &, void (*)(Track &));
|
bool get_info_id(ino_t &, void (*)(Track &));
|
||||||
void insert_track(ino_t &, TrackTag &);
|
void insert_track(ino_t &, TrackTag &);
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
#include <libsaria/model.h>
|
||||||
|
|
||||||
|
namespace libsaria
|
||||||
|
{
|
||||||
|
SourceModel::SourceModel(){}
|
||||||
|
SourceModel::~SourceModel(){}
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue