25 #include "ns3/core-module.h" 
   56 int main (
int argc, 
char *argv[])
 
   61   std::string strArg  = 
"strArg default";
 
   63   const std::string attrClass = 
"ns3::RandomVariableStream";
 
   64   const std::string attrName  = 
"Antithetic";
 
   65   const std::string attrPath  = attrClass + 
"::" + attrName;
 
   69   const int intDef = intArg;
 
   70   const bool boolDef = boolArg;
 
   71   const std::string strDef = strArg;
 
   72   const std::string cbDef  = 
g_cbArg;
 
   79     attrDef = info.originalInitialValue->SerializeToString (info.checker);
 
   84   cmd.
Usage (
"CommandLine example program.\n" 
   86              "This little program demonstrates how to use CommandLine.");
 
   87   cmd.
AddValue (
"intArg",  
"an int argument",       intArg);
 
   88   cmd.
AddValue (
"boolArg", 
"a bool argument",       boolArg);
 
   89   cmd.
AddValue (
"strArg",  
"a string argument",     strArg);
 
   92   cmd.
Parse (argc, argv);
 
   95   std::cout << std::endl;
 
   96   std::cout << cmd.
GetName () << 
":" << std::endl;
 
   97   std::cout << 
"Initial values:" << std::endl;
 
   99   std::cout << std::left << std::setw (10) << 
"intArg:" 
  102   std::cout << std::setw (10)              << 
"boolArg:" 
  103             << std::boolalpha  << boolDef  << std::noboolalpha
 
  106   std::cout << std::setw (10)              << 
"strArg:" 
  107             << 
"\""            << strDef   << 
"\"" 
  109   std::cout << std::setw (10)              << 
"anti:" 
  110             << 
"\""            << attrDef  << 
"\"" 
  112   std::cout << std::setw (10)              << 
"cbArg:" 
  113             << 
"\""            << cbDef    << 
"\"" 
  115   std::cout << std::endl;
 
  119   std::cout << 
"Final values:" << std::endl;
 
  120   std::cout << std::left << std::setw (10) << 
"intArg:" 
  123   std::cout << std::setw (10)              << 
"boolArg:" 
  124             << std::boolalpha  << boolArg
 
  128   std::cout << std::setw (10)              << 
"strArg:" 
  129             << 
"\""            << strArg   << 
"\"" 
  137     std::cout << std::setw (10)            << 
"anti:" 
  139               << info.initialValue->SerializeToString (info.checker)
 
  143   std::cout << std::setw (10)              << 
"cbArg:" 
std::string GetName() const 
Get the program name. 
 
void Usage(const std::string usage)
Supply the program usage and documentation. 
 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
 
Parse command-line arguments. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
bool LookupAttributeByName(std::string name, struct AttributeInformation *info) const 
Find an Attribute by name. 
 
bool SetCbArg(std::string val)
Function to illustrate command line arguments handled by a Callback function. 
 
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD. 
 
void Parse(int argc, char *argv[])
Parse the program arguments. 
 
std::string g_cbArg
Global variable to illustrate command line arguments handled by a Callback function. 
 
a unique identifier for an interface. 
 
static TypeId LookupByName(std::string name)
Get a TypeId by name.