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
Diff: ResourceFactory.cpp
- Revision:
- 6:9a4085eeac52
- Parent:
- 4:3176f927618d
- Child:
- 7:36ec6469949e
diff -r c1c4d511b589 -r 9a4085eeac52 ResourceFactory.cpp --- a/ResourceFactory.cpp Mon Feb 24 19:37:14 2014 +0000 +++ b/ResourceFactory.cpp Mon Feb 24 21:01:32 2014 +0000 @@ -21,6 +21,7 @@ // default constructor ResourceFactory::ResourceFactory(ErrorHandler *error_handler) { this->m_error_handler = error_handler; + this->m_list.clear(); } // default destructor @@ -33,3 +34,26 @@ // create resources (base class does nothing) void ResourceFactory::createResources(char *endpoint_name) { ; } + + // create a resource value + void ResourceFactory::createResource(char *endpoint_name,char *name,char *value) { this->createResource(endpoint_name,name,value,NULL); } + void ResourceFactory::createResource(char *endpoint_name,char *name,char *value,void *internals) { + Resource resource(this->logger(),endpoint_name,name,value,internals); + this->m_list.push_back(resource); + } + + // get a resource value (null in base class) + char *ResourceFactory::getResourceValue(char *name) { + char *value = NULL; + bool found = false; + + // loop through the resource list + for(int i=0;i<this->m_list.size() && !found;++i) { + if (strcmp(this->m_list[i].getName(),name) == 0) { + found = true; + value = this->m_list[i].getValue(); + } + } + + return value; +}