LCOV - code coverage report
Current view: top level - muse/framework/rcommand/internal - commanddispatcher.h Coverage Total Hit
Test: filtered_coverage.info Lines: 100.0 % 1 1
Test Date: 2026-11-05 04:07:02

            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 "../icommanddispatcher.h"
      22              : 
      23              : namespace muse::rcommand {
      24              : class CommandDispatcher : public ICommandDispatcher
      25              : {
      26              : public:
      27           32 :     CommandDispatcher() = default;
      28              :     ~CommandDispatcher() override;
      29              : 
      30              :     async::Promise<Response> dispatch(const Request& request) override;
      31              :     void onRequest(Commandable* client, const Command& command, const CallBack& callback) override;
      32              :     void onRequest(Commandable* client, const Command& command, const AsyncCallBack& callback) override;
      33              :     void unreg(Commandable* client) override;
      34              : 
      35              :     async::Channel<Command, bool* /*allow dispatch*/> preDispatch() const override;
      36              :     async::Channel<Command> postDispatch() const override;
      37              : 
      38              :     // for utests
      39              :     Response dispatch(const Command& command, const Params& params = {});
      40              :     Response dispatch(const CommandQuery& query);
      41              : 
      42              : private:
      43              : 
      44              :     struct Client
      45              :     {
      46              :         Commandable* client = nullptr;
      47              :         CallBack callback = nullptr;
      48              :         AsyncCallBack asyncCallback = nullptr;
      49              :     };
      50              : 
      51              :     void reg(Commandable* client, const Command& command, const Client& c);
      52              : 
      53              :     std::map<Command, Client> m_clients;
      54              :     async::Channel<Command, bool* /*allow dispatch*/> m_preDispatch;
      55              :     async::Channel<Command> m_postDispatch;
      56              : };
      57              : }
        

Generated by: LCOV version 2.0-1