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 :
23 : #include "../icommandsstate.h"
24 : #include "global/async/asyncable.h"
25 : #include "global/modularity/ioc.h"
26 : #include "../icommandsregister.h"
27 :
28 : namespace muse::rcommand {
29 : class CommandsState : public ICommandsState, public async::Asyncable
30 : {
31 : GlobalInject<ICommandsRegister> commandsRegister;
32 :
33 : public:
34 3 : CommandsState() = default;
35 :
36 : void reg(const IModuleCommandsStatePtr& module) override;
37 : void unreg(const IModuleCommandsStatePtr& module) override;
38 :
39 : CommandState commandState(const Command& command) const override;
40 : async::Channel<Command, CommandState> commandStateChanged() const override;
41 :
42 : private:
43 :
44 : std::map<std::string, IModuleCommandsStatePtr> m_modules;
45 : async::Channel<Command, CommandState> m_commandStateChanged;
46 :
47 : mutable std::map<Command, CommandState> m_cache;
48 : };
49 : }
|