Apollo  6.0
Open source self driving car software
container_manager.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 
22 #pragma once
23 
24 #include <memory>
25 #include <unordered_map>
26 
27 #include "cyber/common/macros.h"
28 #include "gtest/gtest.h"
29 
30 #include "modules/common/adapters/proto/adapter_config.pb.h"
32 
37 namespace apollo {
38 namespace prediction {
39 
41  public:
45  ContainerManager() = default;
46 
51  void Init(const common::adapter::AdapterManagerConfig &config);
52 
58  template <typename T>
60  auto key_type = static_cast<int>(type);
61  if (containers_.find(key_type) != containers_.end()) {
62  return static_cast<T *>(containers_[key_type].get());
63  }
64  return nullptr;
65  }
66 
72  std::unique_ptr<Container> CreateContainer(
74 
75  FRIEND_TEST(FeatureExtractorTest, junction);
76  FRIEND_TEST(ScenarioManagerTest, run);
77 
78  private:
83  void RegisterContainer(
85 
89  void RegisterContainers();
90 
91  private:
92  std::unordered_map<int, std::unique_ptr<Container>> containers_;
93 
94  common::adapter::AdapterManagerConfig config_;
95 };
96 
97 } // namespace prediction
98 } // namespace apollo
Definition: container_manager.h:40
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
FRIEND_TEST(FeatureExtractorTest, junction)
ContainerManager()=default
Constructor.
Define the data container base class.
T * GetContainer(const common::adapter::AdapterConfig::MessageType &type)
Get mutable container.
Definition: container_manager.h:59
MessageType
Definition: v2x_object.h:49
std::unique_ptr< Container > CreateContainer(const common::adapter::AdapterConfig::MessageType &type)
Create a container.
void Init(const common::adapter::AdapterManagerConfig &config)
Container manager initialization.