ArmNN
 20.02
CommandLineProcessor Class Reference

Use Boost program options to process the command line. More...

#include <CommandLineProcessor.hpp>

Public Member Functions

bool ProcessCommandLine (int argc, char *argv[])
 
bool IsEchoEnabled ()
 
std::string GetUdsNamespace ()
 
std::string GetCommandFile ()
 

Detailed Description

Use Boost program options to process the command line.

-h or –help to print the options. -n or –namespace to specify the UDS namespace that the server will be listening on. -e or –echo print all sent and received packets to stdout. -f or –file The path to the file that contains instructions for the mock gatord.

Definition at line 20 of file CommandLineProcessor.hpp.

Member Function Documentation

◆ GetCommandFile()

std::string GetCommandFile ( )
inline

Definition at line 33 of file CommandLineProcessor.hpp.

Referenced by main().

34  {
35  return m_File;
36  }

◆ GetUdsNamespace()

std::string GetUdsNamespace ( )
inline

Definition at line 29 of file CommandLineProcessor.hpp.

Referenced by main().

30  {
31  return m_UdsNamespace;
32  }

◆ IsEchoEnabled()

bool IsEchoEnabled ( )
inline

Definition at line 24 of file CommandLineProcessor.hpp.

Referenced by main().

25  {
26  return m_Echo;
27  }

◆ ProcessCommandLine()

bool ProcessCommandLine ( int  argc,
char *  argv[] 
)

Definition at line 16 of file CommandLineProcessor.cpp.

References armnn::error.

Referenced by main().

17 {
18  namespace po = boost::program_options;
19  po::options_description desc("Options");
20  try
21  {
22  desc.add_options()
23  ("help,h", "Display help messages")
24  ("file,f", po::value<std::string>(&m_File),
25  "The path to the file that contains instructions for the mock gatord")
26  ("namespace,n", po::value<std::string>(&m_UdsNamespace)->default_value("gatord_namespace"),
27  "The Unix domain socket namespace this server will bind to.\n"
28  "This will always be prepended with \\0 to use the abstract namespace")
29  ("echo,e", po::bool_switch(&m_Echo)->default_value(false),
30  "Echo packets sent and received to stdout. Disabled by default.\n");
31  }
32  catch (const std::exception& e)
33  {
34  std::cerr << "Fatal internal error: [" << e.what() << "]" << std::endl;
35  return false;
36  }
37 
38  po::variables_map vm;
39  try
40  {
41  po::store(po::parse_command_line(argc, argv, desc), vm);
42 
43  if (vm.count("help"))
44  {
45  std::cout << "Simulate a Gatord server to interact with ArmNN external profiling." << std::endl;
46  std::cout << std::endl;
47  std::cout << desc << std::endl;
48  return false;
49  }
50  // Currently the file parameter is mandatory.
51  if (!vm.count("file"))
52  {
53  std::cout << std::endl << "*** Expected --file or -f parameter." << std::endl;
54  std::cout << std::endl;
55  std::cout << desc << std::endl;
56  return false;
57  }
58  po::notify(vm);
59  }
60  catch (const po::error& e)
61  {
62  std::cerr << e.what() << std::endl << std::endl;
63  std::cerr << desc << std::endl;
64  return false;
65  }
66 
67  return true;
68 }

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