From 8759aadbb5ccae8300f1c35b430056c43eaadd48 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 10 Dec 2024 08:10:29 +0100 Subject: [PATCH] FileItemList: convert CacheType to enum class --- xbmc/FileItemList.cpp | 4 ++-- xbmc/FileItemList.h | 16 ++++++++-------- xbmc/filesystem/AddonsDirectory.cpp | 2 +- .../MusicDatabaseDirectory/DirectoryNode.cpp | 2 +- xbmc/filesystem/PluginDirectory.cpp | 3 ++- xbmc/filesystem/UPnPDirectory.cpp | 2 +- .../VideoDatabaseDirectory/DirectoryNode.cpp | 2 +- xbmc/pvr/filesystem/PVRGUIDirectory.cpp | 2 +- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/xbmc/FileItemList.cpp b/xbmc/FileItemList.cpp index 5f9bfbb8dd646..7580549d1f881 100644 --- a/xbmc/FileItemList.cpp +++ b/xbmc/FileItemList.cpp @@ -129,7 +129,7 @@ void CFileItemList::Clear() m_sortDescription.sortOrder = SortOrderNone; m_sortDescription.sortAttributes = SortAttributeNone; m_sortIgnoreFolders = false; - m_cacheToDisc = CACHE_IF_SLOW; + m_cacheToDisc = CacheType::IF_SLOW; m_sortDetails.clear(); m_replaceListing = false; m_content.clear(); @@ -505,7 +505,7 @@ void CFileItemList::Archive(CArchive& ar) m_sortDescription.sortAttributes = (SortAttribute)tempint; ar >> m_sortIgnoreFolders; ar >> tempint; - m_cacheToDisc = CACHE_TYPE(tempint); + m_cacheToDisc = CacheType(tempint); unsigned int detailSize = 0; ar >> detailSize; diff --git a/xbmc/FileItemList.h b/xbmc/FileItemList.h index 5fd82e79d7d67..eaf345a4d8571 100644 --- a/xbmc/FileItemList.h +++ b/xbmc/FileItemList.h @@ -22,11 +22,11 @@ class CFileItemList : public CFileItem { public: - enum CACHE_TYPE + enum class CacheType { - CACHE_NEVER = 0, - CACHE_IF_SLOW, - CACHE_ALWAYS + NEVER = 0, + IF_SLOW, + ALWAYS }; CFileItemList(); @@ -110,9 +110,9 @@ class CFileItemList : public CFileItem \sa Load,RemoveDiscCache */ bool Save(int windowID = 0); - void SetCacheToDisc(CACHE_TYPE cacheToDisc) { m_cacheToDisc = cacheToDisc; } - bool CacheToDiscAlways() const { return m_cacheToDisc == CACHE_ALWAYS; } - bool CacheToDiscIfSlow() const { return m_cacheToDisc == CACHE_IF_SLOW; } + void SetCacheToDisc(CacheType cacheToDisc) { m_cacheToDisc = cacheToDisc; } + bool CacheToDiscAlways() const { return m_cacheToDisc == CacheType::ALWAYS; } + bool CacheToDiscIfSlow() const { return m_cacheToDisc == CacheType::IF_SLOW; } /*! \brief remove a previously cached CFileItemList from the cache The file list may be cached based on which window we're viewing in, as different @@ -196,7 +196,7 @@ class CFileItemList : public CFileItem bool m_fastLookup = false; SortDescription m_sortDescription; bool m_sortIgnoreFolders = false; - CACHE_TYPE m_cacheToDisc = CACHE_IF_SLOW; + CacheType m_cacheToDisc = CacheType::IF_SLOW; bool m_replaceListing = false; std::string m_content; diff --git a/xbmc/filesystem/AddonsDirectory.cpp b/xbmc/filesystem/AddonsDirectory.cpp index aba97cae08458..a5a942aba4607 100644 --- a/xbmc/filesystem/AddonsDirectory.cpp +++ b/xbmc/filesystem/AddonsDirectory.cpp @@ -665,7 +665,7 @@ bool CAddonsDirectory::GetDirectory(const CURL& url, CFileItemList &items) const std::string& endpoint = path.GetHostName(); items.ClearItems(); items.ClearProperties(); - items.SetCacheToDisc(CFileItemList::CACHE_NEVER); + items.SetCacheToDisc(CFileItemList::CacheType::NEVER); items.SetPath(path.Get()); if (endpoint.empty()) diff --git a/xbmc/filesystem/MusicDatabaseDirectory/DirectoryNode.cpp b/xbmc/filesystem/MusicDatabaseDirectory/DirectoryNode.cpp index 30ada19ffd36c..2e00bee2be857 100644 --- a/xbmc/filesystem/MusicDatabaseDirectory/DirectoryNode.cpp +++ b/xbmc/filesystem/MusicDatabaseDirectory/DirectoryNode.cpp @@ -267,7 +267,7 @@ bool CDirectoryNode::GetChilds(CFileItemList& items) if (bSuccess) { if (CanCache()) - items.SetCacheToDisc(CFileItemList::CACHE_ALWAYS); + items.SetCacheToDisc(CFileItemList::CacheType::ALWAYS); } else items.Clear(); diff --git a/xbmc/filesystem/PluginDirectory.cpp b/xbmc/filesystem/PluginDirectory.cpp index 4269fa42364d4..b64085e523e80 100644 --- a/xbmc/filesystem/PluginDirectory.cpp +++ b/xbmc/filesystem/PluginDirectory.cpp @@ -201,7 +201,8 @@ void CPluginDirectory::EndOfDirectory(int handle, bool success, bool replaceList return; // set cache to disc - dir->m_listItems->SetCacheToDisc(cacheToDisc ? CFileItemList::CACHE_IF_SLOW : CFileItemList::CACHE_NEVER); + dir->m_listItems->SetCacheToDisc(cacheToDisc ? CFileItemList::CacheType::IF_SLOW + : CFileItemList::CacheType::NEVER); dir->m_success = success; dir->m_listItems->SetReplaceListing(replaceListing); diff --git a/xbmc/filesystem/UPnPDirectory.cpp b/xbmc/filesystem/UPnPDirectory.cpp index 2b2af57598a17..ce24b036ca4e5 100644 --- a/xbmc/filesystem/UPnPDirectory.cpp +++ b/xbmc/filesystem/UPnPDirectory.cpp @@ -187,7 +187,7 @@ CUPnPDirectory::GetDirectory(const CURL& url, CFileItemList &items) CUPnP* upnp = CUPnP::GetInstance(); /* upnp should never be cached, it has internal cache */ - items.SetCacheToDisc(CFileItemList::CACHE_NEVER); + items.SetCacheToDisc(CFileItemList::CacheType::NEVER); // We accept upnp://devuuid/[item_id/] NPT_String path = url.Get().c_str(); diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.cpp index 1919b27d6af31..22f21cda0479a 100644 --- a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.cpp +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.cpp @@ -256,7 +256,7 @@ bool CDirectoryNode::GetChilds(CFileItemList& items) if (bSuccess) { if (CanCache()) - items.SetCacheToDisc(CFileItemList::CACHE_ALWAYS); + items.SetCacheToDisc(CFileItemList::CacheType::ALWAYS); } else items.Clear(); diff --git a/xbmc/pvr/filesystem/PVRGUIDirectory.cpp b/xbmc/pvr/filesystem/PVRGUIDirectory.cpp index 1fb5bce119cda..9b354889c4270 100644 --- a/xbmc/pvr/filesystem/PVRGUIDirectory.cpp +++ b/xbmc/pvr/filesystem/PVRGUIDirectory.cpp @@ -167,7 +167,7 @@ bool CPVRGUIDirectory::GetDirectory(CFileItemList& results) const std::string fileName = m_url.GetFileName(); URIUtils::RemoveSlashAtEnd(fileName); - results.SetCacheToDisc(CFileItemList::CACHE_NEVER); + results.SetCacheToDisc(CFileItemList::CacheType::NEVER); if (fileName.empty()) {