Apollo 10.0
自动驾驶开放平台
apollo::cyber::BridgeArgument类 参考

#include <bridge_argument.h>

apollo::cyber::BridgeArgument 的协作图:

Public 成员函数

 BridgeArgument ()=default
 
virtual ~BridgeArgument ()=default
 
void DisplayUsage ()
 
void ParseArgument (int argc, char *const argv[])
 
void GetOptions (const int argc, char *const argv[])
 
const std::string & GetBinaryName () const
 
const bool GetEnableCpuprofile () const
 
const std::string GetProfileFilename () const
 
const bool GetEnableHeapprofile () const
 
const std::string GetHeapProfileFilename () const
 

详细描述

在文件 bridge_argument.h29 行定义.

构造及析构函数说明

◆ BridgeArgument()

apollo::cyber::BridgeArgument::BridgeArgument ( )
default

◆ ~BridgeArgument()

virtual apollo::cyber::BridgeArgument::~BridgeArgument ( )
virtualdefault

成员函数说明

◆ DisplayUsage()

void apollo::cyber::BridgeArgument::DisplayUsage ( )

在文件 bridge_argument.cc25 行定义.

25 {
26 AINFO << "Usage: \n " << binary_name_ << " [OPTION]...\n"
27 << "Description: \n"
28 << " -h, --help: help information \n"
29 << " -c, --cpuprofile: enable gperftools cpu profile\n"
30 << " -o, --profile_filename=filename: the filename to dump the "
31 "profile to, default value is ${binary_name}_cpu.prof. Only work "
32 "with -c option\n"
33 << " -H, --heapprofile: enable gperftools heap profile\n"
34 << " -O, --heapprofile_filename=filename: the filename to dump the "
35 "profile to, default value is ${binary_name}_mem.prof. Only work "
36 "with -H option\n"
37 << "Example:\n"
38 << " " << binary_name_ << " -h\n"
39 << " " << binary_name_ << " -c -H ";
40}
#define AINFO
Definition log.h:42

◆ GetBinaryName()

const std::string & apollo::cyber::BridgeArgument::GetBinaryName ( ) const
inline

在文件 bridge_argument.h52 行定义.

52 {
53 return binary_name_;
54}

◆ GetEnableCpuprofile()

const bool apollo::cyber::BridgeArgument::GetEnableCpuprofile ( ) const
inline

在文件 bridge_argument.h37 行定义.

37{ return enable_cpuprofile_; }

◆ GetEnableHeapprofile()

const bool apollo::cyber::BridgeArgument::GetEnableHeapprofile ( ) const
inline

在文件 bridge_argument.h39 行定义.

39{ return enable_heapprofile_; }

◆ GetHeapProfileFilename()

const std::string apollo::cyber::BridgeArgument::GetHeapProfileFilename ( ) const
inline

在文件 bridge_argument.h40 行定义.

40 {
41 return heapprofile_filename_;
42 }

◆ GetOptions()

void apollo::cyber::BridgeArgument::GetOptions ( const int  argc,
char *const  argv[] 
)

在文件 bridge_argument.cc57 行定义.

57 {
58 opterr = 0; // extern int opterr
59 int long_index = 0;
60 const std::string short_opts = "hco:HO:";
61 static const struct option long_opts[] = {
62 {"help", no_argument, nullptr, 'h'},
63 {"cpuprofile", no_argument, nullptr, 'c'},
64 {"profile_filename", required_argument, nullptr, 'o'},
65 {"heapprofile", no_argument, nullptr, 'H'},
66 {"heapprofile_filename", required_argument, nullptr, 'O'},
67 {NULL, no_argument, nullptr, 0}};
68
69 // log command for info
70 std::string cmd("");
71 for (int i = 0; i < argc; ++i) {
72 cmd += argv[i];
73 cmd += " ";
74 }
75 AINFO << "command: " << cmd;
76
77 do {
78 int opt =
79 getopt_long(argc, argv, short_opts.c_str(), long_opts, &long_index);
80 if (opt == -1) {
81 break;
82 }
83 switch (opt) {
84 case 'c':
85 enable_cpuprofile_ = true;
86 break;
87 case 'o':
88 profile_filename_ = std::string(optarg);
89 break;
90 case 'H':
91 enable_heapprofile_ = true;
92 break;
93 case 'O':
94 heapprofile_filename_ = std::string(optarg);
95 break;
96 case 'h':
98 exit(0);
99 default:
100 break;
101 }
102 } while (true);
103
104 if (optind < argc) {
105 AINFO << "Found non-option ARGV-element \"" << argv[optind++] << "\"";
106 DisplayUsage();
107 exit(1);
108 }
109}

◆ GetProfileFilename()

const std::string apollo::cyber::BridgeArgument::GetProfileFilename ( ) const
inline

在文件 bridge_argument.h38 行定义.

38{ return profile_filename_; }

◆ ParseArgument()

void apollo::cyber::BridgeArgument::ParseArgument ( int  argc,
char *const  argv[] 
)

在文件 bridge_argument.cc42 行定义.

42 {
43 binary_name_ = std::string(basename(argv[0]));
44 GetOptions(argc, argv);
45
46 if (enable_cpuprofile_ && profile_filename_.empty()) {
47 profile_filename_ = binary_name_ + std::string("_cpu.prof");
48 }
49
50 if (enable_heapprofile_ && heapprofile_filename_.empty()) {
51 heapprofile_filename_ = binary_name_ + std::string("_mem.prof");
52 }
53
54 AINFO << "binary_name_ is " << binary_name_;
55}
void GetOptions(const int argc, char *const argv[])

该类的文档由以下文件生成: