MIDI2LR 6.2.0.1
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) {
63 rsj::ExceptionResponse(e, std::source_location::current());
64 throw;
65 }
66}
std::string language_
Definition CommandSet.h:105
std::vector< std::pair< std::string, std::vector< std::pair< std::string, std::string > > > > allcommands_
Definition CommandSet.h:107
static const std::string kUnassigned
Definition CommandSet.h:70
static const auto & UnassignedTranslated()
Definition CommandSet.h:64
std::vector< std::string > cmd_by_number_
Definition CommandSet.h:119
std::vector< std::string > cmd_label_by_number_
Definition CommandSet.h:120
const Impl & m_impl_
Definition CommandSet.h:116
std::unordered_map< std::string, size_t > cmd_idx_
Definition CommandSet.h:117
std::vector< MenuStringT > menus_
Definition CommandSet.h:118
const Impl & MakeImpl() const
Definition CommandSet.cpp:90
std::vector< std::vector< MenuStringT > > menu_entries_
Definition CommandSet.h:121
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
46 {
47 return cmd_by_number_.at(index);
48 }

◆ CommandAbbrevSize()

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

◆ CommandLabelAt()

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

◆ CommandTextIndex()

size_t CommandSet::CommandTextIndex ( const std::string &  command) const
inline
38 {
39 if (const auto found {cmd_idx_.find(command)}; found != cmd_idx_.end()) {
40 return found->second;
41 }
42 return 0;
43 }

◆ GetLanguage()

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

◆ GetMenuEntries()

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

◆ GetMenus()

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

◆ GetRepeats()

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

◆ GetWraps()

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

◆ MakeImpl()

const CommandSet::Impl & CommandSet::MakeImpl ( ) const
private
91{
92 try {
93 static const Impl kImpl;
94 return kImpl;
95 }
96 catch (const std::exception& e) {
97 rsj::ExceptionResponse(e, std::source_location::current());
98 throw;
99 }
100}

◆ UnassignedTranslated()

static const auto & CommandSet::UnassignedTranslated ( )
inlinestatic
65 {
66 static const auto unassigned {juce::translate("Unassigned").toStdString()};
67 return unassigned;
68 }

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
119{}; /* use for command_set_.CommandAbbrevAt, .size */

◆ cmd_idx_

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

◆ cmd_label_by_number_

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

◆ kUnassigned

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

◆ m_impl_

const Impl& CommandSet::m_impl_
private

◆ menu_entries_

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

◆ menus_

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

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