Allow binding commands to class instance
[lsnes.git] / include / core / jukebox.hpp
blob2ee68470220759586ff374dab8e257877cb4d2bd
1 #ifndef _jukebox__hpp__included__
2 #define _jukebox__hpp__included__
4 #include <functional>
5 #include <cstdlib>
6 #include <string>
8 namespace settingvar { class group; }
10 class save_jukebox_listener;
12 /**
13 * Save jukebox.
15 class save_jukebox
17 public:
18 /**
19 * Ctor.
21 save_jukebox(settingvar::group& _settings, command::group& _cmd);
22 /**
23 * Dtor.
25 ~save_jukebox();
26 /**
27 * Get current slot.
29 * Throws std::runtime_exception: No slot selected.
31 size_t get_slot();
32 /**
33 * Set current slot.
35 * Parameter slot: The slot to select.
36 * Throws std::runtime_exception: Slot out of range.
38 void set_slot(size_t slot);
39 /**
40 * Cycle next slot.
42 * Throws std::runtime_exception: No slot selected.
44 void cycle_next();
45 /**
46 * Cycle previous slot.
48 * Throws std::runtime_exception: No slot selected.
50 void cycle_prev();
51 /**
52 * Get save as binary flag.
54 bool save_binary();
55 /**
56 * Get name of current jukebox slot.
58 * Throws std::runtime_exception: No slot selected.
60 std::string get_slot_name();
61 /**
62 * Set size of jukebox.
64 * Parameter size: The new size.
66 void set_size(size_t size);
67 /**
68 * Set update function.
70 void set_update(std::function<void()> _update);
71 /**
72 * Unset update function.
74 void unset_update();
75 private:
76 void do_slotsel(const std::string& arg);
77 settingvar::group& settings;
78 size_t current_slot;
79 size_t current_size;
80 std::function<void()> update;
81 save_jukebox_listener* listener;
82 command::group& cmd;
83 command::_fnptr<const std::string&> slotsel;
84 command::_fnptr<> cycleprev;
85 command::_fnptr<> cyclenext;
88 #endif