00001 #ifndef PATHRESOLVER_PATHRESOLVER_H
00002 #define PATHRESOLVER_PATHRESOLVER_H
00003
00004 #include "AsgTools/AsgMessaging.h"
00005
00006 #include <string>
00007
00008
00009 class PathResolver
00010
00011 {
00012 public:
00013 typedef enum
00014 {
00015 Ok,
00016 EnvironmentVariableUndefined,
00017 UnknownDirectory
00018 } SearchPathStatus;
00019
00020 typedef enum
00021 {
00022 LocalSearch,
00023 RecursiveSearch
00024 } SearchType;
00025
00026 typedef enum {
00027 PR_regular_file,
00028 PR_directory
00029 } PR_file_type;
00030
00031 PathResolver();
00032
00043 static std::string find_file (const std::string& logical_file_name,
00044 const std::string& search_path,
00045 SearchType search_type = LocalSearch);
00046
00056 static std::string find_file_from_list (const std::string& logical_file_name,
00057 const std::string& search_list,
00058 SearchType search_type = LocalSearch);
00059
00060
00070 static std::string find_directory (const std::string& logical_file_name,
00071 const std::string& search_path,
00072 SearchType search_type = LocalSearch);
00073
00083 static std::string find_directory_from_list (const std::string& logical_file_name,
00084 const std::string& search_list,
00085 SearchType search_type = LocalSearch);
00086
00087
00095 static SearchPathStatus check_search_path (const std::string& search_path);
00096
00097
00098 static std::string find_calib_file(const std::string& logical_file_name);
00099 static std::string find_calib_directory(const std::string& logical_file_name);
00100
00101 static void setOutputLevel(MSG::Level level);
00102
00103 inline static std::string FindCalibFile(const std::string& logical_file_name) { return find_calib_file(logical_file_name); }
00104 inline static std::string FindCalibDirectory(const std::string& logical_file_name) { return find_calib_directory(logical_file_name); }
00105 inline static void SetOutputLevel(int lvl) { setOutputLevel(MSG::Level(lvl)); }
00106
00107 private:
00108 static bool PR_find( const std::string& logical_file_name, const std::string& search_list, PR_file_type file_type, SearchType search_type,
00109 std::string& result );
00110
00111
00112 static bool m_setLevel;
00113
00114
00115
00116 static bool msgLvl( const MSG::Level lvl ) { return asgMsg().msgLvl(lvl); }
00117 static MsgStream& msg() { return asgMsg().msg(); }
00118 static MsgStream& msg( const MSG::Level lvl ) { return asgMsg().msg(lvl); }
00119 static asg::AsgMessaging& asgMsg();
00120
00121
00122 };
00123
00124 std::string PathResolverFindXMLFile (const std::string& logical_file_name);
00125 std::string PathResolverFindDataFile (const std::string& logical_file_name);
00126 std::string PathResolverFindCalibFile (const std::string& logical_file_name);
00127 std::string PathResolverFindCalibDirectory (const std::string& logical_file_name);
00128 void PathResolverSetOutputLevel(int lvl);
00129
00130 #endif