Audacity 3.2.0
CommandFunctors.h
Go to the documentation of this file.
1//
2// CommandFunctors.h
3// Audacity
4//
5// Created by Paul Licameli on 4/22/16.
6//
7//
8
9#ifndef __AUDACITY_COMMAND_FUNCTORS__
10#define __AUDACITY_COMMAND_FUNCTORS__
11
12class AudacityProject;
13class AudacityApp;
14class CommandContext;
15
16// Forward-declaring this type before including wx/event.h causes strange
17// compilation failures with MSVC.
18// class wxEvtHandler;
19#include <wx/event.h>
20
21// Base class for objects, to whose member functions, the CommandManager will
22// dispatch.
23//
24// It, or a subclass of it, must be the first base class of the object, and the
25// first base class of that base class, etc., for the same reason that
26// wxEvtHandler must be first (that is, the downcast from a pointer to the base
27// to a pointer to the object, must be a vacuous operation).
28//
29// In fact, then, we just make it an alias of wxEvtHandler, in case you really
30// need to inherit from wxEvtHandler for other reasons, and otherwise you
31// couldn't satisfy the requirement for both base classes at once.
32using CommandHandlerObject = wxEvtHandler;
33
34// First of two functions registered with each command: an extractor
35// of the handler object from the AudacityProject, or null
37 std::function< CommandHandlerObject&(AudacityProject &) >;
38
39// Second of two function pointers registered with each command: a pointer
40// to a member function of the handler object, or a pointer to a non-member
41// function when the CommandHandlerFinder is null
43 using MemberFn =
44 void (CommandHandlerObject::*)(const CommandContext &context);
46 void (*)(const CommandContext &context);
47
50 : memberFn{ memberFn } {}
53
56};
57
58#endif
std::function< CommandHandlerObject &(AudacityProject &) > CommandHandlerFinder
wxEvtHandler CommandHandlerObject
AudacityApp is the 'main' class for Audacity.
Definition: AudacityApp.h:42
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
void(*)(const CommandContext &context) NonMemberFn
CommandFunctorPointer(MemberFn memberFn)
CommandFunctorPointer()=default
CommandFunctorPointer(NonMemberFn nonMemberFn)
void(CommandHandlerObject::*)(const CommandContext &context) MemberFn