Elements 6.1.2
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 <fstream>
20#include <map>
21#include <string>
22#include <vector>
23
25
26namespace Elements {
27inline namespace Services {
28namespace DataSync {
29
30using std::string;
31using std::vector;
32
34 : m_aliasSeparator('\t'), m_distantRoot(distantRoot), m_localRoot(localRoot), m_fileMap() {
35 parseConfigurationFile(configFile);
36}
37
39 return m_fileMap;
40}
41
43 return m_fileMap.at(localFile); // @TODO error handling
44}
45
47 return m_fileMap.size();
48}
49
51 vector<path> distant_paths;
52 for (const auto& item : m_fileMap) {
53 distant_paths.emplace_back(item.second);
54 }
55 return distant_paths;
56}
57
59 vector<path> local_paths;
60 for (const auto& item : m_fileMap) {
61 local_paths.emplace_back(item.first);
62 }
63 return local_paths;
64}
65
67 path abs_path = confFilePath(filename);
68 std::ifstream inputStream(abs_path.c_str());
69 string line;
70 while (std::getline(inputStream, line)) {
72 }
73}
74
76 if (lineHasAlias(line)) {
78 } else {
80 }
81}
82
84 return m_aliasSeparator;
85}
86
88 string::size_type offset = line.find(m_aliasSeparator);
89 return offset != string::npos;
90}
91
93 string::size_type offset = line.find(m_aliasSeparator);
94 const string distantFilename = line.substr(0, offset);
95 const string localFilename = line.substr(offset + 1);
96 const path distantPath = m_distantRoot / distantFilename;
97 const path localPath = m_localRoot / localFilename;
98 m_fileMap[localPath] = distantPath;
99}
100
102 const path distantPath = m_distantRoot / line;
103 const path localPath = m_localRoot / line;
104 m_fileMap[localPath] = distantPath;
105}
106
107} // namespace DataSync
108} // namespace Services
109} // namespace Elements
T at(T... args)
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
Definition: DataSyncUtils.h:41
T size(T... args)
T substr(T... args)