MIDI2LR 6.3.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
Devices Class Reference

#include <Devices.h>

Classes

struct  DevInfo

Public Member Functions

 Devices ()
 Devices (const Devices &other)=delete
 Devices (Devices &&other) noexcept=default
 ~Devices ()
bool Add (const juce::MidiDeviceInfo &info, const juce::String &io)
bool Enabled (const juce::MidiDeviceInfo &info, juce::String io) const
bool EnabledOrNew (const juce::MidiDeviceInfo &info, const juce::String &io)
Devicesoperator= (const Devices &other)=delete
Devicesoperator= (Devices &&other) noexcept=default

Private Member Functions

void CreateDefaultDeviceXml ()
void LoadDeviceXml ()
void ProcessDataList ()

Private Attributes

juce::XmlElement * column_list_ {nullptr}
juce::XmlElement * data_list_ {nullptr}
std::map< DevInfo, bool > device_listing_
std::unique_ptr< juce::XmlElement > device_xml_
int num_rows_ {0}

Constructor & Destructor Documentation

◆ Devices() [1/3]

Devices::Devices ( )
88 {

◆ ~Devices()

Devices::~Devices ( )
94{
98}
99
101{
102 try {
103 /* open file with xml list of devices */
104 const auto source {GetSource(MIDI2LR_UC_LITERAL("Controllers.xml"))};
void LoadDeviceXml()
Definition Devices.cpp:40
void ProcessDataList()
Definition Devices.cpp:64
~Devices()
Definition Devices.cpp:90
void CreateDefaultDeviceXml()
Definition Devices.cpp:59
std::unique_ptr< juce::XmlElement > device_xml_
Definition Devices.h:107

References CreateDefaultDeviceXml(), LoadDeviceXml(), and ProcessDataList().

◆ Devices() [2/3]

Devices::Devices ( const Devices & other)
delete

◆ Devices() [3/3]

Devices::Devices ( Devices && other)
defaultnoexcept

Member Function Documentation

◆ Add()

bool Devices::Add ( const juce::MidiDeviceInfo & info,
const juce::String & io )
108 {
109 rsj::ExceptionResponse(e, std::source_location::current());
110 }
111 catch (...) {
112 rsj::LogAndAlertError("Non-standard exception in ~Devices.", std::source_location::current());
113 }
114}
115
116bool Devices::Add(const juce::MidiDeviceInfo& info, const juce::String& io)
117{
118 try {
119 const auto [it, success] {device_listing_.try_emplace({info, io}, true)};
120 if (success) {
121 if (const auto new_element {data_list_->createNewChildElement("item")}) {
122 new_element->setAttribute("devicename", info.name);
123 new_element->setAttribute("systemid", info.identifier);
124 new_element->setAttribute("inputoutput", io);
125 new_element->setAttribute("active", "1");
126 }
127 else {
128 rsj::Log("Failed to create new element in Devices::Add",
juce::XmlElement * data_list_
Definition Devices.h:109
bool Add(const juce::MidiDeviceInfo &info, const juce::String &io)
Definition Devices.cpp:106
std::map< DevInfo, bool > device_listing_
Definition Devices.h:106
void ExceptionResponse(gsl::czstring id, gsl::czstring fu, const std::exception &e) noexcept
void LogAndAlertError(const juce::String &error_text, const std::source_location &location=std::source_location::current()) noexcept
Definition Misc.cpp:141
void Log(const juce::String &info, const std::source_location &location=std::source_location::current()) noexcept
Definition Misc.cpp:112

◆ CreateDefaultDeviceXml()

void Devices::CreateDefaultDeviceXml ( )
private
60{
61 device_xml_ = juce::parseXML(R"===(<?xml version="1.0" encoding="UTF-8"?>
62 <table_data>

Referenced by ~Devices().

◆ Enabled()

bool Devices::Enabled ( const juce::MidiDeviceInfo & info,
juce::String io ) const
nodiscard
134 {
135 rsj::ExceptionResponse(e, std::source_location::current());
136 throw;
137 }
138}
139
140bool Devices::Enabled(const juce::MidiDeviceInfo& info, juce::String io) const
141{
bool Enabled(const juce::MidiDeviceInfo &info, juce::String io) const
Definition Devices.cpp:130

◆ EnabledOrNew()

bool Devices::EnabledOrNew ( const juce::MidiDeviceInfo & info,
const juce::String & io )
nodiscard
143 {device_listing_.find({info, std::move(io)})};
144 if (it == device_listing_.end()) { return true; }
145 return it->second;
146 }
147 catch (const std::exception& e) {
148 rsj::ExceptionResponse(e, std::source_location::current());
149 throw;
150 }
151}
152
153bool Devices::EnabledOrNew(const juce::MidiDeviceInfo& info, const juce::String& io)
bool EnabledOrNew(const juce::MidiDeviceInfo &info, const juce::String &io)
Definition Devices.cpp:143

◆ LoadDeviceXml()

void Devices::LoadDeviceXml ( )
private
41{
42 try {
43 auto deviceXmlSource {GetSource(MIDI2LR_UC_LITERAL("Controllers.xml"))};
44 if (deviceXmlSource.existsAsFile()) { device_xml_ = juce::parseXML(deviceXmlSource); }
45 else {
46 deviceXmlSource = GetSource(MIDI2LR_UC_LITERAL("DisabledControllers.xml"));
47 if (deviceXmlSource.existsAsFile()) {
48 device_xml_ = juce::parseXML(deviceXmlSource);
49 std::ignore = deviceXmlSource.deleteFile(); // don't want to use name again
50 }
51 }
52 }
53 catch (const std::exception& e) {
54 rsj::ExceptionResponse(e, std::source_location::current());
55 device_xml_.reset();
56 }
57}

Referenced by ~Devices().

◆ operator=() [1/2]

Devices & Devices::operator= ( const Devices & other)
delete

◆ operator=() [2/2]

Devices & Devices::operator= ( Devices && other)
defaultnoexcept

◆ ProcessDataList()

void Devices::ProcessDataList ( )
private
75{
76 column_list_ = device_xml_->getChildByName("heading");
77 data_list_ = device_xml_->getChildByName("data");
78 if (data_list_) {
79 num_rows_ = data_list_->getNumChildElements();
80 for (const gsl::not_null<const juce::XmlElement*> dataElement :
81 data_list_->getChildIterator()) {
int num_rows_
Definition Devices.h:110
juce::XmlElement * column_list_
Definition Devices.h:108

Referenced by ~Devices().

Member Data Documentation

◆ column_list_

juce::XmlElement* Devices::column_list_ {nullptr}
private
108{nullptr};

◆ data_list_

juce::XmlElement* Devices::data_list_ {nullptr}
private
109{nullptr};

◆ device_listing_

std::map<DevInfo, bool> Devices::device_listing_
private

◆ device_xml_

std::unique_ptr<juce::XmlElement> Devices::device_xml_
private

◆ num_rows_

int Devices::num_rows_ {0}
private
110{0};

The documentation for this class was generated from the following files:
  • C:/Users/rsjaf/source/repos/MIDI2LR/src/application/Devices.h
  • C:/Users/rsjaf/source/repos/MIDI2LR/src/application/Devices.cpp