Apollo  6.0
Open source self driving car software
task_factory.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
21 #pragma once
22 
23 #include <memory>
24 #include <unordered_map>
25 
27 #include "modules/planning/proto/planning_config.pb.h"
29 
30 namespace apollo {
31 namespace planning {
32 
33 class TaskFactory {
34  public:
35  static void Init(const PlanningConfig &config,
36  const std::shared_ptr<DependencyInjector> &injector);
37  static std::unique_ptr<Task> CreateTask(
38  const TaskConfig &task_config,
39  const std::shared_ptr<DependencyInjector> &injector);
40 
41  private:
43  TaskConfig::TaskType, Task,
44  Task *(*)(const TaskConfig &config,
45  const std::shared_ptr<DependencyInjector> &injector),
46  std::unordered_map<
47  TaskConfig::TaskType,
48  Task *(*)(const TaskConfig &config,
49  const std::shared_ptr<DependencyInjector> &injector),
50  std::hash<int>>>
51  task_factory_;
52  static std::unordered_map<TaskConfig::TaskType, TaskConfig, std::hash<int>>
53  default_task_configs_;
54 };
55 
56 } // namespace planning
57 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Planning module main class. It processes GPS and IMU as input, to generate planning info...
Definition: task_factory.h:33
Implements a Factory design pattern with Register and Create methods.
Definition: factory.h:60
static std::unique_ptr< Task > CreateTask(const TaskConfig &task_config, const std::shared_ptr< DependencyInjector > &injector)
Defines the Factory class.
static void Init(const PlanningConfig &config, const std::shared_ptr< DependencyInjector > &injector)
Definition: task.h:35