9#include "ns3/core-module.h"
58#define DefaultFinal(label, defaultValue, finalValue) \
59 std::left << std::setw(20) << label + std::string(":") << std::setw(20) << defaultValue \
68 std::string
strArg =
"strArg default";
71 const std::string
attrClass =
"ns3::RandomVariableStream";
72 const std::string
attrName =
"Antithetic";
102 cmd.Usage(
"CommandLine example program.\n"
104 "This little program demonstrates how to use CommandLine.");
105 cmd.AddValue(
"intArg",
"an int argument",
intArg);
106 cmd.AddValue(
"boolArg",
"a bool argument",
boolArg);
107 cmd.AddValue(
"strArg",
"a string argument",
strArg);
111 cmd.AddNonOption(
"nonOpt1",
"first non-option",
nonOpt1);
112 cmd.AddNonOption(
"nonOpt2",
"second non-option",
nonOpt2);
116 std::cout << std::endl;
117 std::cout << cmd.GetName() <<
":" << std::endl;
120 std::cout <<
"Program Version: ";
121 cmd.PrintVersion(std::cout);
122 std::cout << std::endl;
124 std::cout <<
"Argument Initial Value Final Value\n"
125 << std::left << std::boolalpha;
145 "\"" + std::string(
charbuf) +
"\"")
149 std::cout << std::setw(40)
150 <<
"Number of extra non-option arguments:" << cmd.GetNExtraNonOptions() << std::endl;
152 for (std::size_t
i = 0;
i < cmd.GetNExtraNonOptions(); ++
i)
154 std::cout <<
DefaultFinal(
"extra non-option " + std::to_string(
i),
156 "\"" + cmd.GetExtraNonOption(
i) +
"\"");
158 std::cout << std::endl;
Parse command-line arguments.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
bool LookupAttributeByName(std::string name, AttributeInformation *info, bool permissive=false) const
Find an Attribute by name, retrieving the associated AttributeInformation.
#define DefaultFinal(label, defaultValue, finalValue)
Print a row containing the name, the default and the final values of an argument.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
std::string g_cbArg
Global variable to illustrate command line arguments handled by a Callback function.
bool SetCbArg(const std::string &val)
Function to illustrate command line arguments handled by a Callback function.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...