Apollo 11.0
自动驾驶开放平台
apollo::cyber::mainboard::ModuleArgument类 参考

#include <module_argument.h>

apollo::cyber::mainboard::ModuleArgument 的协作图:

Public 成员函数

 ModuleArgument ()=default
 
virtual ~ModuleArgument ()=default
 
void DisplayUsage ()
 
void ParseArgument (int argc, char *const argv[])
 
void GetOptions (const int argc, char *const argv[])
 
const std::string & GetBinaryName () const
 
const std::string & GetProcessGroup () const
 
const std::string & GetSchedName () const
 
const std::list< std::string > & GetDAGConfList () const
 
const std::list< std::string > & GetPluginDescriptionList () const
 
const bool GetEnableCpuprofile () const
 
const std::string GetProfileFilename () const
 
const bool GetEnableHeapprofile () const
 
const std::string GetHeapProfileFilename () const
 
const bool & GetDisablePluginsAutoLoad () const
 

详细描述

在文件 module_argument.h 第 38 行定义.

构造及析构函数说明

◆ ModuleArgument()

apollo::cyber::mainboard::ModuleArgument::ModuleArgument ( )
default

◆ ~ModuleArgument()

virtual apollo::cyber::mainboard::ModuleArgument::~ModuleArgument ( )
virtualdefault

成员函数说明

◆ DisplayUsage()

void apollo::cyber::mainboard::ModuleArgument::DisplayUsage ( )

在文件 module_argument.cc 第 32 行定义.

32 {
33 AINFO << "Usage: \n " << binary_name_ << " [OPTION]...\n"
34 << "Description: \n"
35 << " -h, --help: help information \n"
36 << " -d, --dag_conf=CONFIG_FILE: module dag config file\n"
37 << " -p, --process_group=process_group: the process "
38 "namespace for running this module, default in manager process\n"
39 << " -s, --sched_name=sched_name: sched policy "
40 "conf for hole process, sched_name should be conf in cyber.pb.conf\n"
41 << " --plugin=plugin_description_file_path: the description file of "
42 "plugin\n"
43 << " --disable_plugin_autoload : default enable autoload "
44 "mode of plugins, use disable_plugin_autoload to ingore autoload\n"
45 << " -c, --cpuprofile: enable gperftools cpu profile\n"
46 << " -o, --profile_filename=filename: the filename to dump the "
47 "profile to, default value is ${process_group}_cpu.prof. Only work "
48 "with -c option\n"
49 << " -H, --heapprofile: enable gperftools heap profile\n"
50 << " -O, --heapprofile_filename=filename: the filename to dump the "
51 "profile to, default value is ${process_group}_mem.prof. Only work "
52 "with -c option\n"
53 << "Example:\n"
54 << " " << binary_name_ << " -h\n"
55 << " " << binary_name_ << " -d dag_conf_file1 -d dag_conf_file2 "
56 << "-p process_group -s sched_name\n"
57 << " " << binary_name_ << " --plugin plugin_xml_conf -d dag_conf ";
58}
#define AINFO
Definition log.h:42

◆ GetBinaryName()

const std::string & apollo::cyber::mainboard::ModuleArgument::GetBinaryName ( ) const
inline

在文件 module_argument.h 第 71 行定义.

71 {
72 return binary_name_;
73}

◆ GetDAGConfList()

const std::list< std::string > & apollo::cyber::mainboard::ModuleArgument::GetDAGConfList ( ) const
inline

在文件 module_argument.h 第 83 行定义.

83 {
84 return dag_conf_list_;
85}

◆ GetDisablePluginsAutoLoad()

const bool & apollo::cyber::mainboard::ModuleArgument::GetDisablePluginsAutoLoad ( ) const
inline

在文件 module_argument.h 第 92 行定义.

92 {
93 return disable_plugin_autoload_;
94}

◆ GetEnableCpuprofile()

const bool apollo::cyber::mainboard::ModuleArgument::GetEnableCpuprofile ( ) const
inline

在文件 module_argument.h 第 50 行定义.

50{ return enable_cpuprofile_; }

◆ GetEnableHeapprofile()

const bool apollo::cyber::mainboard::ModuleArgument::GetEnableHeapprofile ( ) const
inline

在文件 module_argument.h 第 52 行定义.

52{ return enable_heapprofile_; }

◆ GetHeapProfileFilename()

const std::string apollo::cyber::mainboard::ModuleArgument::GetHeapProfileFilename ( ) const
inline

在文件 module_argument.h 第 53 行定义.

53 {
54 return heapprofile_filename_;
55 }

◆ GetOptions()

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

在文件 module_argument.cc 第 89 行定义.

89 {
90 opterr = 0; // extern int opterr
91 int long_index = 0;
92 const std::string short_opts = "hd:p:s:co:HO:";
93 static const struct option long_opts[] = {
94 {"help", no_argument, nullptr, 'h'},
95 {"dag_conf", required_argument, nullptr, 'd'},
96 {"process_name", required_argument, nullptr, 'p'},
97 {"sched_name", required_argument, nullptr, 's'},
98 {"plugin", required_argument, nullptr, ARGS_OPT_CODE_PLUGIN},
99 {"disable_plugin_autoload", no_argument, nullptr,
100 ARGS_OPT_CODE_DISABLE_PLUGIN_AUTOLOAD},
101 {"cpuprofile", no_argument, nullptr, 'c'},
102 {"profile_filename", required_argument, nullptr, 'o'},
103 {"heapprofile", no_argument, nullptr, 'H'},
104 {"heapprofile_filename", required_argument, nullptr, 'O'},
105 {NULL, no_argument, nullptr, 0}};
106
107 // log command for info
108 std::string cmd("");
109 for (int i = 0; i < argc; ++i) {
110 cmd += argv[i];
111 cmd += " ";
112 }
113 AINFO << "command: " << cmd;
114
115 if (1 == argc) {
116 DisplayUsage();
117 exit(0);
118 }
119
120 do {
121 int opt =
122 getopt_long(argc, argv, short_opts.c_str(), long_opts, &long_index);
123 if (opt == -1) {
124 break;
125 }
126 switch (opt) {
127 case 'd':
128 dag_conf_list_.emplace_back(std::string(optarg));
129 for (int i = optind; i < argc; i++) {
130 if (*argv[i] != '-') {
131 dag_conf_list_.emplace_back(std::string(argv[i]));
132 } else {
133 break;
134 }
135 }
136 break;
137 case 'p':
138 process_group_ = std::string(optarg);
139 break;
140 case 's':
141 sched_name_ = std::string(optarg);
142 break;
143 case ARGS_OPT_CODE_PLUGIN:
144 plugin_description_list_.emplace_back(std::string(optarg));
145 break;
146 case ARGS_OPT_CODE_DISABLE_PLUGIN_AUTOLOAD:
147 disable_plugin_autoload_ = true;
148 break;
149 case 'c':
150#ifndef BASE_PROFILER_H_
151 AWARN << "gperftools not installed, ignore perf parameters";
152#endif
153 enable_cpuprofile_ = true;
154 break;
155 case 'o':
156 profile_filename_ = std::string(optarg);
157 break;
158 case 'H':
159#ifndef BASE_PROFILER_H_
160 AWARN << "gperftools not installed, ignore perf parameters";
161#endif
162 enable_heapprofile_ = true;
163 break;
164 case 'O':
165 heapprofile_filename_ = std::string(optarg);
166 break;
167 case 'h':
168 DisplayUsage();
169 exit(0);
170 default:
171 break;
172 }
173 } while (true);
174
175 if (optind < argc) {
176 AINFO << "Found non-option ARGV-element \"" << argv[optind++] << "\"";
177 DisplayUsage();
178 exit(1);
179 }
180
181 if (dag_conf_list_.empty()) {
182 AINFO << "-d parameter must be specified";
183 DisplayUsage();
184 exit(1);
185 }
186}
#define AWARN
Definition log.h:43

◆ GetPluginDescriptionList()

const std::list< std::string > & apollo::cyber::mainboard::ModuleArgument::GetPluginDescriptionList ( ) const
inline

在文件 module_argument.h 第 87 行定义.

88 {
89 return plugin_description_list_;
90}

◆ GetProcessGroup()

const std::string & apollo::cyber::mainboard::ModuleArgument::GetProcessGroup ( ) const
inline

在文件 module_argument.h 第 75 行定义.

75 {
76 return process_group_;
77}

◆ GetProfileFilename()

const std::string apollo::cyber::mainboard::ModuleArgument::GetProfileFilename ( ) const
inline

在文件 module_argument.h 第 51 行定义.

51{ return profile_filename_; }

◆ GetSchedName()

const std::string & apollo::cyber::mainboard::ModuleArgument::GetSchedName ( ) const
inline

在文件 module_argument.h 第 79 行定义.

79 {
80 return sched_name_;
81}

◆ ParseArgument()

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

在文件 module_argument.cc 第 60 行定义.

60 {
61 binary_name_ = std::string(basename(argv[0]));
62 GetOptions(argc, argv);
63
64 if (process_group_.empty()) {
65 process_group_ = DEFAULT_process_group_;
66 }
67
68 if (sched_name_.empty()) {
69 sched_name_ = DEFAULT_sched_name_;
70 }
71
72 if (enable_cpuprofile_ && profile_filename_.empty()) {
73 profile_filename_ = process_group_ + std::string("_cpu.prof");
74 }
75
76 if (enable_heapprofile_ && heapprofile_filename_.empty()) {
77 heapprofile_filename_ = process_group_ + std::string("_mem.prof");
78 }
79
80 GlobalData::Instance()->SetProcessGroup(process_group_);
81 GlobalData::Instance()->SetSchedName(sched_name_);
82 AINFO << "binary_name_ is " << binary_name_ << ", process_group_ is "
83 << process_group_ << ", has " << dag_conf_list_.size() << " dag conf";
84 for (std::string& dag : dag_conf_list_) {
85 AINFO << "dag_conf: " << dag;
86 }
87}
void GetOptions(const int argc, char *const argv[])

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