xbmc
DatabaseManager.h
1 /*
2  * Copyright (C) 2012-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "threads/CriticalSection.h"
12 
13 #include <atomic>
14 #include <map>
15 #include <string>
16 
17 class CDatabase;
18 class DatabaseSettings;
19 
29 {
30 public:
32  CDatabaseManager(const CDatabaseManager&) = delete;
33  CDatabaseManager const& operator=(CDatabaseManager const&) = delete;
35 
39  void Initialize();
40 
50  bool CanOpen(const std::string &name);
51 
52  bool IsUpgrading() const { return m_bIsUpgrading; }
53 
54 private:
55  std::atomic<bool> m_bIsUpgrading;
56 
57  enum DB_STATUS { DB_CLOSED, DB_UPDATING, DB_READY, DB_FAILED };
58  void UpdateStatus(const std::string &name, DB_STATUS status);
59  void UpdateDatabase(CDatabase &db, DatabaseSettings *settings = NULL);
60  bool Update(CDatabase &db, const DatabaseSettings &settings);
61  bool UpdateVersion(CDatabase &db, const std::string &dbName);
62 
63  CCriticalSection m_section;
64  std::map<std::string, DB_STATUS> m_dbStatus;
65 };
bool CanOpen(const std::string &name)
Check whether we can open a database.
Definition: DatabaseManager.cpp:65
Database manager class for handling database updating.
Definition: DatabaseManager.h:28
Definition: AdvancedSettings.h:38
Definition: Database.h:26
Definition: settings.py:1
void Initialize()
Initialize the database manager Checks that all databases are up to date, otherwise updates them...
Definition: DatabaseManager.cpp:37