| 445 | } |
| 446 | |
| 447 | Avida::Data::PackagePtr Avida::Data::Manager::GetCurrentValue(const DataID& data_id) const |
| 448 | { |
| 449 | PackagePtr rtn; |
| 450 | Apto::MutexAutoLock cvmutexlock(m_current_value_mutex); |
| 451 | |
| 452 | if (m_current_values.Get(data_id, rtn)) return rtn; |
| 453 | |
| 454 | if (data_id[data_id.GetSize() - 1] == ']') { |
| 455 | // Find start of argument |
| 456 | int start_idx = -1; |
| 457 | for (int i = 0; i < data_id.GetSize(); i++) { |
| 458 | if (data_id[i] == '[') { |
| 459 | start_idx = i + 1; |
| 460 | break; |
| 461 | } |
| 462 | } |
| 463 | if (start_idx == -1) return rtn; // argument start not found |
| 464 | |
| 465 | // Separate argument from incoming requested data id |
| 466 | Apto::String argument = data_id.Substring(start_idx, data_id.GetSize() - start_idx - 1); |
| 467 | DataID raw_id = data_id.Substring(0, start_idx) + "]"; |
| 468 | |
| 469 | m_rwlock.ReadLock(); |
| 470 | ArgumentedProviderPtr arg_provider; |
| 471 | if (m_active_arg_provider_map.Get(raw_id, arg_provider)) { |
| 472 | rtn = arg_provider->GetProvidedValueForArgument(raw_id, argument); |
| 473 | if (rtn) m_current_values[data_id] = rtn; |
| 474 | } |
| 475 | m_rwlock.ReadUnlock(); |
| 476 | } else { |
| 477 | m_rwlock.ReadLock(); |
| 478 | ProviderPtr provider; |
| 479 | if (m_active_provider_map.Get(data_id, provider)) { |
| 480 | rtn = provider->GetProvidedValue(data_id); |
| 481 | if (rtn) m_current_values[data_id] = rtn; |
| 482 | } |
| 483 | m_rwlock.ReadUnlock(); |
| 484 | } |
| 485 | |
| 486 | return rtn; |
| 487 | } |
| 488 |
nothing calls this directly
no test coverage detected