mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 13:21:13 +00:00
Added some private namespace to the SdkWrapper classes in MetadataMap and
MetadataMapList so they don't collide and confuse the runtime. Also fixed AlbumListQuery to return distinct entries and updated CMakeLists.txt with the new files.
This commit is contained in:
parent
205f719c44
commit
24c9ee8232
@ -19,6 +19,7 @@ set(CORE_SOURCES
|
||||
./library/LibraryFactory.cpp
|
||||
./library/LocalLibrary.cpp
|
||||
./library/LocalSimpleDataProvider.cpp
|
||||
./library/query/local/AlbumListQuery.cpp
|
||||
./library/query/local/GetPlaylistQuery.cpp
|
||||
./library/query/local/CategoryListQuery.cpp
|
||||
./library/query/local/CategoryTrackListQuery.cpp
|
||||
@ -26,6 +27,8 @@ set(CORE_SOURCES
|
||||
./library/query/local/NowPlayingTrackListQuery.cpp
|
||||
./library/query/local/SavePlaylistQuery.cpp
|
||||
./library/query/local/SearchTrackListQuery.cpp
|
||||
./library/metadata/MetadataMap.cpp
|
||||
./library/metadata/MetadataMapList.cpp
|
||||
./library/track/IndexerTrack.cpp
|
||||
./library/track/LibraryTrack.cpp
|
||||
./library/track/Track.cpp
|
||||
|
@ -46,19 +46,22 @@ using namespace musik::core::db;
|
||||
using namespace musik::core::library;
|
||||
using namespace musik::core::sdk;
|
||||
|
||||
/* a wrapper around a shared pointer to a MetadataMap. we
|
||||
can pass this to a plugin and it will keep the instance
|
||||
around until it's released, even if the containing list is
|
||||
released. */
|
||||
struct SdkWrapper : public IMetadataMap {
|
||||
MetadataMapPtr wrapped;
|
||||
SdkWrapper(MetadataMapPtr wrapped) { this->wrapped = wrapped; };
|
||||
virtual void Release() { this->wrapped.reset(); }
|
||||
virtual unsigned long long GetId() { return this->wrapped->GetId(); }
|
||||
virtual int GetValue(const char* key, char* dst, int size) { return this->wrapped->GetValue(key, dst, size); }
|
||||
virtual const char* GetDescription() { return this->wrapped->GetDescription(); }
|
||||
virtual const char* GetType() { return this->wrapped->GetType(); }
|
||||
};
|
||||
namespace {
|
||||
/* a wrapper around a shared pointer to a MetadataMap. we
|
||||
can pass this to a plugin and it will keep the instance
|
||||
around until it's released, even if the containing list is
|
||||
released. */
|
||||
class SdkWrapper : public IMetadataMap {
|
||||
public:
|
||||
SdkWrapper(MetadataMapPtr wrapped) { this->wrapped = wrapped; };
|
||||
virtual void Release() { this->wrapped.reset(); }
|
||||
virtual unsigned long long GetId() { return this->wrapped->GetId(); }
|
||||
virtual int GetValue(const char* key, char* dst, int size) { return this->wrapped->GetValue(key, dst, size); }
|
||||
virtual const char* GetDescription() { return this->wrapped->GetDescription(); }
|
||||
virtual const char* GetType() { return this->wrapped->GetType(); }
|
||||
MetadataMapPtr wrapped;
|
||||
};
|
||||
}
|
||||
|
||||
MetadataMap::MetadataMap(
|
||||
unsigned long long id,
|
||||
|
@ -39,13 +39,16 @@ using namespace musik::core;
|
||||
using namespace musik::core::db;
|
||||
using namespace musik::core::sdk;
|
||||
|
||||
struct SdkWrapper : public IMetadataMapList {
|
||||
MetadataMapListPtr wrapped;
|
||||
SdkWrapper(MetadataMapListPtr wrapped) { this->wrapped = wrapped; }
|
||||
virtual void Release() { this->wrapped.reset(); }
|
||||
virtual size_t Count() const { return this->wrapped->Count(); }
|
||||
virtual IMetadataMap* GetMetadata(size_t index) const { return this->wrapped->GetMetadata(index); }
|
||||
};
|
||||
namespace {
|
||||
class SdkWrapper : public IMetadataMapList {
|
||||
public:
|
||||
SdkWrapper(MetadataMapListPtr wrapped) { this->wrapped = wrapped; }
|
||||
virtual void Release() { this->wrapped.reset(); }
|
||||
virtual size_t Count() const { return this->wrapped->Count(); }
|
||||
virtual IMetadataMap* GetMetadata(size_t index) const { return this->wrapped->GetMetadata(index); }
|
||||
MetadataMapListPtr wrapped;
|
||||
};
|
||||
}
|
||||
|
||||
MetadataMapList::MetadataMapList() {
|
||||
|
||||
|
@ -91,7 +91,7 @@ bool AlbumListQuery::OnRun(Connection& db) {
|
||||
|
||||
bool filtered = this->filter.size() > 0;
|
||||
|
||||
std::string query = "SELECT " + COLUMNS + " FROM " + TABLES + " WHERE ";
|
||||
std::string query = "SELECT DISTINCT " + COLUMNS + " FROM " + TABLES + " WHERE ";
|
||||
query += filtered ? FILTER_PREDICATE : "";
|
||||
query += GENERAL_PREDICATE + " ORDER BY " + ORDER + ";";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user