17 #ifndef CYBER_COMPONENT_COMPONENT_BASE_H_ 18 #define CYBER_COMPONENT_COMPONENT_BASE_H_ 25 #include "gflags/gflags.h" 27 #include "cyber/proto/component_conf.pb.h" 38 using apollo::cyber::proto::ComponentConfig;
39 using apollo::cyber::proto::TimerComponentConfig;
41 class ComponentBase :
public std::enable_shared_from_this<ComponentBase> {
48 virtual bool Initialize(
const ComponentConfig& config) {
return false; }
49 virtual bool Initialize(
const TimerComponentConfig& config) {
return false; }
68 virtual bool Init() = 0;
69 virtual void Clear() {
return; }
73 if (!config.config_file_path().empty()) {
74 if (config.config_file_path()[0] !=
'/') {
76 config.config_file_path());
82 if (!config.flag_file_path().empty()) {
83 std::string flag_file_path = config.flag_file_path();
84 if (flag_file_path[0] !=
'/') {
88 google::SetCommandLineOption(
"flagfile", flag_file_path.c_str());
93 if (!config.config_file_path().empty()) {
94 if (config.config_file_path()[0] !=
'/') {
96 config.config_file_path());
102 if (!config.flag_file_path().empty()) {
103 std::string flag_file_path = config.flag_file_path();
104 if (flag_file_path[0] !=
'/') {
108 google::SetCommandLineOption(
"flagfile", flag_file_path.c_str());
113 std::shared_ptr<Node>
node_ =
nullptr;
121 #endif // CYBER_COMPONENT_COMPONENT_BASE_H_ std::vector< std::shared_ptr< ReaderBase > > readers_
Definition: component_base.h:115
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Reader subscribes a channel, it has two main functions:
Definition: reader.h:68
virtual bool Initialize(const ComponentConfig &config)
Definition: component_base.h:48
std::string GetAbsolutePath(const std::string &prefix, const std::string &relative_path)
Get absolute path by concatenating prefix and relative_path.
virtual void Shutdown()
Definition: component_base.h:50
const std::string & ConfigFilePath() const
Definition: component_base.h:70
virtual bool RemoveTask(const std::string &name)=0
virtual bool Initialize(const TimerComponentConfig &config)
Definition: component_base.h:49
void LoadConfigFiles(const ComponentConfig &config)
Definition: component_base.h:72
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, and merges the parsed content to the proto.
std::string config_file_path_
Definition: component_base.h:114
void LoadConfigFiles(const TimerComponentConfig &config)
Definition: component_base.h:92
virtual void Clear()
Definition: component_base.h:69
Definition: component_base.h:41
const std::string WorkRoot()
Definition: environment.h:40
std::shared_ptr< Node > node_
Definition: component_base.h:113
virtual ~ComponentBase()
Definition: component_base.h:46
bool GetProtoConfig(T *config) const
Definition: component_base.h:63
std::atomic< bool > is_shutdown_
Definition: component_base.h:112