mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-30 15:32:37 +00:00
Added ITrackList interface to sdk. We'll use this for plugins in the near
future.
This commit is contained in:
parent
06438830fc
commit
462ac04448
@ -180,6 +180,7 @@
|
|||||||
<ClInclude Include="sdk\IRetainedTrack.h" />
|
<ClInclude Include="sdk\IRetainedTrack.h" />
|
||||||
<ClInclude Include="sdk\ISpectrumVisualizer.h" />
|
<ClInclude Include="sdk\ISpectrumVisualizer.h" />
|
||||||
<ClInclude Include="sdk\ITrack.h" />
|
<ClInclude Include="sdk\ITrack.h" />
|
||||||
|
<ClInclude Include="sdk\ITrackList.h" />
|
||||||
<ClInclude Include="sdk\ITrackListEditor.h" />
|
<ClInclude Include="sdk\ITrackListEditor.h" />
|
||||||
<ClInclude Include="sdk\IVisualizer.h" />
|
<ClInclude Include="sdk\IVisualizer.h" />
|
||||||
<ClInclude Include="support\Common.h" />
|
<ClInclude Include="support\Common.h" />
|
||||||
|
@ -327,5 +327,8 @@
|
|||||||
<ClInclude Include="sdk\ITrackListEditor.h">
|
<ClInclude Include="sdk\ITrackListEditor.h">
|
||||||
<Filter>src\sdk</Filter>
|
<Filter>src\sdk</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="sdk\ITrackList.h">
|
||||||
|
<Filter>src\sdk</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -38,6 +38,7 @@
|
|||||||
#include <core/library/query/QueryBase.h>
|
#include <core/library/query/QueryBase.h>
|
||||||
#include <core/library/track/LibraryTrack.h>
|
#include <core/library/track/LibraryTrack.h>
|
||||||
#include <core/library/LocalLibraryConstants.h>
|
#include <core/library/LocalLibraryConstants.h>
|
||||||
|
#include <core/library/track/RetainedTrack.h>
|
||||||
#include <core/db/Connection.h>
|
#include <core/db/Connection.h>
|
||||||
#include <core/db/Statement.h>
|
#include <core/db/Statement.h>
|
||||||
|
|
||||||
@ -50,6 +51,8 @@ using namespace musik::core::db;
|
|||||||
using namespace musik::core::query;
|
using namespace musik::core::query;
|
||||||
using namespace musik::core::library;
|
using namespace musik::core::library;
|
||||||
|
|
||||||
|
using namespace musik::core::sdk;
|
||||||
|
|
||||||
class TrackMetadataQuery : public QueryBase {
|
class TrackMetadataQuery : public QueryBase {
|
||||||
public:
|
public:
|
||||||
TrackMetadataQuery(DBID trackId, LibraryPtr library);
|
TrackMetadataQuery(DBID trackId, LibraryPtr library);
|
||||||
@ -137,6 +140,10 @@ TrackPtr TrackList::Get(size_t index) {
|
|||||||
return query->Result();
|
return query->Result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IRetainedTrack* TrackList::GetRetainedTrack(size_t index) {
|
||||||
|
return new RetainedTrack(this->Get(index));
|
||||||
|
}
|
||||||
|
|
||||||
DBID TrackList::GetId(size_t index) {
|
DBID TrackList::GetId(size_t index) {
|
||||||
return this->ids.at(index);
|
return this->ids.at(index);
|
||||||
}
|
}
|
||||||
|
@ -34,39 +34,45 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <core/sdk/ITrackList.h>
|
||||||
|
#include <core/sdk/ITrackListEditor.h>
|
||||||
|
|
||||||
#include <core/library/track/Track.h>
|
#include <core/library/track/Track.h>
|
||||||
#include <core/library/ILibrary.h>
|
#include <core/library/ILibrary.h>
|
||||||
#include <core/sdk/ITrackListEditor.h>
|
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
namespace musik { namespace core {
|
namespace musik { namespace core {
|
||||||
class TrackList : public musik::core::sdk::ITrackListEditor {
|
class TrackList :
|
||||||
|
public musik::core::sdk::ITrackList,
|
||||||
|
public musik::core::sdk::ITrackListEditor
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
TrackList(LibraryPtr library);
|
TrackList(LibraryPtr library);
|
||||||
virtual ~TrackList();
|
virtual ~TrackList();
|
||||||
|
|
||||||
/* implementation specific */
|
|
||||||
DBID GetId(size_t index);
|
|
||||||
int IndexOf(DBID id);
|
|
||||||
void ClearCache();
|
|
||||||
void Swap(TrackList& list);
|
|
||||||
void CopyFrom(TrackList& from);
|
|
||||||
|
|
||||||
/* ITrackList */
|
/* ITrackList */
|
||||||
size_t Count();
|
virtual size_t Count();
|
||||||
TrackPtr Get(size_t index);
|
virtual musik::core::sdk::IRetainedTrack* GetRetainedTrack(size_t index);
|
||||||
|
virtual DBID GetId(size_t index);
|
||||||
|
virtual int IndexOf(DBID id);
|
||||||
|
|
||||||
/* ITrackListEditor */
|
/* ITrackListEditor */
|
||||||
virtual void Add(const DBID id);
|
virtual void Add(const DBID id);
|
||||||
virtual void Clear();
|
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 Swap(size_t index1, size_t index2);
|
||||||
virtual bool Move(size_t from, size_t to);
|
virtual bool Move(size_t from, size_t to);
|
||||||
virtual bool Delete(size_t index);
|
virtual bool Delete(size_t index);
|
||||||
virtual void Shuffle();
|
virtual void Shuffle();
|
||||||
|
|
||||||
|
/* implementation specific */
|
||||||
|
TrackPtr Get(size_t index);
|
||||||
|
void ClearCache();
|
||||||
|
void Swap(TrackList& list);
|
||||||
|
void CopyFrom(TrackList& from);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::list<DBID> CacheList;
|
typedef std::list<DBID> CacheList;
|
||||||
typedef std::pair<TrackPtr, CacheList::iterator> CacheValue;
|
typedef std::pair<TrackPtr, CacheList::iterator> CacheValue;
|
||||||
|
54
src/core/sdk/ITrackList.h
Normal file
54
src/core/sdk/ITrackList.h
Normal 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user