#include <ProfileManager.h>
◆ SwitchState
| Enumerator |
|---|
| kNone | |
| kPrev | |
| kNext | |
73 {
74 kNone,
75 kPrev,
76 kNext,
77 };
◆ ProfileManager() [1/3]
35{
36
39}
void AddCallback(_In_ T *const object, _In_ void(T::*const mf)(rsj::MidiMessage))
Definition MIDIReceiver.h:49
ControlsModel & controls_model_
Definition ProfileManager.h:80
LrIpcOut & lr_ipc_out_
Definition ProfileManager.h:83
const Profile & current_profile_
Definition ProfileManager.h:79
void MidiCmdCallback(rsj::MidiMessage mm)
Definition ProfileManager.cpp:144
void ConnectionCallback(bool, bool)
Definition ProfileManager.cpp:163
References current_profile_.
◆ ~ProfileManager()
| ProfileManager::~ProfileManager |
( |
| ) |
|
|
default |
◆ ProfileManager() [2/3]
◆ ProfileManager() [3/3]
◆ AddCallback()
template<class T>
| void ProfileManager::AddCallback |
( |
_In_ T *const | object, |
|
|
_In_ void(T::* | mf )(juce::XmlElement *, const juce::String &) ) |
|
inline |
52 {
53 if (
object && mf) {
callbacks_.emplace_back(std::bind_front(mf,
object)); }
54 }
std::vector< std::function< void(juce::XmlElement *, const juce::String &)> > callbacks_
Definition ProfileManager.h:88
References callbacks_.
◆ ConnectionCallback()
| void ProfileManager::ConnectionCallback |
( |
bool | connected, |
|
|
bool | blocked ) |
|
private |
164{
165 try {
166 if (connected && !blocked) {
167 lr_ipc_out_.SendCommand(fmt::format(
"ChangedToDirectory {}\n",
168 juce::File::addTrailingSeparator(
profile_location_.getFullPathName()).toStdString()));
169 }
170 }
171 catch (const std::exception& e) {
173 throw;
174 }
175}
juce::File profile_location_
Definition ProfileManager.h:82
void ExceptionResponse(gsl::czstring id, gsl::czstring fu, const std::exception &e) noexcept
◆ GetProfileDirectory()
| const juce::String & ProfileManager::GetProfileDirectory |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
◆ handleAsyncUpdate()
| void ProfileManager::handleAsyncUpdate |
( |
| ) |
|
|
overrideprivate |
178{
179 try {
180 const auto state =
switch_state_.load(std::memory_order_acquire);
181 switch (state) {
184 break;
187 break;
189 break;
190 }
192 }
193 catch (const std::exception& e) {
195 throw;
196 }
197}
void SwitchToNextProfile()
Definition ProfileManager.cpp:92
@ kNone
Definition ProfileManager.h:74
@ kNext
Definition ProfileManager.h:76
@ kPrev
Definition ProfileManager.h:75
std::atomic< SwitchState > switch_state_
Definition ProfileManager.h:90
void SwitchToPreviousProfile()
Definition ProfileManager.cpp:107
References kNext, kNone, kPrev, SwitchToNextProfile(), and SwitchToPreviousProfile().
◆ MapCommand()
123{
124 try {
125 using namespace std::string_literals;
127 if (cmd == "PrevPro"s) {
129 triggerAsyncUpdate();
130 }
131 else if (cmd == "NextPro"s) {
133 triggerAsyncUpdate();
134 }
135 else {
136 }
137 }
138 catch (const std::exception& e) {
140 throw;
141 }
142}
Referenced by MidiCmdCallback().
◆ MidiCmdCallback()
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ SetProfileDirectory()
| void ProfileManager::SetProfileDirectory |
( |
const juce::File & | directory | ) |
|
42{
43 try {
45 auto file_array {directory.findChildFiles(juce::File::findFiles, false, "*.xml")};
46 file_array.sort();
48 std::ranges::transform(file_array,
profiles_.begin(),
49 [](const auto& file) { return file.getFileName(); });
50 }
51 catch (const std::exception& e) {
53 throw;
54 }
55}
std::vector< juce::String > profiles_
Definition ProfileManager.h:84
◆ SwitchToNextProfile()
| void ProfileManager::SwitchToNextProfile |
( |
| ) |
|
|
private |
93{
94 try {
96 const auto profiles_size {gsl::narrow_cast<int>(
profiles_.size())};
99 }
100 }
101 catch (const std::exception& e) {
103 throw;
104 }
105}
void SwitchToProfile(int profile_index)
Definition ProfileManager.cpp:57
int current_profile_index_
Definition ProfileManager.h:81
References current_profile_index_, and SwitchToProfile().
Referenced by handleAsyncUpdate().
◆ SwitchToPreviousProfile()
| void ProfileManager::SwitchToPreviousProfile |
( |
| ) |
|
|
private |
◆ SwitchToProfile() [1/2]
| void ProfileManager::SwitchToProfile |
( |
const juce::String & | profile | ) |
|
73{
74 try {
76 if (profile_file.exists()) {
77 if (const auto parsed {juce::parseXML(profile_file)}) {
78 for (
const auto& cb :
callbacks_) { cb(parsed.get(), profile); }
79 lr_ipc_out_.SendCommand(fmt::format(
"ChangedToDirectory {}\n",
81 .toStdString()));
82 lr_ipc_out_.SendCommand(fmt::format(
"ChangedToFile {}\n", profile.toStdString()));
83 }
84 }
85 }
86 catch (const std::exception& e) {
88 throw;
89 }
90}
◆ SwitchToProfile() [2/2]
| void ProfileManager::SwitchToProfile |
( |
int | profile_index | ) |
|
◆ callbacks_
| std::vector<std::function<void(juce::XmlElement*, const juce::String&)> > ProfileManager::callbacks_ |
|
private |
◆ controls_model_
◆ current_profile_
| const Profile& ProfileManager::current_profile_ |
|
private |
◆ current_profile_index_
| int ProfileManager::current_profile_index_ {0} |
|
private |
◆ lr_ipc_out_
◆ profile_location_
| juce::File ProfileManager::profile_location_ |
|
private |
◆ profiles_
| std::vector<juce::String> ProfileManager::profiles_ |
|
private |
◆ switch_state_
The documentation for this class was generated from the following files:
- C:/Users/rsjaf/source/repos/MIDI2LR/src/application/ProfileManager.h
- C:/Users/rsjaf/source/repos/MIDI2LR/src/application/ProfileManager.cpp