Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 : #ifndef MUSE_GLOBAL_GLOBALMODULE_H
23 : #define MUSE_GLOBAL_GLOBALMODULE_H
24 :
25 : #include <memory>
26 : #include <optional>
27 :
28 : #include "logger.h"
29 :
30 : #include "modularity/imodulesetup.h"
31 : #include "modularity/ioc.h"
32 : #include "io/ifilesystem.h"
33 : #include "ticker.h"
34 :
35 : namespace muse {
36 : class SystemInfo;
37 : class GlobalConfiguration;
38 : class BaseApplication;
39 : class IApplicationEventController;
40 : class ITickerProvider;
41 : class GlobalModule : public modularity::IModuleSetup
42 : {
43 : GlobalInject<io::IFileSystem> fileSystem;
44 :
45 : public:
46 :
47 : GlobalModule();
48 :
49 : std::string moduleName() const override;
50 : void registerExports() override;
51 : void registerApi() override;
52 : void onPreInit(const IApplication::RunMode& mode) override;
53 : void onInit(const IApplication::RunMode& mode) override;
54 : void onDeinit() override;
55 :
56 : void setLoggerLevel(const muse::logger::Level& level);
57 :
58 : modularity::IContextSetup* newContext(const muse::modularity::ContextPtr& ctx) const override;
59 :
60 : private:
61 : std::shared_ptr<GlobalConfiguration> m_configuration;
62 : std::shared_ptr<SystemInfo> m_systemInfo;
63 : std::shared_ptr<ITickerProvider> m_tickerProvider;
64 : std::shared_ptr<IApplicationEventController> m_eventController;
65 : Ticker m_asyncTicker;
66 :
67 : std::optional<muse::logger::Level> m_loggerLevel;
68 :
69 : bool m_endTimePeriod = false;
70 : };
71 :
72 : class GlobalContext : public modularity::IContextSetup
73 : {
74 : public:
75 0 : GlobalContext(const muse::modularity::ContextPtr& ctx)
76 0 : : modularity::IContextSetup(ctx) {}
77 :
78 : void registerExports() override;
79 : };
80 : }
81 :
82 : #endif // MUSE_GLOBAL_GLOBALMODULE_H
|