A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::CommandLine Class Reference

parse command-line argumentsInstances of this class can be used to parse command-line arguments: users can register new arguments with CommandLine::AddValue but the most important functionality provided by this class is that it can be used to set the 'initial value' of every attribute in the system with the More...

#include <command-line.h>

+ Collaboration diagram for ns3::CommandLine:

Classes

class  CallbackItem
class  Item
class  UserItem

Public Member Functions

 CommandLine ()
 CommandLine (const CommandLine &cmd)
 ~CommandLine ()
template<typename T >
void AddValue (const std::string &name, const std::string &help, T &value)
void AddValue (const std::string &name, const std::string &help, Callback< bool, std::string > callback)
CommandLineoperator= (const CommandLine &cmd)
void Parse (int argc, char *argv[]) const

Private Types

typedef std::list< Item * > Items

Private Member Functions

void Clear (void)
void Copy (const CommandLine &cmd)
void HandleArgument (std::string name, std::string value) const
void PrintAttributes (std::string type) const
void PrintGlobals (void) const
void PrintGroup (std::string group) const
void PrintGroups (void) const
void PrintHelp (void) const
void PrintTypeIds (void) const

Private Attributes

Items m_items

Detailed Description

parse command-line arguments

Instances of this class can be used to parse command-line arguments: users can register new arguments with CommandLine::AddValue but the most important functionality provided by this class is that it can be used to set the 'initial value' of every attribute in the system with the

*   --TypeIdName::AttributeName=value
* 

syntax and it can be used to set the value of every GlobalValue in the system with the

*   --GlobalValueName=value
* 

syntax.

Definition at line 50 of file command-line.h.

Member Typedef Documentation

Definition at line 124 of file command-line.h.

Constructor & Destructor Documentation

ns3::CommandLine::CommandLine ( )

Definition at line 33 of file command-line.cc.

ns3::CommandLine::CommandLine ( const CommandLine cmd)

Definition at line 36 of file command-line.cc.

References Copy().

+ Here is the call graph for this function:

ns3::CommandLine::~CommandLine ( )

Definition at line 47 of file command-line.cc.

References Clear().

+ Here is the call graph for this function:

Member Function Documentation

template<typename T >
void ns3::CommandLine::AddValue ( const std::string &  name,
const std::string &  help,
T &  value 
)
Parameters
namethe name of the user-supplied argument
helpsome help text used by –PrintHelp
valuea reference to the variable where the value parsed will be stored (if no value is parsed, this variable is not modified).

Definition at line 134 of file command-line.h.

References ns3::CommandLine::Item::m_help, m_items, ns3::CommandLine::Item::m_name, and ns3::CommandLine::UserItem< T >::m_valuePtr.

Referenced by AodvExample::Configure(), MeshTest::Configure(), ns3::CommandLineBooleanTestCase::DoRun(), ns3::CommandLineIntTestCase::DoRun(), ns3::CommandLineUnsignedIntTestCase::DoRun(), ns3::CommandLineStringTestCase::DoRun(), main(), PrintPsr(), PrintPsrVsCollisionInterval(), PrintPsrVsDistance(), and PrintSizeVsRange().

+ Here is the caller graph for this function:

void ns3::CommandLine::AddValue ( const std::string &  name,
const std::string &  help,
Callback< bool, std::string >  callback 
)
Parameters
namethe name of the user-supplied argument
helpsome help text used by –PrintHelp
callbacka callback function that will be invoked to parse and collect the value. This normally used by language bindings.

Definition at line 297 of file command-line.cc.

References ns3::CommandLine::CallbackItem::m_callback, ns3::CommandLine::Item::m_help, m_items, ns3::CommandLine::Item::m_name, and NS_LOG_FUNCTION.

void ns3::CommandLine::Clear ( void  )
private

Definition at line 61 of file command-line.cc.

References m_items.

Referenced by operator=(), and ~CommandLine().

+ Here is the caller graph for this function:

void ns3::CommandLine::Copy ( const CommandLine cmd)
private

Definition at line 52 of file command-line.cc.

References m_items.

Referenced by CommandLine(), and operator=().

+ Here is the caller graph for this function:

void ns3::CommandLine::HandleArgument ( std::string  name,
std::string  value 
) const
private

Definition at line 223 of file command-line.cc.

References m_items, NS_LOG_DEBUG, PrintAttributes(), PrintGlobals(), PrintGroup(), PrintGroups(), PrintHelp(), PrintTypeIds(), ns3::Config::SetDefaultFailSafe(), and ns3::Config::SetGlobalFailSafe().

Referenced by Parse().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CommandLine & ns3::CommandLine::operator= ( const CommandLine cmd)

Definition at line 41 of file command-line.cc.

References Clear(), and Copy().

+ Here is the call graph for this function:

void ns3::CommandLine::Parse ( int  argc,
char *  argv[] 
) const
Parameters
argcthe 'argc' variable: number of arguments (including the main program name as first element).
argvthe 'argv' variable: a null-terminated array of strings, each of which identifies a command-line argument.

Obviously, this method will parse the input command-line arguments and will attempt to handle them all.

Definition at line 75 of file command-line.cc.

References HandleArgument().

Referenced by AodvExample::Configure(), MeshTest::Configure(), main(), and ns3::CommandLineTestCaseBase::Parse().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::CommandLine::PrintAttributes ( std::string  type) const
private
void ns3::CommandLine::PrintGlobals ( void  ) const
private

Definition at line 136 of file command-line.cc.

References ns3::GlobalValue::Begin(), ns3::GlobalValue::End(), and ns3::StringValue::Get().

Referenced by HandleArgument().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::CommandLine::PrintGroup ( std::string  group) const
private

Definition at line 168 of file command-line.cc.

References ns3::TypeId::GetGroupName(), ns3::TypeId::GetName(), ns3::TypeId::GetRegistered(), ns3::TypeId::GetRegisteredN(), and visualizer.higcontainer::group.

Referenced by HandleArgument().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::CommandLine::PrintGroups ( void  ) const
private

Definition at line 191 of file command-line.cc.

References ns3::TypeId::GetGroupName(), ns3::TypeId::GetRegistered(), ns3::TypeId::GetRegisteredN(), and visualizer.higcontainer::group.

Referenced by HandleArgument().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::CommandLine::PrintHelp ( void  ) const
private

Definition at line 117 of file command-line.cc.

References m_items.

Referenced by HandleArgument().

+ Here is the caller graph for this function:

void ns3::CommandLine::PrintTypeIds ( void  ) const
private

Definition at line 181 of file command-line.cc.

References ns3::TypeId::GetName(), ns3::TypeId::GetRegistered(), and ns3::TypeId::GetRegisteredN().

Referenced by HandleArgument().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

Items ns3::CommandLine::m_items
private

Definition at line 125 of file command-line.h.

Referenced by AddValue(), Clear(), Copy(), HandleArgument(), and PrintHelp().


The documentation for this class was generated from the following files: