Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
system.hpp
00001 #ifndef _SYSTEM_HPP 00002 #define _SYSTEM_HPP 00003 00004 #include "key_handler.hpp" 00005 #include <string> 00006 00007 class State; 00008 class DisplayManager; 00009 class KeyboardManager; 00010 class DtmfGenerator; 00011 00012 00013 class System : public KeyHandler { 00014 public: 00015 enum StateId { 00016 Init, Edit, Command, Sending, 00017 NumStates 00018 }; 00019 00020 System(DisplayManager *display, KeyboardManager *keyboard, DtmfGenerator *dtmf); 00021 00022 DisplayManager *display() { return this->display_; } 00023 KeyboardManager *keyboard() { return this->keyboard_; } 00024 DtmfGenerator *dtmf() { return this->dtmf_; } 00025 00026 void registerState(StateId id, State *state); 00027 void unregisterState(State *state); 00028 00029 void setState(StateId newState); 00030 State * state() const { return this->state_; } 00031 00032 void insertSymbol(char ch); 00033 void deleteCurrentSymbol(); 00034 void clearText(); 00035 const std::string &text() const { return this->text_; } 00036 std::size_t text_size() const { return this->len_; } 00037 00038 void moveCursorTo(int pos); 00039 void moveCursorBy(int delta); 00040 std::size_t cursor() const { return this->pos_; } 00041 00042 // KeyHandler implementation 00043 virtual void handleKey(char ch); 00044 00045 private: 00046 void setCursorPosition(int pos); 00047 00048 DisplayManager *display_; 00049 KeyboardManager *keyboard_; 00050 DtmfGenerator *dtmf_; 00051 00052 State *state_; 00053 State *states_[NumStates]; 00054 00055 std::string text_; 00056 std::size_t len_; 00057 std::size_t pos_; 00058 }; 00059 00060 #endif
Generated on Wed Jul 13 2022 16:23:43 by
1.7.2