25 #include "ns3/core-module.h"
40 int main (
int argc,
char *argv[])
45 std::string strArg =
"strArg default";
47 const std::string attrClass =
"ns3::RandomVariableStream";
48 const std::string attrName =
"Antithetic";
49 const std::string attrPath = attrClass +
"::" + attrName;
53 const int intDef = intArg;
54 const bool boolDef = boolArg;
55 const std::string strDef = strArg;
56 const std::string cbDef =
g_cbArg;
68 cmd.
Usage (
"CommandLine example program.\n"
70 "This little program demonstrates how to use CommandLine.");
71 cmd.
AddValue (
"intArg",
"an int argument", intArg);
72 cmd.
AddValue (
"boolArg",
"a bool argument", boolArg);
73 cmd.
AddValue (
"strArg",
"a string argument", strArg);
76 cmd.
Parse (argc, argv);
79 std::cout << std::endl;
80 std::cout << cmd.
GetName () <<
":" << std::endl;
81 std::cout <<
"Initial values:" << std::endl;
83 std::cout << std::left << std::setw (10) <<
"intArg:"
86 std::cout << std::setw (10) <<
"boolArg:"
87 << std::boolalpha << boolDef << std::noboolalpha
90 std::cout << std::setw (10) <<
"strArg:"
91 <<
"\"" << strDef <<
"\""
93 std::cout << std::setw (10) <<
"anti:"
94 <<
"\"" << attrDef <<
"\""
96 std::cout << std::setw (10) <<
"cbArg:"
97 <<
"\"" << cbDef <<
"\""
99 std::cout << std::endl;
103 std::cout <<
"Final values:" << std::endl;
104 std::cout << std::left << std::setw (10) <<
"intArg:"
107 std::cout << std::setw (10) <<
"boolArg:"
108 << std::boolalpha << boolArg
112 std::cout << std::setw (10) <<
"strArg:"
113 <<
"\"" << strArg <<
"\""
121 std::cout << std::setw (10) <<
"anti:"
127 std::cout << std::setw (10) <<
"cbArg:"
int main(int argc, char *argv[])
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.
bool LookupAttributeByName(std::string name, struct AttributeInformation *info) const
bool SetCbArg(std::string val)
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.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)