2013-06-14 13:54:39 -07:00
|
|
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
|
|
|
|
/*
|
2013-06-14 14:01:19 -07:00
|
|
|
* Copyright (c) 2013 Lawrence Livermore National Laboratory
|
2013-06-14 13:54:39 -07:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
|
* published by the Free Software Foundation;
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
2013-06-14 14:01:19 -07:00
|
|
|
* Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
|
2013-06-14 13:54:39 -07:00
|
|
|
*/
|
|
|
|
|
|
2013-08-07 10:36:45 -07:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <iomanip>
|
2013-06-14 13:54:39 -07:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include "ns3/core-module.h"
|
|
|
|
|
|
2013-07-09 13:14:19 -07:00
|
|
|
|
2013-06-14 13:54:39 -07:00
|
|
|
using namespace ns3;
|
|
|
|
|
|
2013-07-09 13:14:19 -07:00
|
|
|
|
2013-08-07 10:36:45 -07:00
|
|
|
std::string g_cbArg="cbArg default";
|
2013-07-09 13:14:19 -07:00
|
|
|
|
2013-08-07 10:36:45 -07:00
|
|
|
bool SetCbArg (std::string val)
|
2013-07-09 13:14:19 -07:00
|
|
|
{
|
2013-08-07 10:36:45 -07:00
|
|
|
g_cbArg = val;
|
2013-07-09 13:14:19 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-06-14 13:54:39 -07:00
|
|
|
int main (int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
|
2013-08-07 10:36:45 -07:00
|
|
|
int intArg = 1;
|
|
|
|
|
bool boolArg = false;
|
|
|
|
|
std::string strArg = "strArg default";
|
2013-06-14 13:54:39 -07:00
|
|
|
|
|
|
|
|
CommandLine cmd;
|
|
|
|
|
cmd.Usage ("CommandLine example program.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"This little program demonstrates how to use CommandLine.");
|
2013-08-07 10:36:45 -07:00
|
|
|
cmd.AddValue ("intArg", "an int argument", intArg);
|
|
|
|
|
cmd.AddValue ("boolArg", "a bool argument", boolArg);
|
|
|
|
|
cmd.AddValue ("strArg", "a string argument", strArg);
|
2014-08-14 12:46:11 -07:00
|
|
|
cmd.AddValue ("anti", "ns3::RandomVariableStream::Antithetic");
|
2013-08-07 10:36:45 -07:00
|
|
|
cmd.AddValue ("cbArg", "a string via callback", MakeCallback (SetCbArg));
|
2013-06-14 13:54:39 -07:00
|
|
|
cmd.Parse (argc, argv);
|
|
|
|
|
|
2013-08-07 10:36:45 -07:00
|
|
|
std::cout << std::left
|
|
|
|
|
<< std::setw (10) << "intArg:" << intArg << std::endl;
|
|
|
|
|
std::cout << std::setw (10) << "boolArg:"
|
|
|
|
|
<< std::boolalpha << boolArg
|
|
|
|
|
<< std::noboolalpha << std::endl;
|
|
|
|
|
|
|
|
|
|
std::cout << std::setw (10) << "strArg:" << "\"" << strArg << "\"" << std::endl;
|
|
|
|
|
std::cout << std::setw (10) << "cbArg:" << "\"" << g_cbArg << "\"" << std::endl;
|
2013-06-14 13:54:39 -07:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|