Elements  6.2
A C++ base framework for the Euclid Software.
DataSyncUtils.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_DATASYNCUTILS_H_
25 #define ELEMENTSSERVICES_ELEMENTSSERVICES_DATASYNC_DATASYNCUTILS_H_
26 
27 #include <string>
28 #include <utility>
29 #include <vector>
30 
31 #include <boost/filesystem.hpp>
32 
33 #include "ElementsKernel/Export.h"
34 #include "ElementsKernel/Path.h"
35 
36 namespace Elements {
37 inline namespace Services {
38 namespace DataSync {
39 
41 using path = Path::Item;
42 
44 
45 ELEMENTS_API bool checkCall(const std::string& command);
46 
48 
49 ELEMENTS_API bool localDirExists(path localDir);
50 
51 ELEMENTS_API void createLocalDirOf(path localFile);
52 
59 
61 
63 
64 template <typename T>
65 ELEMENTS_API bool valueIsListed(const T& value, const std::vector<T>& list) {
66  const auto& begin = list.begin();
67  const auto& end = list.end();
68  return std::find(begin, end, value) != end;
69 }
70 
72 
73 } // namespace DataSync
74 } // namespace Services
75 } // namespace Elements
76 
78 
79 #endif // ELEMENTSSERVICES_ELEMENTSSERVICES_DATASYNC_DATASYNCUTILS_H_
80 
Elements::Kernel::Path::Item
boost::filesystem::path Item
Definition: Path.h:56
Elements::Services::DataSync::checkCall
ELEMENTS_API bool checkCall(const std::string &command)
Definition: DataSyncUtils.cpp:43
Export.h
defines the macros to be used for explicit export of the symbols
std::string
STL class.
Path.h
provide functions to retrieve resources pointed by environment variables
std::pair
Elements::Services::DataSync::valueIsListed
ELEMENTS_API bool valueIsListed(const T &value, const std::vector< T > &list)
Definition: DataSyncUtils.h:65
std::vector
STL class.
std::find
T find(T... args)
Elements::Services::DataSync::localDirExists
ELEMENTS_API bool localDirExists(path localDir)
Definition: DataSyncUtils.cpp:64
Elements::Services::DataSync::lower
ELEMENTS_API std::string lower(std::string text)
Definition: DataSyncUtils.cpp:88
ELEMENTS_API
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
Elements::Services::DataSync::runCommandAndCaptureOutErr
ELEMENTS_API std::pair< std::string, std::string > runCommandAndCaptureOutErr(std::string command)
Definition: DataSyncUtils.cpp:49
Elements::Services::DataSync::containsInThisOrder
ELEMENTS_API bool containsInThisOrder(std::string input, std::vector< std::string > substrings)
Definition: DataSyncUtils.cpp:94
Elements::Services::DataSync::createLocalDirOf
ELEMENTS_API void createLocalDirOf(path localFile)
Definition: DataSyncUtils.cpp:68
Elements::Services::DataSync::localWorkspacePrefix
ELEMENTS_API path localWorkspacePrefix()
Definition: DataSyncUtils.cpp:82
std::vector::begin
T begin(T... args)
Elements::Services
Definition: ConnectionConfiguration.h:34
std::vector::end
T end(T... args)
Elements::Services::DataSync::confFilePath
ELEMENTS_API path confFilePath(path filename)
Definition: DataSyncUtils.cpp:39
Elements::Services::DataSync::environmentVariable
ELEMENTS_API std::string environmentVariable(std::string name)
Get the value of an environment variable.
Definition: DataSyncUtils.cpp:78
Elements
Definition: callBackExample.h:35
Elements::Services::DataSync::path
Path::Item path
importing the path item from ElementsKernel
Definition: DataSyncUtils.h:41