2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
23 #include "dbwrappers/Database.h"
24 #include "TextureCacheJob.h"
26 class CTextureDatabase : public CDatabase
30 virtual ~CTextureDatabase();
33 bool GetCachedTexture(const CStdString &originalURL, CTextureDetails &details);
34 bool AddCachedTexture(const CStdString &originalURL, const CTextureDetails &details);
35 bool SetCachedTextureValid(const CStdString &originalURL, bool updateable);
36 bool ClearCachedTexture(const CStdString &originalURL, CStdString &cacheFile);
37 bool ClearCachedTexture(int textureID, CStdString &cacheFile);
38 bool IncrementUseCount(const CTextureDetails &details);
40 /*! \brief Invalidate a previously cached texture
41 Invalidates the texture hash, and sets the texture update time to the current time so that
42 next texture load it will be re-cached.
43 \param url texture path
45 bool InvalidateCachedTexture(const CStdString &originalURL);
47 /*! \brief Get a texture associated with the given path
48 Used for retrieval of previously discovered images to save
49 stat() on the filesystem all the time
50 \param url path that may be associated with a texture
51 \param type type of image to look for
52 \return URL of the texture associated with the given path
54 CStdString GetTextureForPath(const CStdString &url, const CStdString &type);
56 /*! \brief Set a texture associated with the given path
57 Used for setting of previously discovered images to save
58 stat() on the filesystem all the time. Should be used to set
59 the actual image path, not the cached image path (the image will be
61 \param url path that was used to find the texture
62 \param type type of image to associate
63 \param texture URL of the texture to associate with the path
65 void SetTextureForPath(const CStdString &url, const CStdString &type, const CStdString &texture);
67 /*! \brief Clear a texture associated with the given path
68 \param url path that was used to find the texture
69 \param type type of image to associate
70 \param texture URL of the texture to associate with the path
71 \sa GetTextureForPath, SetTextureForPath
73 void ClearTextureForPath(const CStdString &url, const CStdString &type);
76 /*! \brief retrieve a hash for the given url
77 Computes a hash of the current url to use for lookups in the database
78 \param url url to hash
79 \return a hash for this url
81 unsigned int GetURLHash(const CStdString &url) const;
83 virtual bool CreateTables();
84 virtual bool UpdateOldVersion(int version);
85 virtual int GetMinVersion() const { return 13; };
86 const char *GetBaseDBName() const { return "Textures"; };