Elements  6.0.1
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Auxiliary.tpp
Go to the documentation of this file.
1 
21 #ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_AUXILIARY_IMPL_
22 #error "This file should not be included directly! Use ElementsKernel/Auxiliary.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 namespace Elements {
29 inline namespace Kernel {
30 
31 template <typename T>
32 Path::Item getAuxiliaryPath(const T& file_name, bool raise_exception) {
33 
34  auto location_list = getAuxiliaryLocations();
35 
36  auto result = Path::getPathFromLocations(file_name, location_list);
37 
38  if (result.empty() and raise_exception) {
39  throw Exception() << "The auxiliary path \"" << file_name << "\" cannot be found!";
40  }
41 
42  return result;
43 }
44 
45 namespace Auxiliary {
46 
47 template <typename T>
48 Path::Item getPath(const T& file_name, bool raise_exception) {
49  return getAuxiliaryPath(file_name, raise_exception);
50 }
51 
52 } // namespace Auxiliary
53 
54 } // namespace Kernel
55 } // namespace Elements
56 
57 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_AUXILIARY_IMPL_
ELEMENTS_API Path::Item getAuxiliaryPath(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:56
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
ELEMENTS_API std::vector< Path::Item > getAuxiliaryLocations(bool exist_only=false)
Definition: Auxiliary.cpp:49
defines the base Elements exception class