Elements  6.2
A C++ base framework for the Euclid Software.
DataSynchronizer.h
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 
24 #ifndef ELEMENTSSERVICES_ELEMENTSSERVICES_DATASYNC_DATASYNCHRONIZER_H_
25 #define ELEMENTSSERVICES_ELEMENTSSERVICES_DATASYNC_DATASYNCHRONIZER_H_
26 
27 #include <map>
28 #include <stdexcept>
29 #include <string>
30 
31 #include "ElementsKernel/Export.h"
32 
36 
37 namespace Elements {
38 inline namespace Services {
39 namespace DataSync {
40 
47 public:
48  virtual ~DownloadFailed() = default;
49  DownloadFailed(path distantFile, path localFile)
50  : std::runtime_error("Unable to download file: '" + distantFile.string() + "' as: '" + localFile.string() +
51  "'.") {}
52 };
53 
62 
63 public:
64  virtual ~DataSynchronizer() = default;
65 
66  DataSynchronizer(const ConnectionConfiguration& connection, const DependencyConfiguration& dependency);
67 
68  void downloadAllFiles() const;
69 
70 protected:
71  bool fileShouldBeWritten(path localFile) const;
72 
73  bool fileAlreadyExists(path localFile) const;
74 
75  void downloadOneFile(path distantFile, path localFile) const;
76 
77  bool hasBeenDownloaded(path distantFile, path localFile) const;
78 
79  virtual std::string createDownloadCommand(path distantFile, path localFile) const = 0;
80 
81 protected:
84 };
85 
86 } // namespace DataSync
87 } // namespace Services
88 } // namespace Elements
89 
91 
92 #endif // ELEMENTSSERVICES_ELEMENTSSERVICES_DATASYNC_DATASYNCHRONIZER_H_
93 
Export.h
defines the macros to be used for explicit export of the symbols
std::string
STL class.
Elements::Services::DataSync::DownloadFailed::DownloadFailed
DownloadFailed(path distantFile, path localFile)
Definition: DataSynchronizer.h:49
Elements::Services::DataSync::DownloadFailed
An exception raised when downloading fails.
Definition: DataSynchronizer.h:46
Elements::Services::DataSync::DataSynchronizer
Base class to synchronize test data.
Definition: DataSynchronizer.h:61
ELEMENTS_API
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
Elements::Services::DataSync::DependencyConfiguration
The dependency configurations holds, for each test file to be retrieved:
Definition: DependencyConfiguration.h:45
DependencyConfiguration.h
std::runtime_error
STL class.
std::map< path, path >
DataSyncUtils.h
std
STL namespace.
Elements::Services::DataSync::DataSynchronizer::m_fileMap
std::map< path, path > m_fileMap
Definition: DataSynchronizer.h:83
Elements::Services
Definition: ConnectionConfiguration.h:34
ConnectionConfiguration.h
Elements::Services::DataSync::ConnectionConfiguration
The connection configuration mainly holds:
Definition: ConnectionConfiguration.h:75
Elements
Definition: callBackExample.h:35
Elements::Services::DataSync::path
Path::Item path
importing the path item from ElementsKernel
Definition: DataSyncUtils.h:41
Elements::Services::DataSync::DataSynchronizer::m_connection
ConnectionConfiguration m_connection
Definition: DataSynchronizer.h:82