Skip to content

Commit

Permalink
FileItemList: convert CacheType to enum class
Browse files Browse the repository at this point in the history
  • Loading branch information
notspiff committed Dec 17, 2024
1 parent 6cdcb5b commit 8759aad
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions xbmc/FileItemList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions xbmc/FileItemList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/AddonsDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/MusicDatabaseDirectory/DirectoryNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion xbmc/filesystem/PluginDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/UPnPDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/filesystem/PVRGUIDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down

0 comments on commit 8759aad

Please sign in to comment.