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 :
23 : #ifndef MUSE_MPE_ARTICULATIONPROFILESREPOSITORY_H
24 : #define MUSE_MPE_ARTICULATIONPROFILESREPOSITORY_H
25 :
26 : #include "modularity/ioc.h"
27 : #include "io/ifilesystem.h"
28 : #include "async/asyncable.h"
29 :
30 : #include "iarticulationprofilesrepository.h"
31 :
32 : namespace muse::mpe {
33 : class ArticulationProfilesRepository : public IArticulationProfilesRepository, public Contextable, public async::Asyncable
34 : {
35 : GlobalInject<io::IFileSystem> fileSystem;
36 :
37 : public:
38 0 : ArticulationProfilesRepository(const modularity::ContextPtr& iocCtx)
39 0 : : Contextable(iocCtx) {}
40 :
41 : ArticulationsProfilePtr createNew() const override;
42 : ArticulationsProfilePtr defaultProfile(const ArticulationFamily family) const override;
43 : ArticulationsProfilePtr loadProfile(const io::path_t& path) const override;
44 : void saveProfile(const io::path_t& path, const ArticulationsProfilePtr profilePtr) override;
45 : async::Channel<io::path_t> profileChanged() const override;
46 :
47 : private:
48 : std::vector<ArticulationFamily> supportedFamiliesFromJson(const QJsonArray& array) const;
49 : QJsonArray supportedFamiliesToJson(const std::vector<ArticulationFamily>& families) const;
50 :
51 : ArticulationPattern patternsScopeFromJson(const QJsonArray& array) const;
52 : QJsonArray patternsScopeToJson(const ArticulationPattern& scope) const;
53 :
54 : ArrangementPattern arrangementPatternFromJson(const QJsonObject& obj) const;
55 : QJsonObject arrangementPatternToJson(const ArrangementPattern& pattern) const;
56 :
57 : PitchPattern pitchPatternFromJson(const QJsonObject& obj) const;
58 : QJsonObject pitchPatternToJson(const PitchPattern& pattern) const;
59 :
60 : ExpressionPattern expressionPatternFromJson(const QJsonObject& obj) const;
61 : QJsonObject expressionPatternToJson(const ExpressionPattern& pattern) const;
62 :
63 : mutable std::unordered_map<ArticulationFamily, ArticulationsProfilePtr> m_defaultProfiles;
64 :
65 : async::Channel<io::path_t> m_profileChanged;
66 : };
67 : }
68 :
69 : #endif // MUSE_MPE_ARTICULATIONPROFILESREPOSITORY_H
|