Elements  5.12
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 #ifdef ELEMENTSKERNEL_ELEMENTSKERNEL_CONFIGURATION_IMPL_
22 
23 #include "ElementsKernel/Exception.h" // for Exception
24 #include "ElementsKernel/Path.h" // for Path::VARIABLE, Path::Type, Path::Item
25  // getPathFromLocations
26 
27 namespace Elements {
28 
29 template <typename T>
30 Path::Item getConfigurationPath(const T& file_name, bool raise_exception) {
31 
32  auto location_list = getConfigurationLocations();
33 
34  auto result = Path::getPathFromLocations(file_name, location_list);
35 
36  if (result.empty() and raise_exception) {
37  throw Exception() << "The configuration path \"" << file_name << "\" cannot be found!";
38  }
39 
40  return result;
41 }
42 
43 } // namespace Elements
44 
45 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_CONFIGURATION_IMPL_
ELEMENTS_API Path::Item getConfigurationPath(const T &file_name, bool raise_exception=true)
ELEMENTS_API Item getPathFromLocations(const T &file_name, const std::vector< U > &locations)
retrieve path from a file name and a set of location to look into
boost::filesystem::path Item
Definition: Path.h:61
provide functions to retrieve resources pointed by environment variables
ELEMENTS_API std::vector< Path::Item > getConfigurationLocations(bool exist_only=false)
defines the base Elements exception class