Elements  5.12.0
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 ElementsServices {
38 namespace DataSync {
39 
46 public:
47  virtual ~DownloadFailed() = default;
48  DownloadFailed(path distantFile, path localFile) :
49  std::runtime_error(
50  "Unable to download file: '"
51  + distantFile.string()
52  + "' as: '"
53  + localFile.string()
54  + "'.") {
55  }
56 };
57 
66 
67 public:
68 
69  virtual ~DataSynchronizer() = default;
70 
72  const ConnectionConfiguration& connection,
73  const DependencyConfiguration& dependency);
74 
75  void downloadAllFiles() const;
76 
77 protected:
78 
79  bool fileShouldBeWritten(path localFile) const;
80 
81  bool fileAlreadyExists(path localFile) const;
82 
83  void downloadOneFile(
84  path distantFile,
85  path localFile) const;
86 
87  bool hasBeenDownloaded(
88  path distantFile,
89  path localFile) const;
90 
92  path distantFile,
93  path localFile) const = 0;
94 
95 protected:
96 
99 
100 };
101 
102 } // namespace DataSync
103 } // namespace ElementsServices
104 
105 #endif // ELEMENTSSERVICES_ELEMENTSSERVICES_DATASYNC_DATASYNCHRONIZER_H_
106 
defines the macros to be used for explicit export of the symbols
The connection configuration mainly holds:
Base class to synchronize test data.
virtual std::string createDownloadCommand(path distantFile, path localFile) const =0
The dependency configurations holds, for each test file to be retrieved:
An exception raised when downloading fails.
DownloadFailed(path distantFile, path localFile)
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
Elements::Path::Item path
Definition: DataSyncUtils.h:39
STL namespace.