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

            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              : #ifndef MUSE_ACTIONS_ACTIONSDISPATCHER_H
      23              : #define MUSE_ACTIONS_ACTIONSDISPATCHER_H
      24              : 
      25              : #include <map>
      26              : 
      27              : #include "../iactionsdispatcher.h"
      28              : #include "async/asyncable.h"
      29              : #include "async/channel.h"
      30              : 
      31              : #include "global/modularity/ioc.h"
      32              : #include "rcommand/icommanddispatcher.h"
      33              : 
      34              : namespace muse::actions {
      35              : class ActionsDispatcher : public IActionsDispatcher, public async::Asyncable, public Contextable
      36              : {
      37              :     muse::ContextInject<muse::rcommand::ICommandDispatcher> commandDispatcher = { this };
      38              : 
      39              : public:
      40           32 :     ActionsDispatcher(const muse::modularity::ContextPtr& iocCtx)
      41           32 :         : Contextable(iocCtx) {}
      42              :     ~ActionsDispatcher() override;
      43              : 
      44              :     void dispatch(const ActionCode& actionCode) override;
      45              :     void dispatch(const ActionCode& actionCode, const ActionData& data) override;
      46              :     void dispatch(const ActionQuery& actionQuery) override;
      47              : 
      48              :     async::Channel<ActionCode> preDispatch() const override;
      49              :     async::Channel<ActionCode> postDispatch() const override;
      50              :     async::Channel<ActionCode> notRegistered() const override;
      51              : 
      52              :     void unReg(Actionable* client) override;
      53              :     void reg(Actionable* client, const ActionCode& actionCode, const ActionCallBackWithNameAndData& call) override;
      54              :     void reg(Actionable* client, const ActionQuery& actionQuery, const ActionCallBackWithQuery& call) override;
      55              :     bool isReg(Actionable* client) const override;
      56              :     ActionCodeList actionList() const override;
      57              : 
      58              : private:
      59              : 
      60              :     using CallBacks = std::map<ActionCode, ActionCallBackWithNameAndData>;
      61              :     using Clients = std::map<Actionable*, CallBacks>;
      62              : 
      63              :     void doDispatch(const Clients& clients, const ActionCode& actionCode, const ActionData& data);
      64              : 
      65              :     void dump() const; // for debug
      66              : 
      67              :     std::map<ActionCode, Clients > m_clients;
      68              : 
      69              :     async::Channel<ActionCode> m_preDispatch;
      70              :     async::Channel<ActionCode> m_postDispatch;
      71              :     async::Channel<ActionCode> m_notRegistered;
      72              : };
      73              : }
      74              : 
      75              : #endif // MUSE_ACTIONS_ACTIONSDISPATCHER_H
        

Generated by: LCOV version 2.0-1