}
reader = new DataReader(id);
name = "";
+ _cfg = NULL;
}
W1Device::~W1Device() {
}
string Device::get_name() {
- DeviceConfig *cfg;
-
if (name.empty() == true) {
- cfg = DeviceConfig::get_device_config(id);
- if (cfg != NULL) {
- cfg->get_config_value(DEVICE_CONFIG_VALUE_KEY__NAME, name);
- delete(cfg);
+ if (_cfg == NULL) {
+ _cfg = DeviceConfig::get_device_config(id);
+ }
+ if (_cfg != NULL) {
+ _cfg->get_config_value(DEVICE_CONFIG_VALUE_KEY__NAME, name);
}
}
return name;
}
void Device::set_name(string name_param) {
- DeviceConfig *cfg;
-
- log_debug("set_name started\n");
if (name.compare(name_param) != 0) {
name = name_param;
- cfg = DeviceConfig::get_device_config(id);
- if (cfg != NULL) {
- cfg->set_config_value(DEVICE_CONFIG_VALUE_KEY__NAME, name_param, true);
- delete(cfg);
+ if (_cfg == NULL) {
+ _cfg = DeviceConfig::get_device_config(id);
+ }
+ if (_cfg != NULL) {
+ _cfg->set_config_value(DEVICE_CONFIG_VALUE_KEY__NAME, name_param, true);
}
}
}