MIDI2LR 6.1.0.0
MIDI2LR is an application that interfaces MIDI controllers with Lightroom 6+/CC Classic. It processes MIDI input into develop parameter updates and photo actions, and sends MIDI output when parameters are changed for motorized feedback (on controllers that have motorized faders). A listing of available LightRoom commands is in the Wiki. Assistance on the code and design is welcome.
Loading...
Searching...
No Matches
CommandSet Class Reference

#include <CommandSet.h>

Classes

class  Impl
 

Public Member Functions

 CommandSet ()
 
const auto & CommandAbbrevAt (size_t index) const
 
auto CommandAbbrevSize () const noexcept
 
auto CommandLabelAt (size_t index) const
 
size_t CommandTextIndex (const std::string &command) const
 
const auto & GetLanguage () const noexcept
 
const auto & GetMenuEntries () const noexcept
 
const auto & GetMenus () const noexcept
 
const auto & GetRepeats () const noexcept
 
const auto & GetWraps () const noexcept
 

Static Public Member Functions

static const auto & UnassignedTranslated ()
 

Static Public Attributes

static const std::string kUnassigned {"Unassigned"}
 

Private Types

using MenuStringT = juce::String
 

Private Member Functions

const ImplMakeImpl () const
 

Private Attributes

std::vector< std::string > cmd_by_number_ {}
 
std::unordered_map< std::string, size_t > cmd_idx_ {}
 
std::vector< std::string > cmd_label_by_number_ {}
 
const Implm_impl_
 
std::vector< std::vector< MenuStringT > > menu_entries_ {}
 
std::vector< MenuStringTmenus_ {}
 

Friends

class cereal::access
 
struct cereal::detail::Version< CommandSet::Impl >
 

Member Typedef Documentation

◆ MenuStringT

using CommandSet::MenuStringT = juce::String
private

Constructor & Destructor Documentation

◆ CommandSet()

CommandSet::CommandSet ( )
34 : m_impl_(MakeImpl())
35{
36 /* manually insert unmapped at first position */
37 try {
38 rsj::Translate(m_impl_.language_); /* so UnassignedTranslated translated properly */
39 const auto command_count {
40 std::accumulate(m_impl_.allcommands_.begin(), m_impl_.allcommands_.end(), size_t {1},
41 [](size_t sum, const auto& pair) { return sum + pair.second.size(); })};
42 cmd_by_number_.reserve(command_count);
43 cmd_label_by_number_.reserve(command_count);
44 cmd_by_number_.push_back(kUnassigned);
47 size_t idx {1};
48 for (const auto& [cmd_group, cmd_abbrev_label] : m_impl_.allcommands_) {
49 std::vector<MenuStringT> menu_items_temp {};
50 menu_items_temp.reserve(cmd_abbrev_label.size());
51 const auto group_colon {cmd_group + " : "}; /* concatenation optimization */
52 for (const auto& [cmd_abbrev, cmd_label] : cmd_abbrev_label) {
53 cmd_by_number_.push_back(cmd_abbrev);
54 cmd_label_by_number_.push_back(group_colon + cmd_label);
55 cmd_idx_.emplace(cmd_abbrev, idx++);
56 menu_items_temp.emplace_back(cmd_label);
57 }
58 menus_.emplace_back(cmd_group);
59 menu_entries_.push_back(std::move(menu_items_temp));
60 }
61 }
62 catch (const std::exception& e) {
64 throw;
65 }
66}
std::string language_
Definition CommandSet.h:98
std::vector< std::pair< std::string, std::vector< std::pair< std::string, std::string > > > > allcommands_
Definition CommandSet.h:100
static const std::string kUnassigned
Definition CommandSet.h:63
static const auto & UnassignedTranslated()
Definition CommandSet.h:57
std::vector< std::string > cmd_by_number_
Definition CommandSet.h:112
std::vector< std::string > cmd_label_by_number_
Definition CommandSet.h:113
const Impl & m_impl_
Definition CommandSet.h:109
std::unordered_map< std::string, size_t > cmd_idx_
Definition CommandSet.h:110
std::vector< MenuStringT > menus_
Definition CommandSet.h:111
const Impl & MakeImpl() const
Definition CommandSet.cpp:89
std::vector< std::vector< MenuStringT > > menu_entries_
Definition CommandSet.h:114
void Translate(const std::string &lg)
Definition Translate.cpp:35
void ExceptionResponse(gsl::czstring id, gsl::czstring fu, const std::exception &e) noexcept

Member Function Documentation

◆ CommandAbbrevAt()

const auto & CommandSet::CommandAbbrevAt ( size_t  index) const
inline
39 {
40 return cmd_by_number_.at(index);
41 }

◆ CommandAbbrevSize()

auto CommandSet::CommandAbbrevSize ( ) const
inlinenoexcept
43{ return cmd_by_number_.size(); }

◆ CommandLabelAt()

auto CommandSet::CommandLabelAt ( size_t  index) const
inline
45{ return cmd_label_by_number_.at(index); }

◆ CommandTextIndex()

size_t CommandSet::CommandTextIndex ( const std::string &  command) const
102{
103 try {
104 using namespace std::string_literals;
105 if (const auto found {cmd_idx_.find(command)}; found != cmd_idx_.end()) {
106 return found->second;
107 }
108 if (command != "Unmapped"s) { /*Old version of Unassigned*/
109 rsj::Log(fmt::format(FMT_STRING("Command not found in CommandTextIndex: {}."), command));
110 }
111 return 0;
112 }
113 catch (const std::exception& e) {
115 throw;
116 }
117}
void Log(const juce::String &info, const std::source_location &location=std::source_location::current()) noexcept
Definition Misc.cpp:131

◆ GetLanguage()

const auto & CommandSet::GetLanguage ( ) const
inlinenoexcept
47{ return m_impl_.language_; }

◆ GetMenuEntries()

const auto & CommandSet::GetMenuEntries ( ) const
inlinenoexcept
51{ return menu_entries_; }

◆ GetMenus()

const auto & CommandSet::GetMenus ( ) const
inlinenoexcept
49{ return menus_; }

◆ GetRepeats()

const auto & CommandSet::GetRepeats ( ) const
inlinenoexcept
53{ return m_impl_.repeat_messages_; }
std::unordered_map< std::string, std::pair< std::string, std::string > > repeat_messages_
Definition CommandSet.h:101

◆ GetWraps()

const auto & CommandSet::GetWraps ( ) const
inlinenoexcept
55{ return m_impl_.wraps_; }
std::vector< std::string > wraps_
Definition CommandSet.h:102

◆ MakeImpl()

const CommandSet::Impl & CommandSet::MakeImpl ( ) const
private
90{
91 try {
92 static const Impl kImpl;
93 return kImpl;
94 }
95 catch (const std::exception& e) {
97 throw;
98 }
99}

◆ UnassignedTranslated()

static const auto & CommandSet::UnassignedTranslated ( )
inlinestatic
58 {
59 static const auto unassigned {juce::translate("Unassigned").toStdString()};
60 return unassigned;
61 }

Friends And Related Symbol Documentation

◆ cereal::access

friend class cereal::access
friend

◆ cereal::detail::Version< CommandSet::Impl >

friend struct cereal::detail::Version< CommandSet::Impl >
friend

Member Data Documentation

◆ cmd_by_number_

std::vector<std::string> CommandSet::cmd_by_number_ {}
private
112{}; /* use for command_set_.CommandAbbrevAt, .size */

◆ cmd_idx_

std::unordered_map<std::string, size_t> CommandSet::cmd_idx_ {}
private
110{}; /* for CommandTextIndex */

◆ cmd_label_by_number_

std::vector<std::string> CommandSet::cmd_label_by_number_ {}
private
113{};

◆ kUnassigned

const std::string CommandSet::kUnassigned {"Unassigned"}
inlinestatic
63{"Unassigned"};

◆ m_impl_

const Impl& CommandSet::m_impl_
private

◆ menu_entries_

std::vector<std::vector<MenuStringT> > CommandSet::menu_entries_ {}
private
114{}; /* use for commandmenu */

◆ menus_

std::vector<MenuStringT> CommandSet::menus_ {}
private
111{}; /* use for commandmenu */

The documentation for this class was generated from the following files: