Elements  6.0.1
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Configuration.tpp
Go to the documentation of this file.
1 
21 #ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_CONFIGURATION_IMPL_
22 #error "This file should not be included directly! Use ElementsKernel/Configuration.h instead"
23 #else
24 
25 #include "ElementsKernel/Exception.h" // for Exception
26 #include "ElementsKernel/Path.h" // for Path::VARIABLE, Path::Type, Path::Item
27  // getPathFromLocations
28 
29 namespace Elements {
30 inline namespace Kernel {
31 
32 template <typename T>
33 Path::Item getConfigurationPath(const T& file_name, bool raise_exception) {
34 
35  auto location_list = getConfigurationLocations();
36 
37  auto result = Path::getPathFromLocations(file_name, location_list);
38 
39  if (result.empty() and raise_exception) {
40  throw Exception() << "The configuration path \"" << file_name << "\" cannot be found!";
41  }
42 
43  return result;
44 }
45 
46 namespace Configuration {
47 
48 template <typename T>
49 Path::Item getPath(const T& file_name, bool raise_exception) {
50  return getConfigurationPath(file_name, raise_exception);
51 }
52 
53 } // namespace Configuration
54 
55 } // namespace Kernel
56 } // namespace Elements
57 
58 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_CONFIGURATION_IMPL_
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:56
ELEMENTS_API Path::Item getConfigurationPath(const T &file_name, bool raise_exception=true)
ELEMENTS_API Path::Item getPath(const T &file_name, bool raise_exception=true)
alias for the getAuxiliaryPath function
provide functions to retrieve resources pointed by environment variables
defines the base Elements exception class
ELEMENTS_API std::vector< Path::Item > getConfigurationLocations(bool exist_only=false)