Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: IoT_LED_demo ServoTest uWater_Project hackathon ... more
Diff: api/DynamicResource.h
- Revision:
- 2:853f9ecc12df
- Parent:
- 0:b438482ebbfc
- Child:
- 21:8487990a3baa
--- a/api/DynamicResource.h Tue Jan 27 22:52:25 2015 +0000 +++ b/api/DynamicResource.h Tue Jan 27 23:41:34 2015 +0000 @@ -3,7 +3,7 @@ * @brief mbed CoAP Endpoint Dynamic Resource class * @author Doug Anson/Chris Paola * @version 1.0 - * @see + * @see * * Copyright (c) 2014 * @@ -19,98 +19,101 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - #ifndef __DYNAMIC_RESOURCE_H__ - #define __DYNAMIC_RESOURCE_H__ - - // Base Class - #include "Resource.h" - - // NSDL Support - #include "nsdl_support.h" - - class DynamicResource : public Resource<string> { - public: - /** - Default constructor (char strings) - @param logger input logger instance for this resource - @param name input the Resource URI/Name - @param res_type input type for the Resource - @param res_mask input the resource enablement mask (GET, PUT, etc...) - @param observable input the resource is Observable (default: FALSE) - */ - DynamicResource(const Logger *logger,const char *name,const char *res_type,uint8_t res_mask,const bool observable = false); - - /** - Default constructor (char strings) - @param logger input logger instance for this resource - @param name input the Resource URI/Name - @param res_type input type for the Resource - @param value input initial value for the Resource - @param res_mask input the resource enablement mask (GET, PUT, etc...) - @param observable input the resource is Observable (default: FALSE) - */ - DynamicResource(const Logger *logger,const char *name,const char *res_type,const string value,uint8_t res_mask,const bool observable = false); + +#ifndef __DYNAMIC_RESOURCE_H__ +#define __DYNAMIC_RESOURCE_H__ + +// Base Class +#include "Resource.h" + +// NSDL Support +#include "nsdl_support.h" + +/** DynamicResource class + */ +class DynamicResource : public Resource<string> +{ +public: + /** + Default constructor (char strings) + @param logger input logger instance for this resource + @param name input the Resource URI/Name + @param res_type input type for the Resource + @param res_mask input the resource enablement mask (GET, PUT, etc...) + @param observable input the resource is Observable (default: FALSE) + */ + DynamicResource(const Logger *logger,const char *name,const char *res_type,uint8_t res_mask,const bool observable = false); + + /** + Default constructor (char strings) + @param logger input logger instance for this resource + @param name input the Resource URI/Name + @param res_type input type for the Resource + @param value input initial value for the Resource + @param res_mask input the resource enablement mask (GET, PUT, etc...) + @param observable input the resource is Observable (default: FALSE) + */ + DynamicResource(const Logger *logger,const char *name,const char *res_type,const string value,uint8_t res_mask,const bool observable = false); + + /** + constructor with string buffer for name + @param logger input logger instance for this resource + @param name input the Resource URI/Name + @param res_type input type for the Resource + @param value input initial value for the Resource + @param res_mask input the resource enablement mask (GET, PUT, etc...) + @param observable input the resource is Observable (default: FALSE) + */ + DynamicResource(const Logger *logger,const string name,const string res_type,const string value,uint8_t res_mask,const bool observable = false); - /** - constructor with string buffer for name - @param logger input logger instance for this resource - @param name input the Resource URI/Name - @param res_type input type for the Resource - @param value input initial value for the Resource - @param res_mask input the resource enablement mask (GET, PUT, etc...) - @param observable input the resource is Observable (default: FALSE) - */ - DynamicResource(const Logger *logger,const string name,const string res_type,const string value,uint8_t res_mask,const bool observable = false); - - /** - Copy constructor - @param resource input the DynamicResource that is to be deep copied - */ - DynamicResource(const DynamicResource &resource); - - /** - Destructor - */ - virtual ~DynamicResource(); - - /** - Bind resource to endpoint - @param p input pointer to the endpoint resources necessary for binding - */ - virtual void bind(void *p); - - /** - Process the CoAP message - @param received_coap_ptr input the received coap pointer - @param address input the NSDL address pointer - @param proto input the NSDL protocol pointer - @return 0 - success, 1 - failure - */ - uint8_t process(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s *proto); - - /** - Resource value getter (REQUIRED: must be implemented in derived class as all Binders MUST support and implement GET) - @returns string value of the resource - */ - virtual string get() = 0; - - /** - Resource value setter (OPTIONAL: defaulted noop if not derived. Binders MAY implement PUT if needed) - @param string value of the resource - */ - virtual void put(const string value); - - protected: - - private: - - string m_res_type; - uint8_t m_res_mask; - bool m_observable; - - // convenience method to create a string from the NSDL CoAP data buffers... - string coapDataToString(uint8_t *coap_data_ptr,int coap_data_ptr_length); - }; - - #endif // __DYNAMIC_RESOURCE_H__ \ No newline at end of file + /** + Copy constructor + @param resource input the DynamicResource that is to be deep copied + */ + DynamicResource(const DynamicResource &resource); + + /** + Destructor + */ + virtual ~DynamicResource(); + + /** + Bind resource to endpoint + @param p input pointer to the endpoint resources necessary for binding + */ + virtual void bind(void *p); + + /** + Process the CoAP message + @param received_coap_ptr input the received coap pointer + @param address input the NSDL address pointer + @param proto input the NSDL protocol pointer + @return 0 - success, 1 - failure + */ + uint8_t process(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s *proto); + + /** + Resource value getter (REQUIRED: must be implemented in derived class as all Binders MUST support and implement GET) + @returns string value of the resource + */ + virtual string get() = 0; + + /** + Resource value setter (OPTIONAL: defaulted noop if not derived. Binders MAY implement PUT if needed) + @param string value of the resource + */ + virtual void put(const string value); + +protected: + +private: + + string m_res_type; + uint8_t m_res_mask; + bool m_observable; + + // convenience method to create a string from the NSDL CoAP data buffers... + string coapDataToString(uint8_t *coap_data_ptr,int coap_data_ptr_length); +}; + +#endif // __DYNAMIC_RESOURCE_H__