Added ITrackList interface to sdk. We'll use this for plugins in the near

future.
This commit is contained in:
casey langen 2017-01-21 17:24:32 -08:00
parent 06438830fc
commit 462ac04448
5 changed files with 83 additions and 12 deletions

View File

@ -180,6 +180,7 @@
<ClInclude Include="sdk\IRetainedTrack.h" />
<ClInclude Include="sdk\ISpectrumVisualizer.h" />
<ClInclude Include="sdk\ITrack.h" />
<ClInclude Include="sdk\ITrackList.h" />
<ClInclude Include="sdk\ITrackListEditor.h" />
<ClInclude Include="sdk\IVisualizer.h" />
<ClInclude Include="support\Common.h" />

View File

@ -327,5 +327,8 @@
<ClInclude Include="sdk\ITrackListEditor.h">
<Filter>src\sdk</Filter>
</ClInclude>
<ClInclude Include="sdk\ITrackList.h">
<Filter>src\sdk</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -38,6 +38,7 @@
#include <core/library/query/QueryBase.h>
#include <core/library/track/LibraryTrack.h>
#include <core/library/LocalLibraryConstants.h>
#include <core/library/track/RetainedTrack.h>
#include <core/db/Connection.h>
#include <core/db/Statement.h>
@ -50,6 +51,8 @@ using namespace musik::core::db;
using namespace musik::core::query;
using namespace musik::core::library;
using namespace musik::core::sdk;
class TrackMetadataQuery : public QueryBase {
public:
TrackMetadataQuery(DBID trackId, LibraryPtr library);
@ -137,6 +140,10 @@ TrackPtr TrackList::Get(size_t index) {
return query->Result();
}
IRetainedTrack* TrackList::GetRetainedTrack(size_t index) {
return new RetainedTrack(this->Get(index));
}
DBID TrackList::GetId(size_t index) {
return this->ids.at(index);
}

View File

@ -34,39 +34,45 @@
#pragma once
#include <core/sdk/ITrackList.h>
#include <core/sdk/ITrackListEditor.h>
#include <core/library/track/Track.h>
#include <core/library/ILibrary.h>
#include <core/sdk/ITrackListEditor.h>
#include <unordered_map>
#include <list>
namespace musik { namespace core {
class TrackList : public musik::core::sdk::ITrackListEditor {
class TrackList :
public musik::core::sdk::ITrackList,
public musik::core::sdk::ITrackListEditor
{
public:
TrackList(LibraryPtr library);
virtual ~TrackList();
/* implementation specific */
DBID GetId(size_t index);
int IndexOf(DBID id);
void ClearCache();
void Swap(TrackList& list);
void CopyFrom(TrackList& from);
/* ITrackList */
size_t Count();
TrackPtr Get(size_t index);
virtual size_t Count();
virtual musik::core::sdk::IRetainedTrack* GetRetainedTrack(size_t index);
virtual DBID GetId(size_t index);
virtual int IndexOf(DBID id);
/* ITrackListEditor */
virtual void Add(const DBID id);
virtual void Clear();
virtual bool Insert(unsigned long long id, size_t index);
virtual bool Insert(DBID id, size_t index);
virtual bool Swap(size_t index1, size_t index2);
virtual bool Move(size_t from, size_t to);
virtual bool Delete(size_t index);
virtual void Shuffle();
/* implementation specific */
TrackPtr Get(size_t index);
void ClearCache();
void Swap(TrackList& list);
void CopyFrom(TrackList& from);
private:
typedef std::list<DBID> CacheList;
typedef std::pair<TrackPtr, CacheList::iterator> CacheValue;

54
src/core/sdk/ITrackList.h Normal file
View File

@ -0,0 +1,54 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2016 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "IRetainedTrack.h"
namespace musik {
namespace core {
namespace sdk {
class ITrackList {
public:
virtual size_t Count() = 0;
virtual IRetainedTrack* GetRetainedTrack(size_t index) = 0;
virtual unsigned long long GetId(size_t index) = 0;
virtual int IndexOf(unsigned long long id) = 0;
};
}
}
}