31 for (
auto& component : component_list_) {
32 component->Shutdown();
34 component_list_.clear();
42 std::vector<std::string> paths;
52 std::string module_path = dag_conf;
55 AERROR <<
"no dag conf [" << dag_conf <<
"] found!";
58 AINFO <<
"mainboard: use dag conf " << module_path;
59 total_component_nums += GetComponentNum(module_path);
60 paths.emplace_back(std::move(module_path));
62 if (has_timer_component) {
65 common::GlobalData::Instance()->SetComponentNums(total_component_nums);
66 for (
auto module_path : paths) {
67 AINFO <<
"Start initialize dag: " << module_path;
68 if (!LoadModule(module_path)) {
69 AERROR <<
"Failed to load module: " << module_path;
76bool ModuleController::LoadModule(
const DagConfig& dag_config) {
77 for (
auto module_config : dag_config.module_config()) {
78 std::string load_path;
80 "APOLLO_LIB_PATH", &load_path)) {
81 AERROR <<
"no module library [" << module_config.module_library()
85 AINFO <<
"mainboard: use module library " << load_path;
89 for (
auto& component : module_config.components()) {
90 const std::string& class_name = component.class_name();
91 std::shared_ptr<ComponentBase> base =
93 if (base ==
nullptr || !base->Initialize(component.config())) {
96 component_list_.emplace_back(std::move(base));
99 for (
auto& component : module_config.timer_components()) {
100 const std::string& class_name = component.class_name();
101 std::shared_ptr<ComponentBase> base =
103 if (base ==
nullptr || !base->Initialize(component.config())) {
106 component_list_.emplace_back(std::move(base));
112bool ModuleController::LoadModule(
const std::string& path) {
113 DagConfig dag_config;
115 AERROR <<
"Get proto failed, file: " << path;
118 return LoadModule(dag_config);
121int ModuleController::GetComponentNum(
const std::string& path) {
122 DagConfig dag_config;
123 int component_nums = 0;
125 for (
auto module_config : dag_config.module_config()) {
126 component_nums += module_config.components_size();
127 if (module_config.timer_components_size() > 0) {
128 has_timer_component =
true;
132 return component_nums;
std::shared_ptr< Base > CreateClassObj(const std::string &class_name)
bool LoadLibrary(const std::string &library_path)
const std::list< std::string > & GetDAGConfList() const
const bool & GetDisablePluginsAutoLoad() const
const std::list< std::string > & GetPluginDescriptionList() const
static PluginManager * Instance()
get singleton instance of PluginManager
bool LoadInstalledPlugins()
load plugins from installed path
bool LoadPlugin(const std::string &plugin_description_file_path)
load plugin clases from file
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,...
std::string GetCurrentPath()
bool GetFilePathWithEnv(const std::string &path, const std::string &env_var, std::string *file_path)
get file path, judgement priority:
std::string GetAbsolutePath(const std::string &prefix, const std::string &relative_path)
Get absolute path by concatenating prefix and relative_path.
const std::string WorkRoot()