From 462ac04448e08d32e1b82aeab450069330b0bc35 Mon Sep 17 00:00:00 2001 From: casey langen Date: Sat, 21 Jan 2017 17:24:32 -0800 Subject: [PATCH] Added ITrackList interface to sdk. We'll use this for plugins in the near future. --- src/core/core.vcxproj | 1 + src/core/core.vcxproj.filters | 3 ++ src/core/library/track/TrackList.cpp | 7 ++++ src/core/library/track/TrackList.h | 30 +++++++++------- src/core/sdk/ITrackList.h | 54 ++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 src/core/sdk/ITrackList.h diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index 6fd65a289..539b00b86 100755 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj @@ -180,6 +180,7 @@ + diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index 3041da0d7..9cd43f283 100755 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters @@ -327,5 +327,8 @@ src\sdk + + src\sdk + \ No newline at end of file diff --git a/src/core/library/track/TrackList.cpp b/src/core/library/track/TrackList.cpp index 7bebed726..b3c19ecca 100755 --- a/src/core/library/track/TrackList.cpp +++ b/src/core/library/track/TrackList.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -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); } diff --git a/src/core/library/track/TrackList.h b/src/core/library/track/TrackList.h index afb2c03ee..067ec0fd9 100755 --- a/src/core/library/track/TrackList.h +++ b/src/core/library/track/TrackList.h @@ -34,39 +34,45 @@ #pragma once +#include +#include + #include #include -#include #include #include 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 CacheList; typedef std::pair CacheValue; diff --git a/src/core/sdk/ITrackList.h b/src/core/sdk/ITrackList.h new file mode 100644 index 000000000..4fd77058f --- /dev/null +++ b/src/core/sdk/ITrackList.h @@ -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; + }; + + } + } +} +