| 425 | } |
| 426 | |
| 427 | Monitor::TreeNode* |
| 428 | Monitor::MonitorDataStorage::getNode( |
| 429 | const std::string& label, |
| 430 | const OpenDDS::DCPS::GUID_t& parentId, |
| 431 | const OpenDDS::DCPS::GUID_t& id, |
| 432 | bool& create |
| 433 | ) |
| 434 | { |
| 435 | TreeNode* node = 0; |
| 436 | GuidToTreeMap::iterator location = this->guidToTreeMap_.find( id); |
| 437 | if( location == this->guidToTreeMap_.end()) { |
| 438 | // We are done if not creating a new node. |
| 439 | if( !create) return 0; |
| 440 | |
| 441 | // We need to add a new DomainParticipant. |
| 442 | |
| 443 | // Find the parent node, if any. It is ok to not have a parent node |
| 444 | // for cases of out-of-order udpates. We handle that as the updates |
| 445 | // are actually processed. |
| 446 | TreeNode* parent = 0; |
| 447 | GuidToTreeMap::iterator parentLocation |
| 448 | = this->guidToTreeMap_.find( parentId); |
| 449 | if( parentLocation != this->guidToTreeMap_.end()) { |
| 450 | parent = parentLocation->second.second; |
| 451 | } |
| 452 | |
| 453 | // Node data. |
| 454 | QList<QVariant> list; |
| 455 | list << QString( QObject::tr( label.c_str())) |
| 456 | << QString( QObject::tr( OpenDDS::DCPS::LogGuid( id).c_str())); |
| 457 | node = new TreeNode( list, parent); |
| 458 | if( parent) { |
| 459 | parent->append( node); |
| 460 | } |
| 461 | |
| 462 | // Install the new node. |
| 463 | this->guidToTreeMap_[ id] = std::make_pair( node->row(), node); |
| 464 | |
| 465 | } else { |
| 466 | node = location->second.second; |
| 467 | create = false; |
| 468 | } |
| 469 | |
| 470 | // If there have been some out-of-order reports, we may have been |
| 471 | // created without a parent node. We can now fill in that information |
| 472 | // if we can. If we created the node, we already know it has a |
| 473 | // parent so this will be bypassed. |
| 474 | if( !node->parent()) { |
| 475 | // Need to search for the parent. |
| 476 | TreeNode* parent = 0; |
| 477 | GuidToTreeMap::iterator parentLocation |
| 478 | = this->guidToTreeMap_.find( parentId); |
| 479 | if( parentLocation != this->guidToTreeMap_.end()) { |
| 480 | parent = parentLocation->second.second; |
| 481 | } |
| 482 | |
| 483 | // And install anything that is found. |
| 484 | node->parent() = parent; |