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