Elements 6.3.3
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
DependencyConfiguration.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012-2020 Euclid Science Ground Segment
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 3.0 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "ElementsServices/DataSync/DependencyConfiguration.h" // for DependencyConfiguration
20
21#include <cstddef> // for size_t
22#include <fstream> // for basic_istream, ifstream
23#include <map> // for map, operator!=, _Rb_tree_const_iterator
24#include <string> // for char_traits, string, getline
25#include <utility> // for pair
26#include <vector> // for vector
27
28#include <boost/filesystem/path.hpp> // for operator/, path, operator<
29
30#include "ElementsServices/DataSync/DataSyncUtils.h" // for path, confFilePath
31
32namespace Elements {
33inline namespace Services {
34namespace DataSync {
35
36using std::string;
37using std::vector;
38
40 : m_aliasSeparator('\t'), m_distantRoot(distantRoot), m_localRoot(localRoot), m_fileMap() {
41 parseConfigurationFile(configFile);
42}
43
47
49 return m_fileMap.at(localFile); // @TODO error handling
50}
51
55
57 vector<path> distant_paths;
58 for (const auto& item : m_fileMap) {
59 distant_paths.emplace_back(item.second);
60 }
61 return distant_paths;
62}
63
65 vector<path> local_paths;
66 for (const auto& item : m_fileMap) {
67 local_paths.emplace_back(item.first);
68 }
69 return local_paths;
70}
71
73 path abs_path = confFilePath(filename);
74 std::ifstream inputStream(abs_path.c_str());
75 string line;
76 while (std::getline(inputStream, line)) {
78 }
79}
80
82 if (lineHasAlias(line)) {
84 } else {
86 }
87}
88
92
94 string::size_type offset = line.find(m_aliasSeparator);
95 return offset != string::npos;
96}
97
99 string::size_type offset = line.find(m_aliasSeparator);
100 const string distantFilename = line.substr(0, offset);
101 const string localFilename = line.substr(offset + 1);
102 const path distantPath = m_distantRoot / distantFilename;
103 const path localPath = m_localRoot / localFilename;
104 m_fileMap[localPath] = distantPath;
105}
106
108 const path distantPath = m_distantRoot / line;
109 const path localPath = m_localRoot / line;
110 m_fileMap[localPath] = distantPath;
111}
112
113} // namespace DataSync
114} // namespace Services
115} // namespace Elements
DependencyConfiguration(path distantRoot, path localRoot, path configFile)
T emplace_back(T... args)
T find(T... args)
T getline(T... args)
ELEMENTS_API path confFilePath(path filename)
Path::Item path
importing the path item from ElementsKernel
T substr(T... args)