2021-06-02 15:16:05 +00:00
|
|
|
#pragma once
|
2021-08-19 00:18:42 +00:00
|
|
|
|
2022-01-05 16:10:18 +00:00
|
|
|
#include "irda_app_signal.h"
|
2021-08-19 00:18:42 +00:00
|
|
|
|
2021-07-16 16:43:54 +00:00
|
|
|
#include <irda_worker.h>
|
2021-08-19 00:18:42 +00:00
|
|
|
#include <irda.h>
|
|
|
|
|
|
|
|
#include <cstdint>
|
2021-06-02 15:16:05 +00:00
|
|
|
#include <string>
|
2021-06-09 13:04:49 +00:00
|
|
|
#include <memory>
|
2021-08-19 00:18:42 +00:00
|
|
|
#include <vector>
|
2021-07-16 16:43:54 +00:00
|
|
|
|
2021-06-02 15:16:05 +00:00
|
|
|
class IrdaAppRemoteButton {
|
|
|
|
friend class IrdaAppRemoteManager;
|
|
|
|
std::string name;
|
2021-07-16 16:43:54 +00:00
|
|
|
IrdaAppSignal signal;
|
2021-08-11 17:51:06 +00:00
|
|
|
|
2021-06-02 15:16:05 +00:00
|
|
|
public:
|
2021-07-16 16:43:54 +00:00
|
|
|
IrdaAppRemoteButton(const char* name, const IrdaAppSignal& signal)
|
2021-08-11 17:51:06 +00:00
|
|
|
: name(name)
|
|
|
|
, signal(signal) {
|
|
|
|
}
|
|
|
|
~IrdaAppRemoteButton() {
|
|
|
|
}
|
2021-06-02 15:16:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IrdaAppRemote {
|
|
|
|
friend class IrdaAppRemoteManager;
|
|
|
|
std::vector<IrdaAppRemoteButton> buttons;
|
|
|
|
std::string name;
|
2021-08-11 17:51:06 +00:00
|
|
|
|
2021-06-02 15:16:05 +00:00
|
|
|
public:
|
2021-08-11 17:51:06 +00:00
|
|
|
IrdaAppRemote(const std::string& name)
|
|
|
|
: name(name) {
|
|
|
|
}
|
2021-07-16 16:50:18 +00:00
|
|
|
|
2021-08-11 17:51:06 +00:00
|
|
|
IrdaAppRemote& operator=(std::string& new_name) noexcept {
|
2021-06-09 13:04:49 +00:00
|
|
|
name = new_name;
|
|
|
|
buttons.clear();
|
|
|
|
return *this;
|
|
|
|
}
|
2021-06-02 15:16:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IrdaAppRemoteManager {
|
2021-06-09 13:04:49 +00:00
|
|
|
std::unique_ptr<IrdaAppRemote> remote;
|
2021-07-16 16:50:18 +00:00
|
|
|
std::string make_full_name(const std::string& remote_name) const;
|
|
|
|
std::string make_remote_name(const std::string& full_name) const;
|
2021-06-09 13:04:49 +00:00
|
|
|
|
2021-06-02 15:16:05 +00:00
|
|
|
public:
|
2021-09-02 09:02:34 +00:00
|
|
|
static inline const uint32_t max_button_name_length = 22;
|
|
|
|
static inline const uint32_t max_remote_name_length = 22;
|
2021-07-16 16:43:54 +00:00
|
|
|
bool add_remote_with_button(const char* button_name, const IrdaAppSignal& signal);
|
|
|
|
bool add_button(const char* button_name, const IrdaAppSignal& signal);
|
2021-06-09 13:04:49 +00:00
|
|
|
|
|
|
|
int find_remote_name(const std::vector<std::string>& strings);
|
|
|
|
bool rename_button(uint32_t index, const char* str);
|
|
|
|
bool rename_remote(const char* str);
|
2021-07-22 00:07:00 +00:00
|
|
|
std::string find_vacant_remote_name(const std::string& name);
|
2021-06-02 15:16:05 +00:00
|
|
|
|
2021-06-09 13:04:49 +00:00
|
|
|
std::vector<std::string> get_button_list() const;
|
|
|
|
std::string get_button_name(uint32_t index);
|
|
|
|
std::string get_remote_name();
|
|
|
|
size_t get_number_of_buttons();
|
2021-07-16 16:43:54 +00:00
|
|
|
const IrdaAppSignal& get_button_data(size_t index) const;
|
2021-06-09 13:04:49 +00:00
|
|
|
bool delete_button(uint32_t index);
|
|
|
|
bool delete_remote();
|
2021-07-22 00:07:00 +00:00
|
|
|
void reset_remote();
|
2021-06-09 13:04:49 +00:00
|
|
|
|
|
|
|
bool store();
|
2021-07-22 00:07:00 +00:00
|
|
|
bool load(const std::string& name);
|
2021-06-02 15:16:05 +00:00
|
|
|
};
|