2021-06-02 18:16:05 +03:00
|
|
|
#pragma once
|
2021-08-19 03:18:42 +03:00
|
|
|
|
|
|
|
#include "irda-app-signal.h"
|
|
|
|
|
2021-07-16 19:43:54 +03:00
|
|
|
#include <irda_worker.h>
|
2021-08-19 03:18:42 +03:00
|
|
|
#include <irda.h>
|
|
|
|
|
|
|
|
#include <cstdint>
|
2021-06-02 18:16:05 +03:00
|
|
|
#include <string>
|
2021-06-09 16:04:49 +03:00
|
|
|
#include <memory>
|
2021-08-19 03:18:42 +03:00
|
|
|
#include <vector>
|
2021-07-16 19:43:54 +03:00
|
|
|
|
2021-06-02 18:16:05 +03:00
|
|
|
class IrdaAppRemoteButton {
|
|
|
|
friend class IrdaAppRemoteManager;
|
|
|
|
std::string name;
|
2021-07-16 19:43:54 +03:00
|
|
|
IrdaAppSignal signal;
|
2021-08-11 20:51:06 +03:00
|
|
|
|
2021-06-02 18:16:05 +03:00
|
|
|
public:
|
2021-07-16 19:43:54 +03:00
|
|
|
IrdaAppRemoteButton(const char* name, const IrdaAppSignal& signal)
|
2021-08-11 20:51:06 +03:00
|
|
|
: name(name)
|
|
|
|
, signal(signal) {
|
|
|
|
}
|
|
|
|
~IrdaAppRemoteButton() {
|
|
|
|
}
|
2021-06-02 18:16:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class IrdaAppRemote {
|
|
|
|
friend class IrdaAppRemoteManager;
|
|
|
|
std::vector<IrdaAppRemoteButton> buttons;
|
|
|
|
std::string name;
|
2021-08-11 20:51:06 +03:00
|
|
|
|
2021-06-02 18:16:05 +03:00
|
|
|
public:
|
2021-08-11 20:51:06 +03:00
|
|
|
IrdaAppRemote(const std::string& name)
|
|
|
|
: name(name) {
|
|
|
|
}
|
2021-07-16 19:50:18 +03:00
|
|
|
|
2021-08-11 20:51:06 +03:00
|
|
|
IrdaAppRemote& operator=(std::string& new_name) noexcept {
|
2021-06-09 16:04:49 +03:00
|
|
|
name = new_name;
|
|
|
|
buttons.clear();
|
|
|
|
return *this;
|
|
|
|
}
|
2021-06-02 18:16:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class IrdaAppRemoteManager {
|
2021-06-09 16:04:49 +03:00
|
|
|
std::unique_ptr<IrdaAppRemote> remote;
|
2021-07-16 19:50:18 +03: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 16:04:49 +03:00
|
|
|
|
2021-06-02 18:16:05 +03:00
|
|
|
public:
|
2021-08-19 03:18:42 +03:00
|
|
|
static inline const uint32_t max_button_name_length = 31;
|
|
|
|
static inline const uint32_t max_remote_name_length = 31;
|
2021-07-16 19:43:54 +03: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 16:04:49 +03: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 03:07:00 +03:00
|
|
|
std::string find_vacant_remote_name(const std::string& name);
|
2021-06-02 18:16:05 +03:00
|
|
|
|
2021-06-09 16:04:49 +03: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 19:43:54 +03:00
|
|
|
const IrdaAppSignal& get_button_data(size_t index) const;
|
2021-06-09 16:04:49 +03:00
|
|
|
bool delete_button(uint32_t index);
|
|
|
|
bool delete_remote();
|
2021-07-22 03:07:00 +03:00
|
|
|
void reset_remote();
|
2021-06-09 16:04:49 +03:00
|
|
|
|
|
|
|
bool store();
|
2021-07-22 03:07:00 +03:00
|
|
|
bool load(const std::string& name);
|
2021-06-02 18:16:05 +03:00
|
|
|
};
|