QueryAttributesAndTraces

From Nsnam
Revision as of 14:19, 24 May 2008 by Tjkopena (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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;