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:
- 47:fa96ddc36f04
- Parent:
- 42:ff05e71c4cb5
- Child:
- 55:63350425d704
diff -r 1041f7efee73 -r fa96ddc36f04 ResourceFactory.cpp --- a/ResourceFactory.cpp Sat Mar 01 16:10:08 2014 +0000 +++ b/ResourceFactory.cpp Sat Mar 01 17:01:46 2014 +0000 @@ -36,7 +36,7 @@ int ResourceFactory::numResources() { return this->m_count; } // get the ith resource - Resource *ResourceFactory::getResource(int index) { return this->m_list[index]; }; + Resource *ResourceFactory::getResource(int index) { if (index >= 0 && index < NUM_RESOURCES) return this->m_list[index]; return NULL;}; // get the error handler ErrorHandler *ResourceFactory::logger() { return this->m_error_handler; } @@ -62,7 +62,7 @@ bool found = false; // loop through the resource list - for(int i=0;i<this->m_count && !found;++i) { + for(int i=0;i<this->m_count && !found && name != NULL;++i) { if (strcmp(this->m_list[i]->getName(),name) == 0) { found = true; value = this->m_list[i]->getValue(); @@ -79,7 +79,7 @@ bool set = false; // loop through the resource list - for(int i=0;i<this->m_count && !found;++i) { + for(int i=0;i<this->m_count && !found && name != NULL && value != NULL;++i) { if (strcmp(this->m_list[i]->getName(),name) == 0) { found = true; this->logger()->log("Setting Resource: %s Value: %s",name,value); @@ -97,7 +97,7 @@ bool found = false; // loop through the resource list - for(int i=0;i<this->m_count && !found;++i) { + for(int i=0;i<this->m_count && !found && name != NULL;++i) { if (strcmp(this->m_list[i]->getName(),name) == 0) { found = true; cb = this->m_list[i]->getCallbackPointer();