summaryrefslogtreecommitdiffstats
path: root/xbmc/settings/SettingsComponent.h
blob: 42bb9a8cc3caf3cb1d3fdad566bf3b5a92770f28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include <memory>

class CAdvancedSettings;
class CProfileManager;
class CSettings;

namespace KODI
{
namespace SUBTITLES
{
class CSubtitlesSettings;
} // namespace SUBTITLES
} // namespace KODI

class CSettingsComponent
{
public:
  CSettingsComponent();
  virtual ~CSettingsComponent();

  /*!
   * @brief Initialize all subcomponents with system default values (loaded from code, system settings files, ...).
   */
  void Initialize();

  /*!
   * @brief Initialize all subcomponents with user values (loaded from user settings files, according to active profile).
   * @return true on success, false otherwise.
   */
  bool Load();

  /*!
   * @brief Deinitialize all subcomponents.
   */
  void Deinitialize();

  /*!
   * @brief Get access to the settings subcomponent.
   * @return the settings subcomponent.
   */
  std::shared_ptr<CSettings> GetSettings();

  /*!
   * @brief Get access to the advanced settings subcomponent.
   * @return the advanced settings subcomponent.
   */
  std::shared_ptr<CAdvancedSettings> GetAdvancedSettings();

  /*!
   * @brief Get access to the subtitles settings subcomponent.
   * @return the subtiltles settings subcomponent.
   */
  std::shared_ptr<KODI::SUBTITLES::CSubtitlesSettings> GetSubtitlesSettings();

  /*!
   * @brief Get access to the profiles manager subcomponent.
   * @return the profiles manager subcomponent.
   */
  std::shared_ptr<CProfileManager> GetProfileManager();

private:
  bool InitDirectoriesLinux(bool bPlatformDirectories);
  bool InitDirectoriesOSX(bool bPlatformDirectories);
  bool InitDirectoriesWin32(bool bPlatformDirectories);
  void CreateUserDirs() const;

  enum class State
  {
    DEINITED,
    INITED,
    LOADED
  };
  State m_state = State::DEINITED;

  std::shared_ptr<CSettings> m_settings;
  std::shared_ptr<CAdvancedSettings> m_advancedSettings;
  std::shared_ptr<KODI::SUBTITLES::CSubtitlesSettings> m_subtitlesSettings;
  std::shared_ptr<CProfileManager> m_profileManager;
};