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