Audacity 3.2.0
CommandFlag.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5CommandFlag.cpp
6
7Paul Licameli split from Menus.cpp
8
9**********************************************************************/
10
11#include "CommandFlag.h"
12
13namespace {
15{
16 static ReservedCommandFlag::Predicates thePredicates;
17 return thePredicates;
18}
19
20std::vector< CommandFlagOptions > &sOptions()
21{
22 static std::vector< CommandFlagOptions > theOptions;
23 return theOptions;
24}
25}
26
28{
29 return sPredicates();
30}
31
32const std::vector< CommandFlagOptions > &ReservedCommandFlag::Options()
33{
34 return sOptions();
35}
36
38 const Predicate &predicate, const CommandFlagOptions &options )
39{
40 static size_t sNextReservedFlag = 0;
41 // This will throw std::out_of_range if the constant NCommandFlags is too
42 // small
43 set( sNextReservedFlag++ );
44 sPredicates().emplace_back( predicate );
45 sOptions().emplace_back( options );
46}
47
48namespace {
50{
51 static MenuItemEnablers enablers;
52 return enablers;
53}
54}
55
57{
58 return sEnablers();
59}
60
62 const MenuItemEnabler &enabler )
63{
64 sEnablers().emplace_back( enabler );
65}
std::vector< MenuItemEnabler > MenuItemEnablers
Definition: CommandFlag.h:122
#define set(f, v)
static const Predicates & RegisteredPredicates()
Definition: CommandFlag.cpp:27
std::function< bool(const AudacityProject &) > Predicate
Definition: CommandFlag.h:90
static const std::vector< CommandFlagOptions > & Options()
Definition: CommandFlag.cpp:32
std::vector< Predicate > Predicates
Definition: CommandFlag.h:91
ReservedCommandFlag(const Predicate &predicate, const CommandFlagOptions &options={})
Definition: CommandFlag.cpp:37
std::vector< CommandFlagOptions > & sOptions()
Definition: CommandFlag.cpp:20
ReservedCommandFlag::Predicates & sPredicates()
Definition: CommandFlag.cpp:14
RegisteredMenuItemEnabler(const MenuItemEnabler &enabler)
Definition: CommandFlag.cpp:61
static const MenuItemEnablers & Enablers()
Definition: CommandFlag.cpp:56