[lang] update of core language files
[vuplus_xbmc] / xbmc / DatabaseManager.h
1 /*
2  *      Copyright (C) 2012-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 <map>
24 #include <string>
25 #include "threads/CriticalSection.h"
26 #include "threads/Event.h"
27
28 class CDatabase;
29 class DatabaseSettings;
30
31 /*!
32  \ingroup database
33  \brief Database manager class for handling database updating
34
35  Ensures that databases used in XBMC are up to date, and if a database can't be
36  opened, ensures we don't continuously try it.
37
38  */
39 class CDatabaseManager
40 {
41 public:
42   /*!
43    \brief The only way through which the global instance of the CDatabaseManager should be accessed.
44    \return the global instance.
45    */
46   static CDatabaseManager &Get();
47
48   /*! \brief Initalize the database manager
49    Checks that all databases are up to date, otherwise updates them.
50    */
51   void Initialize(bool addonsOnly = false);
52
53   /*! \brief Deinitialize the database manager
54    */
55   void Deinitialize();
56
57   /*! \brief Check whether we can open a database.
58
59    Checks whether the database has been updated correctly, if so returns true.
60    If the database update failed, returns false immediately.
61    If the database update is in progress, returns false.
62
63    \param name the name of the database to check.
64    \return true if the database can be opened, false otherwise.
65    */ 
66   bool CanOpen(const std::string &name);
67
68 private:
69   // private construction, and no assignements; use the provided singleton methods
70   CDatabaseManager();
71   CDatabaseManager(const CDatabaseManager&);
72   CDatabaseManager const& operator=(CDatabaseManager const&);
73   virtual ~CDatabaseManager();
74
75   enum DB_STATUS { DB_CLOSED, DB_UPDATING, DB_READY, DB_FAILED };
76   void UpdateStatus(const std::string &name, DB_STATUS status);
77   void UpdateDatabase(CDatabase &db, DatabaseSettings *settings = NULL);
78
79   CCriticalSection            m_section;     ///< Critical section protecting m_dbStatus.
80   std::map<std::string, DB_STATUS> m_dbStatus;    ///< Our database status map.
81 };