irda-app-remote-manager.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include <stdint.h>
  3. #include <string>
  4. #include <vector>
  5. #include <memory>
  6. #include <irda.h>
  7. #include <sd-card-api.h>
  8. #include <filesystem-api.h>
  9. class IrdaAppRemoteButton {
  10. friend class IrdaAppRemoteManager;
  11. std::string name;
  12. IrdaMessage message;
  13. public:
  14. IrdaAppRemoteButton(const char* name, const IrdaMessage* message)
  15. : name(name), message (*message) {}
  16. ~IrdaAppRemoteButton() {}
  17. };
  18. class IrdaAppRemote {
  19. friend class IrdaAppRemoteManager;
  20. std::vector<IrdaAppRemoteButton> buttons;
  21. std::string name;
  22. public:
  23. IrdaAppRemote(const std::string& name);
  24. IrdaAppRemote& operator=(std::string& new_name) noexcept
  25. {
  26. name = new_name;
  27. buttons.clear();
  28. return *this;
  29. }
  30. };
  31. class IrdaAppRemoteManager {
  32. static const char* irda_directory;
  33. static const char* irda_extension;
  34. std::unique_ptr<IrdaAppRemote> remote;
  35. std::string make_filename(const std::string& name) const;
  36. public:
  37. bool add_remote_with_button(const char* button_name, const IrdaMessage* message);
  38. bool add_button(const char* button_name, const IrdaMessage* message);
  39. int find_remote_name(const std::vector<std::string>& strings);
  40. bool rename_button(uint32_t index, const char* str);
  41. bool rename_remote(const char* str);
  42. bool get_remote_list(std::vector<std::string>& remote_names) const;
  43. std::vector<std::string> get_button_list() const;
  44. std::string get_button_name(uint32_t index);
  45. std::string get_remote_name();
  46. size_t get_number_of_buttons();
  47. const IrdaMessage* get_button_data(size_t button_index) const;
  48. bool delete_button(uint32_t index);
  49. bool delete_remote();
  50. bool store();
  51. bool load(const std::string& name);
  52. bool check_fs() const;
  53. };