mbed Connector Endpoint interface. This interface permits a mbed endpoint to easily setup MDS resources and emit those resources to an MDS server.
Dependents: IoT_LED_demo ServoTest uWater_Project hackathon ... more
Diff: api/Resource.h
- Revision:
- 2:853f9ecc12df
- Parent:
- 0:b438482ebbfc
- Child:
- 46:cc6076ac5026
diff -r cabdd0350707 -r 853f9ecc12df api/Resource.h --- a/api/Resource.h Tue Jan 27 22:52:25 2015 +0000 +++ b/api/Resource.h Tue Jan 27 23:41:34 2015 +0000 @@ -3,7 +3,7 @@ * @brief mbed CoAP Endpoint Resource base class template * @author Doug Anson/Chris Paola * @version 1.0 - * @see + * @see * * Copyright (c) 2014 * @@ -19,92 +19,105 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - #ifndef __RESOURCE_H__ - #define __RESOURCE_H__ + +#ifndef __RESOURCE_H__ +#define __RESOURCE_H__ + +// logging facility +#include "Logger.h" + +// string support +#include <string> + +/** Resource class + */ +template <typename InnerType> class Resource +{ +public: + /** + Default constructor + @param logger input the Logger instance this Resource is a part of + @param name input the Resource URI/Name + @param value input the Resource value + */ + Resource(const Logger *logger,const string name,InnerType value) { + this->init(logger); + this->m_name = name; + this->m_value = value; + } + + /** + Copy constructor + @param resource input the Resource that is to be deep copied + */ + Resource(const Resource<InnerType> &resource) { + this->init(resource.m_logger); + this->m_endpoint = resource.m_endpoint; + this->m_name = resource.m_name; + this->m_value = resource.m_value; + } + + /** + Destructor + */ + virtual ~Resource() { + } - // logging facility - #include "Logger.h" - - // string support - #include <string> - - template <typename InnerType> class Resource { - public: - /** - Default constructor - @param logger input the Logger instance this Resource is a part of - @param name input the Resource URI/Name - @param value input the Resource value - */ - Resource(const Logger *logger,const string name,InnerType value) { - this->init(logger); - this->m_name = name; - this->m_value = value; - } - - /** - Copy constructor - @param resource input the Resource that is to be deep copied - */ - Resource(const Resource<InnerType> &resource) { - this->init(resource.m_logger); - this->m_endpoint = resource.m_endpoint; - this->m_name = resource.m_name; - this->m_value = resource.m_value; - } - - /** - Destructor - */ - virtual ~Resource() { - } - - /** - Get the resource name - @return the name of the resource - */ - string getName() { return this->m_name; } - - /** - Get the resource value - @return the value of the resource - */ - InnerType getValue() { return this->m_value; } - - /** - Set the resource name - @param name input the resource name - */ - void setName(const string name) { this->m_name = name; } - - /** - Set the resource value - @param value input the resource value - */ - void setValue(const InnerType value) { this->m_value = value; } - - /** - Bind resource to endpoint - */ - virtual void bind(void *p) = 0; - - // access the logger() - Logger *logger() { return this->m_logger; } + /** + Get the resource name + @return the name of the resource + */ + string getName() { + return this->m_name; + } + + /** + Get the resource value + @return the value of the resource + */ + InnerType getValue() { + return this->m_value; + } + + /** + Set the resource name + @param name input the resource name + */ + void setName(const string name) { + this->m_name = name; + } - protected: - // initialize internals to Resource - void init(const Logger *logger) { - this->m_logger = (Logger *)logger; - this->m_endpoint = NULL; - this->m_name = ""; - this->m_value = ""; - } - - Logger *m_logger; - void *m_endpoint; - string m_name; - InnerType m_value; - }; - - #endif // __RESOURCE_H__ \ No newline at end of file + /** + Set the resource value + @param value input the resource value + */ + void setValue(const InnerType value) { + this->m_value = value; + } + + /** + Bind resource to endpoint + */ + virtual void bind(void *p) = 0; + + // access the logger() + Logger *logger() { + return this->m_logger; + } + +protected: + // initialize internals to Resource + void init(const Logger *logger) { + this->m_logger = (Logger *)logger; + this->m_endpoint = NULL; + this->m_name = ""; + this->m_value = ""; + } + + Logger *m_logger; + void *m_endpoint; + string m_name; + InnerType m_value; +}; + +#endif // __RESOURCE_H__