Elements  5.8
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 
19 #ifndef ELEMENTSSERVICES_ELEMENTSSERVICES_DATASYNC_DATASYNCHRONIZER_H_
20 #define ELEMENTSSERVICES_ELEMENTSSERVICES_DATASYNC_DATASYNCHRONIZER_H_
21 
22 #include <map>
23 #include <stdexcept>
24 #include <string>
25 
26 #include "ElementsKernel/Export.h"
27 
31 
32 namespace ElementsServices {
33 namespace DataSync {
34 
40 public:
41  virtual ~DownloadFailed() = default;
42  DownloadFailed(path distantFile, path localFile) :
43  std::runtime_error(
44  "Unable to download file: '"
45  + distantFile.string()
46  + "' as: '"
47  + localFile.string()
48  + "'.") {
49  }
50 };
51 
59 
60 public:
61 
62  virtual ~DataSynchronizer() = default;
63 
65  const ConnectionConfiguration& connection,
66  const DependencyConfiguration& dependency);
67 
68  void downloadAllFiles() const;
69 
70 protected:
71 
72  bool fileShouldBeWritten(path localFile) const;
73 
74  bool fileAlreadyExists(path localFile) const;
75 
76  void downloadOneFile(
77  path distantFile,
78  path localFile) const;
79 
80  bool hasBeenDownloaded(
81  path distantFile,
82  path localFile) const;
83 
84  virtual std::string createDownloadCommand(
85  path distantFile,
86  path localFile) const = 0;
87 
88 protected:
89 
92 
93 };
94 
95 } // namespace DataSync
96 } // namespace ElementsServices
97 
98 #endif // ELEMENTSSERVICES_ELEMENTSSERVICES_DATASYNC_DATASYNCHRONIZER_H_
The dependency configurations holds, for each test file to be retrieved:
STL class.
defines the macros to be used for explicit export of the symbols
Base class to synchronize test data.
boost::filesystem::path path
Definition: DataSyncUtils.h:33
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
An exception raised when downloading fails.
The connection configuration mainly holds:
DownloadFailed(path distantFile, path localFile)