bool SensorsList::setSerialization(const SensorType& sensor_type, const std::vector< std::string >& serializaton) { if( serializaton.size() != this->getNrOfSensors(sensor_type) ) { std::cerr << "[ERROR] SensorsTree::setSerialization error : wrong size of serializaton vector" << std::endl; return false; } std::vector<Sensor *> newVecSensors(serializaton.size()); for(size_t i=0; i < serializaton.size(); i++ ) { int oldSensIndex = getSensorIndex(sensor_type,serializaton[i]); if( oldSensIndex == -1 ) { std::cerr << "[ERROR] SensorsTree::setSerialization error : sensor " << serializaton[i] << " not found in sensor list." << std::endl; return false; } newVecSensors[i] = this->getSensor(sensor_type,oldSensIndex); } this->pimpl->VecSensors[sensor_type] = newVecSensors; return true; }
int SensorsList::getSensorIndex(const SensorType& sensor_type, const std::string& _sensor_name) const { unsigned int retUnsignedVal; int retVal; bool ok = getSensorIndex(sensor_type,_sensor_name,retUnsignedVal); if( !ok ) { retVal = -1; } else { // \todo TODO check overflow retVal = (int) retUnsignedVal; } return retVal; }