1 /* 2 * Copyright (C) 2005-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9 #pragma once 10 11 #include "utils/UrlOptions.h" 12 13 class CFileItemList; 14 15 namespace XFILE 16 { 17 namespace MUSICDATABASEDIRECTORY 18 { 19 class CQueryParams; 20 21 typedef enum _NODE_TYPE 22 { 23 NODE_TYPE_NONE=0, 24 NODE_TYPE_ROOT, 25 NODE_TYPE_OVERVIEW, 26 NODE_TYPE_TOP100, 27 NODE_TYPE_ROLE, 28 NODE_TYPE_SOURCE, 29 NODE_TYPE_GENRE, 30 NODE_TYPE_ARTIST, 31 NODE_TYPE_ALBUM, 32 NODE_TYPE_ALBUM_RECENTLY_ADDED, 33 NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS, 34 NODE_TYPE_ALBUM_RECENTLY_PLAYED, 35 NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS, 36 NODE_TYPE_ALBUM_TOP100, 37 NODE_TYPE_ALBUM_TOP100_SONGS, 38 NODE_TYPE_SONG, 39 NODE_TYPE_SONG_TOP100, 40 NODE_TYPE_YEAR, 41 NODE_TYPE_SINGLES, 42 NODE_TYPE_DISC, 43 } NODE_TYPE; 44 45 typedef struct { 46 NODE_TYPE node; 47 std::string id; 48 int label; 49 } Node; 50 51 class CDirectoryNode 52 { 53 public: 54 static CDirectoryNode* ParseURL(const std::string& strPath); 55 static void GetDatabaseInfo(const std::string& strPath, CQueryParams& params); 56 static bool GetNodeInfo(const std::string& strPath, NODE_TYPE& type, NODE_TYPE& childtype, CQueryParams& params); 57 virtual ~CDirectoryNode(); 58 59 NODE_TYPE GetType() const; 60 61 bool GetChilds(CFileItemList& items); 62 virtual NODE_TYPE GetChildType() const; 63 virtual std::string GetLocalizedName() const; 64 65 CDirectoryNode* GetParent() const; 66 virtual bool CanCache() const; 67 68 std::string BuildPath() const; 69 70 protected: 71 CDirectoryNode(NODE_TYPE Type, const std::string& strName, CDirectoryNode* pParent); 72 static CDirectoryNode* CreateNode(NODE_TYPE Type, const std::string& strName, CDirectoryNode* pParent); 73 74 void AddOptions(const std::string &options); 75 void CollectQueryParams(CQueryParams& params) const; 76 77 const std::string& GetName() const; 78 int GetID() const; 79 void RemoveParent(); 80 81 virtual bool GetContent(CFileItemList& items) const; 82 83 private: 84 NODE_TYPE m_Type; 85 std::string m_strName; 86 CDirectoryNode* m_pParent; 87 CUrlOptions m_options; 88 }; 89 } 90 } 91 92 93