Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore/Audacity CLA applies
4 : *
5 : * Copyright (C) 2026 MuseScore/Audacity and others
6 : *
7 : * This program is free software: you can redistribute it and/or modify
8 : * it under the terms of the GNU General Public License version 3 as
9 : * published by the Free Software Foundation.
10 : *
11 : * This program is distributed in the hope that it will be useful,
12 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : * GNU General Public License for more details.
15 : *
16 : * You should have received a copy of the GNU General Public License
17 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 : */
19 : #pragma once
20 :
21 : #include <map>
22 : #include <string>
23 :
24 : #include "global/async/asyncable.h"
25 :
26 : #include "../icommandsregister.h"
27 :
28 : namespace muse::rcommand {
29 : class CommandsRegister : public ICommandsRegister, public async::Asyncable
30 : {
31 : public:
32 4 : CommandsRegister() = default;
33 :
34 : void reg(const IModuleCommandsRegisterPtr& module) override;
35 : void unreg(const IModuleCommandsRegisterPtr& module) override;
36 : IModuleCommandsRegisterPtr moduleRegister(const std::string& moduleName) const override;
37 :
38 : std::vector<CommandInfo> commandInfoList() const override;
39 : const CommandInfo& commandInfo(const Command& command) const override;
40 : async::Notification commandInfoListChanged() const override;
41 :
42 : const std::string& commandModuleName(const Command& command) const override;
43 :
44 : private:
45 : std::map<std::string, IModuleCommandsRegisterPtr> m_modules;
46 :
47 : std::map<Command, std::string> m_commandModuleNames;
48 : async::Notification m_commandInfoListChanged;
49 : };
50 : }
|