Apollo 10.0
自动驾驶开放平台
multi_value_warehouse.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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
17#ifndef CYBER_SERVICE_DISCOVERY_CONTAINER_MULTI_VALUE_WAREHOUSE_H_
18#define CYBER_SERVICE_DISCOVERY_CONTAINER_MULTI_VALUE_WAREHOUSE_H_
19
20#include <cstdint>
21#include <unordered_map>
22#include <vector>
23
26
27namespace apollo {
28namespace cyber {
29namespace service_discovery {
30
32 public:
33 using RoleMap = std::unordered_multimap<uint64_t, RolePtr>;
34
37
38 bool Add(uint64_t key, const RolePtr& role,
39 bool ignore_if_exist = true) override;
40
41 void Clear() override;
42 std::size_t Size() override;
43
44 void Remove(uint64_t key) override;
45 void Remove(uint64_t key, const RolePtr& role) override;
46 void Remove(const proto::RoleAttributes& target_attr) override;
47
48 bool Search(uint64_t key) override;
49 bool Search(uint64_t key, RolePtr* first_matched_role) override;
50 bool Search(uint64_t key,
51 proto::RoleAttributes* first_matched_role_attr) override;
52 bool Search(uint64_t key, std::vector<RolePtr>* matched_roles) override;
53 bool Search(uint64_t key,
54 std::vector<proto::RoleAttributes>* matched_roles_attr) override;
55
56 bool Search(const proto::RoleAttributes& target_attr) override;
57 bool Search(const proto::RoleAttributes& target_attr,
58 RolePtr* first_matched) override;
59 bool Search(const proto::RoleAttributes& target_attr,
60 proto::RoleAttributes* first_matched_role_attr) override;
61 bool Search(const proto::RoleAttributes& target_attr,
62 std::vector<RolePtr>* matched_roles) override;
63 bool Search(const proto::RoleAttributes& target_attr,
64 std::vector<proto::RoleAttributes>* matched_roles_attr) override;
65
66 void GetAllRoles(std::vector<RolePtr>* roles) override;
67 void GetAllRoles(std::vector<proto::RoleAttributes>* roles_attr) override;
68
69 private:
70 RoleMap roles_;
71 base::AtomicRWLock rw_lock_;
72};
73
74} // namespace service_discovery
75} // namespace cyber
76} // namespace apollo
77
78#endif // CYBER_SERVICE_DISCOVERY_CONTAINER_MULTI_VALUE_WAREHOUSE_H_
void GetAllRoles(std::vector< RolePtr > *roles) override
std::unordered_multimap< uint64_t, RolePtr > RoleMap
bool Add(uint64_t key, const RolePtr &role, bool ignore_if_exist=true) override
std::shared_ptr< RoleBase > RolePtr
Definition role.h:31
class register implement
Definition arena_queue.h:37