Apollo 11.0
自动驾驶开放平台
apollo::planning::ConfigUtil类 参考

#include <config_util.h>

apollo::planning::ConfigUtil 的协作图:

静态 Public 成员函数

static std::string TransformToPathName (const std::string &name)
 Tranform the name to part of path.
 
static std::string GetFullPlanningClassName (const std::string &class_name)
 Given the class name of planning module, combine the namespace "apollo::planning::" with it to create an instance of the class.
 
template<typename T >
static bool LoadMergedConfig (const std::string &default_config_path, const std::string &config_path, T *config)
 Load the config and merge the default and user defined config.
 
template<typename T >
static bool LoadOverridedConfig (const std::string &default_config_path, const std::string &config_path, T *config)
 Load the config and override the default config by the user defined one.
 

详细描述

在文件 config_util.h27 行定义.

成员函数说明

◆ GetFullPlanningClassName()

std::string apollo::planning::ConfigUtil::GetFullPlanningClassName ( const std::string &  class_name)
static

Given the class name of planning module, combine the namespace "apollo::planning::" with it to create an instance of the class.

参数
class_nameThe class name without namespace.
返回
The planning class name with namespace.

在文件 config_util.cc32 行定义.

33 {
34 static const std::string kNameSpace = "apollo::planning::";
35 // If the class name already has namespace in it, do nothing.
36 if (class_name.find("::") != std::string::npos) {
37 return class_name;
38 }
39 return kNameSpace + class_name;
40}

◆ LoadMergedConfig()

template<typename T >
bool apollo::planning::ConfigUtil::LoadMergedConfig ( const std::string &  default_config_path,
const std::string &  config_path,
T *  config 
)
static

Load the config and merge the default and user defined config.

参数
default_config_pathThe default config path, if the parameter is not defined in config_path, use that in this file as default.
config_pathThe config path
configThe output config data.
返回
Load result, return true for success.

在文件 config_util.h76 行定义.

77 {
78 CHECK_NOTNULL(config);
79 // Get the default config, will be merged by the user defined
80 // "spcific_config".
81 if (!apollo::cyber::common::LoadConfig<T>(default_config_path, config)) {
82 AERROR << "Failed to load default config file:" << default_config_path;
83 }
84 // Get the user defined "spcific_config".
85 T spcific_config;
86 if (!apollo::cyber::common::LoadConfig<T>(config_path, &spcific_config)) {
87 AWARN << "can not load user defined config file[" << config_path
88 << "], use default config instead";
89 return true;
90 }
91 config->MergeFrom(spcific_config);
92 return true;
93}
#define AERROR
Definition log.h:44
#define AWARN
Definition log.h:43

◆ LoadOverridedConfig()

template<typename T >
bool apollo::planning::ConfigUtil::LoadOverridedConfig ( const std::string &  default_config_path,
const std::string &  config_path,
T *  config 
)
static

Load the config and override the default config by the user defined one.

If the user defined config doesn't exit, use the default.

参数
default_config_pathThe default config path, if the parameter is not defined in config_path, use that in this file as default.
config_pathThe config path
configThe output config data.
返回
Load result, return true for success.

在文件 config_util.h96 行定义.

98 {
99 CHECK_NOTNULL(config);
100 // Get the user defined "spcific_config".
101 if (apollo::cyber::common::GetProtoFromFile(config_path, config)) {
102 return true;
103 }
104 // Get the default config.
105 if (!apollo::cyber::common::GetProtoFromFile(default_config_path, config)) {
106 AERROR << "Failed to load config file using the default config:"
107 << default_config_path;
108 return false;
109 }
110 return true;
111}
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132

◆ TransformToPathName()

std::string apollo::planning::ConfigUtil::TransformToPathName ( const std::string &  name)
static

Tranform the name to part of path.

The path must be all in lower cases.

参数
nameThe name to be transformed.
返回
The transformed name in lower cases.

在文件 config_util.cc26 行定义.

26 {
27 std::string output = name;
28 std::transform(name.begin(), name.end(), output.begin(), ::tolower);
29 return output;
30}

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