PackagePath.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarXCore::core::PackagePath
19 * @author Christian R. G. Dreher <c.dreher@kit.edu>
20 * @date 2020
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25
27
28
29// ArmarX
31
32armarx::PackagePath::PackagePath(const std::string& package_name,
33 const std::filesystem::path& rel_path) :
34 m_pp{package_name, rel_path.string()}
35{
36}
37
38armarx::PackagePath::PackagePath(const data::PackagePath& pp) : m_pp{pp}
39{
40}
41
45
46std::filesystem::path
47armarx::PackagePath::toSystemPath(const data::PackagePath& pp)
48{
49 CMakePackageFinder pkg_finder(pp.package);
50 const std::filesystem::path pkg_data_dir{pkg_finder.getDataDir()};
51
52 if (pkg_data_dir.empty())
53 {
54 throw PackageNotFoundException{pp.package};
55 }
56
57 return pkg_data_dir / std::filesystem::path{pp.package} / pp.path;
58}
59
60std::filesystem::path
65
66armarx::data::PackagePath
68{
69 return m_pp;
70}
71
72namespace armarx
73{
74
75 std::ostream&
76 operator<<(std::ostream& os, const armarx::PackagePath& packagePath)
77 {
78 os << "PackagePath { " << packagePath.serialize().package << " : "
79 << packagePath.serialize().path << " }";
80 return os;
81 }
82
83} // namespace armarx
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
std::filesystem::path toSystemPath() const
data::PackagePath serialize() const
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::ostream & operator<<(std::ostream &os, const PythonApplicationManager::Paths &paths)