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
ResourceFactory.h@55:63350425d704, 2014-03-02 (annotated)
- Committer:
- ansond
- Date:
- Sun Mar 02 18:07:26 2014 +0000
- Revision:
- 55:63350425d704
- Parent:
- 40:eae89a487d86
- Child:
- 135:7f3f963cd159
updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 1:5d332fa199ce | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 1:5d332fa199ce | 2 | * |
ansond | 1:5d332fa199ce | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 1:5d332fa199ce | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 1:5d332fa199ce | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 1:5d332fa199ce | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 1:5d332fa199ce | 7 | * furnished to do so, subject to the following conditions: |
ansond | 1:5d332fa199ce | 8 | * |
ansond | 1:5d332fa199ce | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 1:5d332fa199ce | 10 | * substantial portions of the Software. |
ansond | 1:5d332fa199ce | 11 | * |
ansond | 1:5d332fa199ce | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 1:5d332fa199ce | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 1:5d332fa199ce | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 1:5d332fa199ce | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 1:5d332fa199ce | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 1:5d332fa199ce | 17 | */ |
ansond | 1:5d332fa199ce | 18 | |
ansond | 1:5d332fa199ce | 19 | #ifndef _RESOURCE_FACTORY_H_ |
ansond | 1:5d332fa199ce | 20 | #define _RESOURCE_FACTORY_H_ |
ansond | 1:5d332fa199ce | 21 | |
ansond | 2:4d81c828b230 | 22 | // ErrorHandler support |
ansond | 2:4d81c828b230 | 23 | #include "ErrorHandler.h" |
ansond | 2:4d81c828b230 | 24 | |
ansond | 6:9a4085eeac52 | 25 | // Resource support |
ansond | 6:9a4085eeac52 | 26 | #include "Resource.h" |
ansond | 6:9a4085eeac52 | 27 | |
ansond | 1:5d332fa199ce | 28 | class ResourceFactory { |
ansond | 1:5d332fa199ce | 29 | private: |
ansond | 6:9a4085eeac52 | 30 | ErrorHandler *m_error_handler; |
ansond | 7:36ec6469949e | 31 | |
ansond | 7:36ec6469949e | 32 | protected: |
ansond | 40:eae89a487d86 | 33 | void *m_endpoint; |
ansond | 26:791d22d43cb4 | 34 | Resource *m_list[NUM_RESOURCES]; |
ansond | 26:791d22d43cb4 | 35 | int m_count; |
ansond | 1:5d332fa199ce | 36 | |
ansond | 1:5d332fa199ce | 37 | public: |
ansond | 40:eae89a487d86 | 38 | ResourceFactory(ErrorHandler *error_handler,void *endpoint); |
ansond | 1:5d332fa199ce | 39 | virtual ~ResourceFactory(); |
ansond | 1:5d332fa199ce | 40 | |
ansond | 1:5d332fa199ce | 41 | ErrorHandler *logger(); |
ansond | 1:5d332fa199ce | 42 | |
ansond | 7:36ec6469949e | 43 | virtual void createResources(char *endpoint_name); |
ansond | 7:36ec6469949e | 44 | char *getResourceValue(char *name); |
ansond | 21:cfdaee0a2b50 | 45 | bool setResourceValue(char *name, char *value); |
ansond | 25:2a001b4f7024 | 46 | int numResources(); |
ansond | 25:2a001b4f7024 | 47 | Resource *getResource(int index); |
ansond | 6:9a4085eeac52 | 48 | |
ansond | 7:36ec6469949e | 49 | protected: |
ansond | 40:eae89a487d86 | 50 | virtual void createResource(char *endpoint_name,char *name,char *value,void *cb); |
ansond | 8:d7ea38b0e131 | 51 | virtual void createResource(char *name,char *value); |
ansond | 21:cfdaee0a2b50 | 52 | void *getCallbackPointer(char *name); |
ansond | 55:63350425d704 | 53 | int min(int value1, int value2); |
ansond | 1:5d332fa199ce | 54 | }; |
ansond | 1:5d332fa199ce | 55 | |
ansond | 1:5d332fa199ce | 56 | |
ansond | 1:5d332fa199ce | 57 | #endif // _RESOURCE_FACTORY_H_ |