Exemplo n.º 1
0
void
Monitor::MonitorDataStorage::manageTopicLink(
  TreeNode*                    node,
  const OpenDDS::DCPS::GUID_t& dp_id,
  const OpenDDS::DCPS::GUID_t& topic_id,
  bool&                        create
)
{
  // This gets a bit tedious.  Here are the cases:
  // 1) We currently have no reference, and found a Topic node to
  //    reference:
  //    - attach a reference to the topic node;
  // 2) We currently have no reference, and found a Name node to
  //    reference:
  //    - attach a reference to the name node;
  // 3) We currently have a Topic node referenced, and found the same
  //    topic node to reference:
  //    - nothing to do;
  // 4) We currently have a Topic node referenced, and found a different
  //    Topic node to reference:
  //    - detach previous reference and reattach to new topic node;
  // 5) We currently have a Topic node referenced, but were able to find
  //    a name node to reference:
  //    - detach previous reference and reattach to new name node;
  // 6) We currently have a Name node referenced, and found the same name
  //    node to reference:
  //    - nothing to do;
  // 7) We currently have a Name node referenced, and found a different
  //    name node to reference:
  //    - detach previous reference and reattach to new name node;
  // 8) We currently have a Name node referenced, and found a different
  //    Topic node to reference:
  //    - detach previous reference and reattach to new topic node.
  //
  // Note that cases (4), (7), and (8) indicate inconsistent data reports
  // and are error conditions.  We chose to not handle these cases.
  // Cases (3) and (6) require no action, so the only code paths we need
  // to consider are for cases (1), (2), and (5).

  // Find the actual topic.
  TreeNode* topicNode = this->getNode(
                          std::string( "Topic"),
                          dp_id,
                          topic_id,
                          create
                        );
  if( !topicNode) {
    return;
  }

  // Find the topic name to reference instead of the GUID value.
  TreeNode* nameNode = 0;
  QString nameLabel( QObject::tr( "Topic Name"));
  int row = topicNode->indexOf( 0, nameLabel);
  if( row != -1) {
    nameNode = (*topicNode)[ row];
  }

  // Check for an existing Topic entry.
  QString topicLabel( QObject::tr( "Topic"));
  int topicRow = node->indexOf( 0, topicLabel);
  if( nameNode && topicRow != -1) {
    // Case 5: We have a topic reference and found a name reference,
    //         remove the existing topic reference
    TreeNode* topicRef = (*node)[ topicRow];
    if( topicRef && topicRef->valueSource()) {
      topicRef->valueSource()->removeValueRef( topicRef);
    }
//  node->removeChildren( topicRow, 1); // DEVELOPMENT: don't delete to show stale data.
  }

  // The node to install.
  TreeNode* refNode = nameNode;
  if( !refNode) {
    refNode = topicNode;
  }

  // Check to see if we need to create a name entry.
  int nameRow  = node->indexOf( 0, nameLabel);
  if( nameRow == -1) {
    // New entry, add a reference to the topic or its name.
    QList<QVariant> list;
    list << topicLabel << QString( QObject::tr("<error>"));
    TreeNode* idNode = new TreeNode( list, node);
    idNode->setColor( 1, QColor("#bfbfff"));
    node->append( idNode);
    refNode->addValueRef( idNode);
    refNode->setColor( 1, QColor("#bfffbf"));
    create = true;
  }
}
Exemplo n.º 2
0
void
Monitor::MonitorDataStorage::manageTransportLink(
  TreeNode* node,
  int       transport_id,
  bool&     create
)
{
  // Start by finding the participant node.
  TreeNode* processNode = node->parent();
  if( processNode) {
    // And follow it to the actual process node.
    processNode = processNode->parent();

  } else {
    // Horribly corrupt model, something oughta been done about it!
    ACE_ERROR((LM_ERROR,
      ACE_TEXT("(%P|%t) ERROR: MonitorDataStorage::manageTransportLink() - ")
      ACE_TEXT("unable to locate the ancestor process node!\n")
    ));
    return;
  }

  // Then finds its key in the maps.
  ProcessKey processKey;
  std::pair< bool, ProcessKey> pResult
    = this->findKey( this->processToTreeMap_, processNode);
  if( pResult.first) {
    processKey = pResult.second;

  } else {
    // Horribly corrupt model, something oughta been done about it!
    ACE_ERROR((LM_ERROR,
      ACE_TEXT("(%P|%t) ERROR: MonitorDataStorage::manageTransportLink() - ")
      ACE_TEXT("unable to locate the process node in the maps!\n")
    ));
    return;
  }

  // Now we have enough information to build a TransportKey and find or
  // create a transport node for our Id value.
  TransportKey transportKey(
                 processKey.host,
                 processKey.pid,
                 transport_id
               );
  TreeNode* transportNode = this->getTransportNode( transportKey, create);
  if( !node) {
    return;
  }

  // Transport Id display.
  QString label( QObject::tr( "Transport"));
  int row = node->indexOf( 0, label);
  if( row == -1) {
    // New entry, add a reference to the actual transport node.
    QList<QVariant> list;
    list << label << QString( QObject::tr("<error>"));;
    TreeNode* idNode = new TreeNode( list, node);
    idNode->setColor( 1, QColor("#bfbfff"));
    node->append( idNode);
    transportNode->addValueRef( idNode);
    transportNode->setColor( 1, QColor("#bfffbf"));
    create = true;
  }
}