| 2787 | |
| 2788 | |
| 2789 | int cConfigManager::updateInstance(ConfigInstance *_inst) |
| 2790 | { |
| 2791 | if (_inst == NULL) return -1; |
| 2792 | int update = 0; |
| 2793 | int idx = findInstance(_inst->getName()); |
| 2794 | if (idx == -1) { |
| 2795 | // new instance, check for default instance in *defaults |
| 2796 | SMILE_DBG(6,"updateInstance: adding new instance '%s'",_inst->getName()); |
| 2797 | const ConfigType *tmpType = _inst->getType(); |
| 2798 | int tidx = findType(tmpType->getName()); |
| 2799 | if (tidx == -1) { |
| 2800 | // error: unknown type! (can not be...) |
| 2801 | CONF_MANAGER_ERR("updateInstance: trying to add instance (%s) of unknown type (%s) to configManager",_inst->getName(),tmpType->getName()); |
| 2802 | } else { |
| 2803 | // copy and "update" default: |
| 2804 | _inst->missingFrom(defaults[tidx]); |
| 2805 | addInstance(_inst); |
| 2806 | } |
| 2807 | } else { |
| 2808 | //update only |
| 2809 | inst[idx]->updateWith(_inst); |
| 2810 | update = 1; |
| 2811 | } |
| 2812 | return update; |
| 2813 | } |
| 2814 | |
| 2815 | /* register an instance specifying the type and the default values */ |
| 2816 | /* the instance MUST contain a type, the instance must be created with freeType=0 |
nothing calls this directly
no test coverage detected