QueryAttributesAndTraces

From Nsnam
Jump to navigation Jump to search

Main Page - Roadmap - Summer Projects - Project Ideas - Developer FAQ - Tools - Related Projects

HOWTOs - Installation - Troubleshooting - User FAQ - Samples - Models - Education - Contributed Code - Papers

Particularly for non-standard objects, you may wish to query for the attributes and traces declared by the object. The associated TypeId object provides methods to get that information. An example is below, where Sender is a custom class defined in a user script.

  TypeId tid = Sender::GetTypeId();
  cout << endl << "Attributes for Sender:" << endl;
  uint32_t tidn = tid.GetAttributeN();
  for (uint32_t tidcount = 0; tidcount < tidn; tidcount++) {
    cout << "  " << tid.GetAttributeFullName(tidcount) << " - " <<
      tid.GetAttributeHelp(tidcount) << endl;
  }
  cout << endl << "Trace Sources for Sender:" << endl;
  tidn = tid.GetTraceSourceN();
  for (uint32_t tidcount = 0; tidcount < tidn; tidcount++) {
    cout << "  " << tid.GetTraceSourceName(tidcount) << " - " <<
      tid.GetTraceSourceHelp(tidcount) << endl;
  }
  cout << endl;

Note also that Trace sources and Attributes are also automatically documented via Doxygen.