Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2023 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 :
23 : #include "braillemodule.h"
24 :
25 : #include "modularity/ioc.h"
26 : #include "project/inotationwritersregister.h"
27 :
28 : #include "internal/brailleconfiguration.h"
29 : #include "internal/brailleconverter.h"
30 : #include "internal/notationbraille.h"
31 : #include "internal/braillewriter.h"
32 :
33 : #include "inotationbraille.h"
34 :
35 : using namespace muse;
36 : using namespace mu::braille;
37 : using namespace mu::engraving;
38 : using namespace mu::notation;
39 : using namespace mu::project;
40 :
41 : static const std::string mname("braille");
42 :
43 0 : std::string BrailleModule::moduleName() const
44 : {
45 0 : return mname;
46 : }
47 :
48 0 : void BrailleModule::registerExports()
49 : {
50 0 : m_brailleConfiguration = std::make_shared<BrailleConfiguration>();
51 :
52 0 : globalIoc()->registerExport<IBrailleConfiguration>(mname, m_brailleConfiguration);
53 0 : }
54 :
55 0 : void BrailleModule::resolveImports()
56 : {
57 0 : auto writers = globalIoc()->resolve<INotationWritersRegister>(mname);
58 0 : if (writers) {
59 0 : writers->reg({ "brf" }, std::make_shared<BrailleWriter>());
60 : }
61 0 : }
62 :
63 0 : void BrailleModule::onInit(const IApplication::RunMode&)
64 : {
65 0 : m_brailleConfiguration->init();
66 0 : }
67 :
68 0 : muse::modularity::IContextSetup* BrailleModule::newContext(const muse::modularity::ContextPtr& ctx) const
69 : {
70 0 : return new BrailleModuleContext(ctx);
71 : }
72 :
73 : // Context
74 :
75 0 : void BrailleModuleContext::registerExports()
76 : {
77 0 : m_brailleConverter = std::make_shared<BrailleConverter>();
78 0 : m_notationBraille = std::make_shared<NotationBraille>(iocContext());
79 :
80 0 : ioc()->registerExport<IBrailleConverter>(mname, m_brailleConverter);
81 0 : ioc()->registerExport<INotationBraille>(mname, m_notationBraille);
82 0 : }
83 :
84 0 : void BrailleModuleContext::onInit(const muse::IApplication::RunMode&)
85 : {
86 0 : m_notationBraille->init();
87 0 : }
|