Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
entry_manager.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019-2021 LEIDOS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * 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, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
18
20{
21
23 {
24 entry_map_[entry.name_] = entry;
25 }
26
27
28 std::vector<Entry> EntryManager::get_entries() const
29 {
30 // returns the copy of the original data
31 std::vector<Entry> entries;
32 entries.reserve(entry_map_.size());
33
34 for (const auto& e : entry_map_)
35 entries.push_back(e.second);
36
37 return entries;
38 }
39
40 std::vector<std::string> EntryManager::get_entry_names() const
41 {
42 std::vector<std::string> names;
43 names.reserve(entry_map_.size());
44
45 for (const auto& e : entry_map_)
46 names.push_back(e.second.name_);
47
48 return names;
49 }
50
51 void EntryManager::delete_entry(const std::string& name)
52 {
53 if (entry_map_.find(name) != entry_map_.end())
54 entry_map_.erase(name);
55 }
56
57 boost::optional<Entry> EntryManager::get_entry_by_name(const std::string& name) const
58 {
59 if (entry_map_.find(name) != entry_map_.end())
60 return entry_map_.at(name);
61
62
63 // use boost::optional because requested entry might not exist
64 return boost::none;
65 }
66
67}
std::vector< std::string > get_entry_names() const
Get all entry names as a list.
boost::optional< Entry > get_entry_by_name(const std::string &name) const
Get a entry using name as the key.
void delete_entry(const std::string &name)
Delete an entry using the given name as the key.
void update_entry(const Entry &entry)
Add a new entry if the given name does not exist. Update an existing entry if the given name exists.
std::vector< Entry > get_entries() const
Get all entries as a list.
std::unordered_map< std::string, Entry > entry_map_
private map by entry name to keep track of all entries
Definition: entry_manager.h:69
An entry represents a driver details for the purposes of tracking.
Definition: entry.hpp:27
std::string name_
Fully specified node name of a driver.
Definition: entry.hpp:31