Audacity
3.2.0
libraries
lib-menus
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
12
class
AudacityProject
;
13
class
AudacityApp
;
14
class
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.
32
using
CommandHandlerObject
= wxEvtHandler;
33
34
// First of two functions registered with each command: an extractor
35
// of the handler object from the AudacityProject, or null
36
using
CommandHandlerFinder
=
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
42
union
CommandFunctorPointer
{
43
using
MemberFn
=
44
void (
CommandHandlerObject
::*)(
const
CommandContext
&context);
45
using
NonMemberFn
=
46
void (*)(
const
CommandContext
&context);
47
48
CommandFunctorPointer
() =
default
;
49
explicit
CommandFunctorPointer
(
MemberFn
memberFn
)
50
:
memberFn
{
memberFn
} {}
51
explicit
CommandFunctorPointer
(
NonMemberFn
nonMemberFn
)
52
:
nonMemberFn
{
nonMemberFn
} {}
53
54
MemberFn
memberFn
;
55
NonMemberFn
nonMemberFn
;
56
};
57
58
#endif
CommandHandlerFinder
std::function< CommandHandlerObject &(AudacityProject &) > CommandHandlerFinder
Definition:
CommandFunctors.h:37
CommandHandlerObject
wxEvtHandler CommandHandlerObject
Definition:
CommandFunctors.h:32
AudacityApp
AudacityApp is the 'main' class for Audacity.
Definition:
AudacityApp.h:42
AudacityProject
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
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition:
CommandContext.h:37
CommandFunctorPointer
Definition:
CommandFunctors.h:42
CommandFunctorPointer::memberFn
MemberFn memberFn
Definition:
CommandFunctors.h:54
CommandFunctorPointer::nonMemberFn
NonMemberFn nonMemberFn
Definition:
CommandFunctors.h:55
CommandFunctorPointer::NonMemberFn
void(*)(const CommandContext &context) NonMemberFn
Definition:
CommandFunctors.h:46
CommandFunctorPointer::CommandFunctorPointer
CommandFunctorPointer(MemberFn memberFn)
Definition:
CommandFunctors.h:49
CommandFunctorPointer::CommandFunctorPointer
CommandFunctorPointer()=default
CommandFunctorPointer::CommandFunctorPointer
CommandFunctorPointer(NonMemberFn nonMemberFn)
Definition:
CommandFunctors.h:51
CommandFunctorPointer::MemberFn
void(CommandHandlerObject::*)(const CommandContext &context) MemberFn
Definition:
CommandFunctors.h:44
Generated by
1.9.3