[textures] adds ClearCachedImage() to clear a texture by id
[vuplus_xbmc] / xbmc / TextureDatabase.h
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
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)
8  *  any later version.
9  *
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.
14  *
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/>.
18  *
19  */
20
21 #pragma once
22
23 #include "dbwrappers/Database.h"
24 #include "TextureCacheJob.h"
25
26 class CTextureDatabase : public CDatabase
27 {
28 public:
29   CTextureDatabase();
30   virtual ~CTextureDatabase();
31   virtual bool Open();
32
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);
39
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
44    */
45   bool InvalidateCachedTexture(const CStdString &originalURL);
46
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
53    */
54   CStdString GetTextureForPath(const CStdString &url, const CStdString &type);
55
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
60    cached at load time.)
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
64    */
65   void SetTextureForPath(const CStdString &url, const CStdString &type, const CStdString &texture);
66
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
72    */
73   void ClearTextureForPath(const CStdString &url, const CStdString &type);
74
75 protected:
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
80    */
81   unsigned int GetURLHash(const CStdString &url) const;
82
83   virtual bool CreateTables();
84   virtual bool UpdateOldVersion(int version);
85   virtual int GetMinVersion() const { return 13; };
86   const char *GetBaseDBName() const { return "Textures"; };
87 };