Merge pull request #3005 from FernetMenta/winrenderer
[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 IncrementUseCount(const CTextureDetails &details);
38
39   /*! \brief Invalidate a previously cached texture
40    Invalidates the texture hash, and sets the texture update time to the current time so that
41    next texture load it will be re-cached.
42    \param url texture path
43    */
44   bool InvalidateCachedTexture(const CStdString &originalURL);
45
46   /*! \brief Get a texture associated with the given path
47    Used for retrieval of previously discovered images to save
48    stat() on the filesystem all the time
49    \param url path that may be associated with a texture
50    \param type type of image to look for
51    \return URL of the texture associated with the given path
52    */
53   CStdString GetTextureForPath(const CStdString &url, const CStdString &type);
54
55   /*! \brief Set a texture associated with the given path
56    Used for setting of previously discovered images to save
57    stat() on the filesystem all the time. Should be used to set
58    the actual image path, not the cached image path (the image will be
59    cached at load time.)
60    \param url path that was used to find the texture
61    \param type type of image to associate
62    \param texture URL of the texture to associate with the path
63    */
64   void SetTextureForPath(const CStdString &url, const CStdString &type, const CStdString &texture);
65
66   /*! \brief Clear a texture associated with the given path
67    \param url path that was used to find the texture
68    \param type type of image to associate
69    \param texture URL of the texture to associate with the path
70    \sa GetTextureForPath, SetTextureForPath
71    */
72   void ClearTextureForPath(const CStdString &url, const CStdString &type);
73
74 protected:
75   /*! \brief retrieve a hash for the given url
76    Computes a hash of the current url to use for lookups in the database
77    \param url url to hash
78    \return a hash for this url
79    */
80   unsigned int GetURLHash(const CStdString &url) const;
81
82   virtual bool CreateTables();
83   virtual bool UpdateOldVersion(int version);
84   virtual int GetMinVersion() const { return 13; };
85   const char *GetBaseDBName() const { return "Textures"; };
86 };