irda-app-remote-manager.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include <irda_worker.h>
  3. #include <stdint.h>
  4. #include <string>
  5. #include <vector>
  6. #include <memory>
  7. #include <irda.h>
  8. #include <storage/storage.h>
  9. #include "irda-app-signal.h"
  10. class IrdaAppRemoteButton {
  11. friend class IrdaAppRemoteManager;
  12. std::string name;
  13. IrdaAppSignal signal;
  14. public:
  15. IrdaAppRemoteButton(const char* name, const IrdaAppSignal& signal)
  16. : name(name)
  17. , signal(signal) {
  18. }
  19. ~IrdaAppRemoteButton() {
  20. }
  21. };
  22. class IrdaAppRemote {
  23. friend class IrdaAppRemoteManager;
  24. std::vector<IrdaAppRemoteButton> buttons;
  25. std::string name;
  26. public:
  27. IrdaAppRemote(const std::string& name)
  28. : name(name) {
  29. }
  30. IrdaAppRemote& operator=(std::string& new_name) noexcept {
  31. name = new_name;
  32. buttons.clear();
  33. return *this;
  34. }
  35. };
  36. class IrdaAppRemoteManager {
  37. static const char* irda_directory;
  38. static const char* irda_extension;
  39. std::unique_ptr<IrdaAppRemote> remote;
  40. std::string make_full_name(const std::string& remote_name) const;
  41. std::string make_remote_name(const std::string& full_name) const;
  42. public:
  43. bool add_remote_with_button(const char* button_name, const IrdaAppSignal& signal);
  44. bool add_button(const char* button_name, const IrdaAppSignal& signal);
  45. int find_remote_name(const std::vector<std::string>& strings);
  46. bool rename_button(uint32_t index, const char* str);
  47. bool rename_remote(const char* str);
  48. std::string find_vacant_remote_name(const std::string& name);
  49. std::vector<std::string> get_button_list() const;
  50. std::string get_button_name(uint32_t index);
  51. std::string get_remote_name();
  52. size_t get_number_of_buttons();
  53. const IrdaAppSignal& get_button_data(size_t index) const;
  54. bool delete_button(uint32_t index);
  55. bool delete_remote();
  56. void reset_remote();
  57. bool store();
  58. bool load(const std::string& name);
  59. };