location.cpp
Go to the documentation of this file.
1/**
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Fabian Reister ( fabian dot reister at kit dot edu )
17 * @date 2025
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#include "location.h"
23
24#include <optional>
25#include <string>
26
27#include <range/v3/range/conversion.hpp>
28#include <range/v3/view/filter.hpp>
29
31{
32
33 bool
34 Location::matches(const std::string& name,
35 const std::optional<std::string>& provider) const noexcept
36 {
37 if (provider.has_value())
38 {
39 return this->name == name and this->provider == provider.value();
40 }
41
42 return this->name == name;
43 }
44
45 std::vector<core::Location>
46 util::findMatchingLocations(const std::vector<core::Location>& locations,
47 const std::string& locationName,
48 const std::optional<std::string>& provider)
49 {
50 const auto matchFn = [&](const core::Location& location) noexcept
51 { return location.matches(locationName, provider); };
52
53 return locations | ranges::views::filter(matchFn) | ranges::to_vector;
54 }
55} // namespace armarx::navigation::core
std::vector< core::Location > findMatchingLocations(const std::vector< core::Location > &locations, const std::string &locationName, const std::optional< std::string > &provider)
Definition location.cpp:46
This file is part of ArmarX.
This file is part of ArmarX.
Definition constants.cpp:4
bool matches(const std::string &name, const std::optional< std::string > &provider) const noexcept
Definition location.cpp:34