Core Base Classes for the Light Endpoints
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more
Preferences.h@154:6e60f310ab78, 2014-04-03 (annotated)
- Committer:
- ansond
- Date:
- Thu Apr 03 00:50:36 2014 +0000
- Revision:
- 154:6e60f310ab78
- Parent:
- 135:7f3f963cd159
- Child:
- 155:582462821bd7
updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 112:1fb53d4729af | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 112:1fb53d4729af | 2 | * |
ansond | 112:1fb53d4729af | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 112:1fb53d4729af | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 112:1fb53d4729af | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 112:1fb53d4729af | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 112:1fb53d4729af | 7 | * furnished to do so, subject to the following conditions: |
ansond | 112:1fb53d4729af | 8 | * |
ansond | 112:1fb53d4729af | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 112:1fb53d4729af | 10 | * substantial portions of the Software. |
ansond | 112:1fb53d4729af | 11 | * |
ansond | 112:1fb53d4729af | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 112:1fb53d4729af | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 112:1fb53d4729af | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 112:1fb53d4729af | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 112:1fb53d4729af | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 112:1fb53d4729af | 17 | */ |
ansond | 112:1fb53d4729af | 18 | |
ansond | 112:1fb53d4729af | 19 | #ifndef _PREFERENCES_H_ |
ansond | 112:1fb53d4729af | 20 | #define _PREFERENCES_H_ |
ansond | 112:1fb53d4729af | 21 | |
ansond | 112:1fb53d4729af | 22 | #include "mbed.h" |
ansond | 135:7f3f963cd159 | 23 | #include "BaseClass.h" |
ansond | 112:1fb53d4729af | 24 | |
ansond | 154:6e60f310ab78 | 25 | typedef struct { |
ansond | 154:6e60f310ab78 | 26 | char name[PREFERENCE_NAME_LEN+1]; |
ansond | 154:6e60f310ab78 | 27 | char value[PREFERENCE_VALUE_LEN+1]; |
ansond | 154:6e60f310ab78 | 28 | } PreferenceEntry; |
ansond | 154:6e60f310ab78 | 29 | |
ansond | 135:7f3f963cd159 | 30 | class Preferences : public BaseClass { |
ansond | 154:6e60f310ab78 | 31 | private: |
ansond | 154:6e60f310ab78 | 32 | PreferenceEntry m_preferences[MAX_NUM_PREFERENCES]; |
ansond | 118:c8a80adfe90d | 33 | int m_num_preferences; |
ansond | 118:c8a80adfe90d | 34 | |
ansond | 112:1fb53d4729af | 35 | public: |
ansond | 112:1fb53d4729af | 36 | Preferences(ErrorHandler *error_handler); |
ansond | 135:7f3f963cd159 | 37 | virtual ~Preferences(); |
ansond | 112:1fb53d4729af | 38 | |
ansond | 112:1fb53d4729af | 39 | int numPreferences(); |
ansond | 112:1fb53d4729af | 40 | char *getPreference(char *name,char *buffer,int buffer_length,char *def_value); |
ansond | 112:1fb53d4729af | 41 | int getIntPreference(char *name,int def_value); |
ansond | 112:1fb53d4729af | 42 | bool getBooleanPreference(char *name,bool def_value); |
ansond | 112:1fb53d4729af | 43 | |
ansond | 120:edf33bd41e4f | 44 | void fixCoordsForIOC(); |
ansond | 120:edf33bd41e4f | 45 | |
ansond | 112:1fb53d4729af | 46 | private: |
ansond | 112:1fb53d4729af | 47 | bool initialize(); |
ansond | 135:7f3f963cd159 | 48 | |
ansond | 112:1fb53d4729af | 49 | int indexOfPreference(char *name); |
ansond | 154:6e60f310ab78 | 50 | }; |
ansond | 112:1fb53d4729af | 51 | |
ansond | 112:1fb53d4729af | 52 | #endif // _PREFERENCES_H_ |