* Fixed clang compile.

* Removed the query template stuff from last night. Overly-complicated and not
  necessary.
* Renamed QueryBase to LocalQueryBase
This commit is contained in:
Casey Langen 2017-02-05 01:50:25 -08:00
parent fb74bb3d1f
commit 2590d37e4b
14 changed files with 46 additions and 52 deletions

View File

@ -49,9 +49,5 @@ include_directories(
../3rdparty/include/sqlite
)
add_definitions(
-D_DEBUG
)
add_library(musikcore STATIC ${CORE_SOURCES})
target_link_libraries(musikcore ${musikbox_LINK_LIBS})

View File

@ -156,7 +156,7 @@
<ClInclude Include="library\query\local\SavePlaylistQuery.h" />
<ClInclude Include="library\query\local\SearchTrackListQuery.h" />
<ClInclude Include="library\query\local\TrackListQueryBase.h" />
<ClInclude Include="Library\query\QueryBase.h" />
<ClInclude Include="Library\query\local\LocalQueryBase.h" />
<ClInclude Include="library\track\IndexerTrack.h" />
<ClInclude Include="library\track\LibraryTrack.h" />
<ClInclude Include="library\track\RetainedTrack.h" />
@ -215,4 +215,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -198,7 +198,7 @@
<ClInclude Include="sdk\IDataStreamFactory.h">
<Filter>src\sdk</Filter>
</ClInclude>
<ClInclude Include="Library\query\QueryBase.h">
<ClInclude Include="Library\query\local\LocalQueryBase.h">
<Filter>src\library\query</Filter>
</ClInclude>
<ClInclude Include="io\LocalFileStream.h">
@ -385,4 +385,4 @@
<Filter>src\library\query\local</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>

View File

@ -36,7 +36,7 @@
#include <core/library/LocalLibrary.h>
#include <core/config.h>
#include <core/library/query/QueryBase.h>
#include <core/library/query/local/LocalQueryBase.h>
#include <core/support/Common.h>
#include <core/support/Preferences.h>
#include <core/library/Indexer.h>
@ -52,8 +52,6 @@ using namespace musik::core::runtime;
#define VERBOSE_LOGGING 0
#define MESSAGE_QUERY_COMPLETED 5000
using QueryT = musik::core::db::QueryBase<musik::core::db::Connection>;
class QueryCompletedMessage : public Message {
public:
using IQueryPtr = std::shared_ptr<musik::core::db::IQuery>;

View File

@ -44,7 +44,7 @@
#include <core/library/ILibrary.h>
#include <core/library/IIndexer.h>
#include <core/library/IQuery.h>
#include <core/library/query/QueryBase.h>
#include <core/library/query/local/LocalQueryBase.h>
#include <thread>
#include <mutex>
@ -63,7 +63,7 @@ namespace musik { namespace core { namespace library {
{
public:
using IQueryPtr = std::shared_ptr<musik::core::db::IQuery>;
using LocalQuery = musik::core::db::QueryBase<musik::core::db::Connection>;
using LocalQuery = musik::core::db::LocalQueryBase;
using LocalQueryPtr = std::shared_ptr<LocalQuery>;
static ILibraryPtr Create(std::string name, int id);

View File

@ -34,7 +34,7 @@
#pragma once
#include <core/library/query/QueryBase.h>
#include <core/library/query/local/LocalQueryBase.h>
#include <core/db/Connection.h>
#include <core/sdk/IMetadataValueList.h>
#include <core/support/Common.h>
@ -42,7 +42,7 @@
namespace musik { namespace core { namespace db { namespace local {
class CategoryListQuery : public musik::core::db::QueryBase<musik::core::db::Connection> {
class CategoryListQuery : public musik::core::db::LocalQueryBase {
public:
/* note we implement the SDK's IMetadataValue interface so
we can return data to plugins! */

View File

@ -36,7 +36,7 @@
#include <core/db/Connection.h>
#include <core/library/track/Track.h>
#include <core/library/query/QueryBase.h>
#include <core/library/query/local/LocalQueryBase.h>
#include "TrackListQueryBase.h"

View File

@ -34,12 +34,12 @@
#pragma once
#include <core/library/query/QueryBase.h>
#include <core/library/query/local/LocalQueryBase.h>
#include <core/db/Connection.h>
namespace musik { namespace core { namespace db { namespace local {
class DeletePlaylistQuery : public musik::core::db::QueryBase<musik::core::db::Connection> {
class DeletePlaylistQuery : public musik::core::db::LocalQueryBase {
public:
DeletePlaylistQuery(const DBID playlistId);
virtual ~DeletePlaylistQuery();

View File

@ -36,7 +36,7 @@
#include <core/db/Connection.h>
#include <core/library/track/Track.h>
#include <core/library/query/QueryBase.h>
#include <core/library/query/local/LocalQueryBase.h>
#include "TrackListQueryBase.h"

View File

@ -36,6 +36,7 @@
#include <core/config.h>
#include <core/library/IQuery.h>
#include <core/db/Connection.h>
#include <sigslot/sigslot.h>
@ -44,13 +45,19 @@
namespace musik { namespace core { namespace db {
template <typename ConnectionT>
class QueryBase : public IQuery, public sigslot::has_slots<> {
class LocalQueryBase : public IQuery, public sigslot::has_slots<> {
public:
QueryBase();
virtual ~QueryBase();
LocalQueryBase()
: status(0)
, options(0)
, queryId(nextId())
, cancel(false) {
}
bool Run(ConnectionT &db) {
virtual ~LocalQueryBase() {
}
bool Run(musik::core::db::Connection &db) {
this->SetStatus(Running);
try {
if (this->IsCanceled()) {
@ -83,8 +90,14 @@ namespace musik { namespace core { namespace db {
return this->options;
}
virtual void Cancel() { this->cancel = true; }
virtual bool IsCanceled() { return cancel; }
virtual void Cancel() {
this->cancel = true;
}
virtual bool IsCanceled() {
return cancel;
}
virtual std::string Name() = 0;
protected:
@ -98,32 +111,19 @@ namespace musik { namespace core { namespace db {
this->options = options;
}
virtual bool OnRun(ConnectionT& db) = 0;
virtual bool OnRun(musik::core::db::Connection& db) = 0;
private:
static int nextId() {
static std::atomic<int> next(0);
return ++next;
}
unsigned int status;
unsigned int queryId;
unsigned int options;
volatile bool cancel;
std::mutex stateMutex;
static std::atomic<int> nextId;
};
template <typename ConnectionT>
std::atomic<int> QueryBase<ConnectionT>::nextId = 0;
template <typename ConnectionT>
QueryBase<ConnectionT>::QueryBase()
: status(0)
, options(0)
, queryId(0)
, cancel(false) {
this->queryId = nextId++;
}
template <typename ConnectionT>
QueryBase<ConnectionT>::~QueryBase() {
}
} } }

View File

@ -34,7 +34,7 @@
#pragma once
#include <core/library/query/QueryBase.h>
#include <core/library/query/local/LocalQueryBase.h>
#include <core/audio/PlaybackService.h>
#include "TrackListQueryBase.h"

View File

@ -34,14 +34,14 @@
#pragma once
#include <core/library/query/QueryBase.h>
#include <core/library/query/local/LocalQueryBase.h>
#include <core/library/track/TrackList.h>
#include <core/db/Connection.h>
#include <memory>
namespace musik { namespace core { namespace db { namespace local {
class SavePlaylistQuery : public musik::core::db::QueryBase<musik::core::db::Connection> {
class SavePlaylistQuery : public musik::core::db::LocalQueryBase {
public:
static std::shared_ptr<SavePlaylistQuery> Save(
const std::string& playlistName,

View File

@ -34,14 +34,14 @@
#pragma once
#include <core/library/query/QueryBase.h>
#include <core/library/query/local/LocalQueryBase.h>
#include <core/db/Connection.h>
#include <core/library/track/Track.h>
#include <core/library/track/TrackList.h>
namespace musik { namespace core { namespace db { namespace local {
class TrackListQueryBase : public musik::core::db::QueryBase<musik::core::db::Connection> {
class TrackListQueryBase : public musik::core::db::LocalQueryBase {
public:
typedef std::shared_ptr<musik::core::TrackList> Result;
typedef std::shared_ptr<std::set<size_t> > Headers;

View File

@ -35,7 +35,7 @@
#include "pch.hpp"
#include "TrackList.h"
#include <core/library/query/QueryBase.h>
#include <core/library/query/local/LocalQueryBase.h>
#include <core/library/track/LibraryTrack.h>
#include <core/library/LocalLibraryConstants.h>
#include <core/library/track/RetainedTrack.h>
@ -52,7 +52,7 @@ using namespace musik::core::library;
using namespace musik::core::sdk;
class TrackMetadataQuery : public QueryBase<musik::core::db::Connection> {
class TrackMetadataQuery : public LocalQueryBase {
public:
TrackMetadataQuery(DBID trackId, ILibraryPtr library);
virtual ~TrackMetadataQuery() { }