Elements  5.12
A C++ base framework for the Euclid Software.
DataSync.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 
22 
23 namespace ElementsServices {
24 namespace DataSync {
25 
26 
27 DataSync::DataSync(path connectionFile, path dependencyFile) :
28  m_connectionConfig(connectionFile),
29  m_distantRoot(m_connectionConfig.distantRoot),
30  m_localRoot(m_connectionConfig.localRoot),
31  m_dependencyConfig(m_distantRoot, m_localRoot, dependencyFile) {
32 }
33 
34 void DataSync::download() {
35  const auto& synchronizer = createSynchronizer(
38  synchronizer->downloadAllFiles();
39 }
40 
41 void DataSync::downloadWithFallback(path connectionFile) {
42  try {
43  download();
44  } catch (std::exception &e) {
46  download();
47  }
48 }
49 
50 path DataSync::absolutePath(path relativePath) {
51  return m_localRoot / relativePath;
52 }
53 
54 } // namespace DataSync
55 } // namespace ElementsServices
ElementsServices::DataSync::DataSync::m_connectionConfig
ConnectionConfiguration m_connectionConfig
Definition: DataSync.h:96
DataSynchronizerMaker.h
std::exception
STL class.
ElementsServices::DataSync::DataSync::m_localRoot
path m_localRoot
Definition: DataSync.h:98
ElementsServices::DataSync::DataSync::download
void download()
Download the test data.
Definition: DataSync.cpp:34
ElementsServices::DataSync::createSynchronizer
ELEMENTS_API std::shared_ptr< DataSynchronizer > createSynchronizer(ConnectionConfiguration connection, DependencyConfiguration dependency)
Definition: DataSynchronizerMaker.cpp:26
DataSync.h
ElementsServices::DataSync::DataSync
A class to download test data from a data repository prior to the unit test run.
Definition: DataSync.h:47
ElementsServices
Definition: ConnectionConfiguration.h:33
Elements::Units::e
constexpr double e
The base of the natural logarithm .
Definition: MathConstants.h:50
DataSynchronizer.h
ElementsServices::DataSync::ConnectionConfiguration
The connection configuration mainly holds:
Definition: ConnectionConfiguration.h:75
ElementsServices::DataSync::DataSync::m_dependencyConfig
DependencyConfiguration m_dependencyConfig
Definition: DataSync.h:99
ElementsServices::DataSync::path
Elements::Path::Item path
Definition: DataSyncUtils.h:39