use TCP to connect to mbed connector
Fork of mbedConnectorInterfaceWithDM by
mbed-connector-interface/StaticResource.h@0:1f1f55e73248, 2016-02-19 (annotated)
- Committer:
- ansond
- Date:
- Fri Feb 19 17:32:14 2016 +0000
- Revision:
- 0:1f1f55e73248
- Child:
- 27:b8aaf7dc7023
initial checkin
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:1f1f55e73248 | 1 | /** |
ansond | 0:1f1f55e73248 | 2 | * @file StaticResource.h |
ansond | 0:1f1f55e73248 | 3 | * @brief mbed CoAP Endpoint Static Resource class |
ansond | 0:1f1f55e73248 | 4 | * @author Doug Anson/Chris Paola |
ansond | 0:1f1f55e73248 | 5 | * @version 1.0 |
ansond | 0:1f1f55e73248 | 6 | * @see |
ansond | 0:1f1f55e73248 | 7 | * |
ansond | 0:1f1f55e73248 | 8 | * Copyright (c) 2014 |
ansond | 0:1f1f55e73248 | 9 | * |
ansond | 0:1f1f55e73248 | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
ansond | 0:1f1f55e73248 | 11 | * you may not use this file except in compliance with the License. |
ansond | 0:1f1f55e73248 | 12 | * You may obtain a copy of the License at |
ansond | 0:1f1f55e73248 | 13 | * |
ansond | 0:1f1f55e73248 | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
ansond | 0:1f1f55e73248 | 15 | * |
ansond | 0:1f1f55e73248 | 16 | * Unless required by applicable law or agreed to in writing, software |
ansond | 0:1f1f55e73248 | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
ansond | 0:1f1f55e73248 | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ansond | 0:1f1f55e73248 | 19 | * See the License for the specific language governing permissions and |
ansond | 0:1f1f55e73248 | 20 | * limitations under the License. |
ansond | 0:1f1f55e73248 | 21 | */ |
ansond | 0:1f1f55e73248 | 22 | |
ansond | 0:1f1f55e73248 | 23 | #ifndef __STATIC_RESOURCE_H__ |
ansond | 0:1f1f55e73248 | 24 | #define __STATIC_RESOURCE_H__ |
ansond | 0:1f1f55e73248 | 25 | |
ansond | 0:1f1f55e73248 | 26 | // Base Class |
ansond | 0:1f1f55e73248 | 27 | #include "mbed-connector-interface/Resource.h" |
ansond | 0:1f1f55e73248 | 28 | |
ansond | 0:1f1f55e73248 | 29 | // String class support |
ansond | 0:1f1f55e73248 | 30 | #include <string> |
ansond | 0:1f1f55e73248 | 31 | |
ansond | 0:1f1f55e73248 | 32 | // DataWrapper support |
ansond | 0:1f1f55e73248 | 33 | #include "mbed-connector-interface/DataWrapper.h" |
ansond | 0:1f1f55e73248 | 34 | |
ansond | 0:1f1f55e73248 | 35 | /** StaticResource is a static (GET only) resource with a value type pinned as a string type |
ansond | 0:1f1f55e73248 | 36 | */ |
ansond | 0:1f1f55e73248 | 37 | class StaticResource : public Resource<string> |
ansond | 0:1f1f55e73248 | 38 | { |
ansond | 0:1f1f55e73248 | 39 | public: |
ansond | 0:1f1f55e73248 | 40 | /** |
ansond | 0:1f1f55e73248 | 41 | Default constructor |
ansond | 0:1f1f55e73248 | 42 | @param logger input logger instance for this resource |
ansond | 0:1f1f55e73248 | 43 | @param obj_name input the Object |
ansond | 0:1f1f55e73248 | 44 | @param res_name input the Resource URI/Name |
ansond | 0:1f1f55e73248 | 45 | @param value input the Resource value (a string) |
ansond | 0:1f1f55e73248 | 46 | */ |
ansond | 0:1f1f55e73248 | 47 | StaticResource(const Logger *logger,const char *obj_name,const char *res_name,const char *value); |
ansond | 0:1f1f55e73248 | 48 | |
ansond | 0:1f1f55e73248 | 49 | /** |
ansond | 0:1f1f55e73248 | 50 | string value constructor |
ansond | 0:1f1f55e73248 | 51 | @param logger input logger instance for this resource |
ansond | 0:1f1f55e73248 | 52 | @param obj_name input the Object |
ansond | 0:1f1f55e73248 | 53 | @param name input the Resource URI/Name |
ansond | 0:1f1f55e73248 | 54 | @param value input the Resource value (a string) |
ansond | 0:1f1f55e73248 | 55 | */ |
ansond | 0:1f1f55e73248 | 56 | StaticResource(const Logger *logger,const char *obj_name,const char *res_name,const string value); |
ansond | 0:1f1f55e73248 | 57 | |
ansond | 0:1f1f55e73248 | 58 | /** |
ansond | 0:1f1f55e73248 | 59 | constructor with buffer lengths |
ansond | 0:1f1f55e73248 | 60 | @param logger input logger instance for this resource |
ansond | 0:1f1f55e73248 | 61 | @param obj_name input the Object |
ansond | 0:1f1f55e73248 | 62 | @param name input the Resource URI/Name |
ansond | 0:1f1f55e73248 | 63 | #param name_length input the length of the Resource URI/Name |
ansond | 0:1f1f55e73248 | 64 | @param value input the Resource value (or NULL) |
ansond | 0:1f1f55e73248 | 65 | */ |
ansond | 0:1f1f55e73248 | 66 | StaticResource(const Logger *logger,const string obj_name,const string res_name,const string value); |
ansond | 0:1f1f55e73248 | 67 | |
ansond | 0:1f1f55e73248 | 68 | /** |
ansond | 0:1f1f55e73248 | 69 | Copy constructor |
ansond | 0:1f1f55e73248 | 70 | @param resource input the StaticResource that is to be deep copied |
ansond | 0:1f1f55e73248 | 71 | */ |
ansond | 0:1f1f55e73248 | 72 | StaticResource(const StaticResource &resource); |
ansond | 0:1f1f55e73248 | 73 | |
ansond | 0:1f1f55e73248 | 74 | /** |
ansond | 0:1f1f55e73248 | 75 | Destructor |
ansond | 0:1f1f55e73248 | 76 | */ |
ansond | 0:1f1f55e73248 | 77 | virtual ~StaticResource(); |
ansond | 0:1f1f55e73248 | 78 | |
ansond | 0:1f1f55e73248 | 79 | /** |
ansond | 0:1f1f55e73248 | 80 | Bind resource to endpoint |
ansond | 0:1f1f55e73248 | 81 | @param p input pointer to the endpoint resources necessary for binding |
ansond | 0:1f1f55e73248 | 82 | */ |
ansond | 0:1f1f55e73248 | 83 | virtual M2MObject *bind(void *p); |
ansond | 0:1f1f55e73248 | 84 | |
ansond | 0:1f1f55e73248 | 85 | /** |
ansond | 0:1f1f55e73248 | 86 | Set the data wrapper |
ansond | 0:1f1f55e73248 | 87 | @param data_wrapper input the data wrapper instance |
ansond | 0:1f1f55e73248 | 88 | */ |
ansond | 0:1f1f55e73248 | 89 | void setDataWrapper(DataWrapper *data_wrapper) { this->m_data_wrapper = data_wrapper; } |
ansond | 0:1f1f55e73248 | 90 | |
ansond | 0:1f1f55e73248 | 91 | protected: |
ansond | 0:1f1f55e73248 | 92 | DataWrapper *getDataWrapper() { return this->m_data_wrapper; } |
ansond | 0:1f1f55e73248 | 93 | |
ansond | 0:1f1f55e73248 | 94 | private: |
ansond | 0:1f1f55e73248 | 95 | DataWrapper *m_data_wrapper; |
ansond | 0:1f1f55e73248 | 96 | M2MObject *m_object; |
ansond | 0:1f1f55e73248 | 97 | }; |
ansond | 0:1f1f55e73248 | 98 | |
ansond | 0:1f1f55e73248 | 99 | #endif // __STATIC_RESOURCE_H__ |
ansond | 0:1f1f55e73248 | 100 |