Elements  5.8
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Configuration.icpp
Go to the documentation of this file.
1 
21 #ifndef ELEMENTSKERNEL_ELEMENTSKERNEL__IMPL_CONFIGURATION_ICPP_
22 #define ELEMENTSKERNEL_ELEMENTSKERNEL__IMPL_CONFIGURATION_ICPP_
23 
24 #include <boost/filesystem.hpp> // for boost::filesystem
25 
26 #include "ElementsKernel/Exception.h" // for Exception
27 #include "ElementsKernel/Path.h" // for Path::getPathFromLocations
28 
29 namespace Elements {
30 
31 template <typename T>
32 boost::filesystem::path getConfigurationPath(const T& file_name, bool raise_exception) {
33 
34  auto location_list = getConfigurationLocations();
35 
36  auto result = Path::getPathFromLocations(file_name, location_list);
37 
38  if (result.empty() and raise_exception) {
39  throw Exception() << "The configuration path \"" << file_name << "\" cannot be found!";
40  }
41 
42  return result;
43 }
44 
45 } // namespace Elements
46 
47 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL__IMPL_CONFIGURATION_ICPP_
ELEMENTS_API std::vector< boost::filesystem::path > getConfigurationLocations(bool exist_only=false)
boost::filesystem::path getConfigurationPath(const T &file_name, bool raise_exception)
boost::filesystem::path path
Definition: DataSyncUtils.h:33
boost::filesystem::path getPathFromLocations(const T &file_name, const std::vector< U > &locations)
retrieve path from a file name and a set of location to look into
Definition: Path.icpp:37
provide functions to retrieve resources pointed by environment variables
defines the base Elements exception class