1 /** 2 * Implements a singleton that maintains program resources. 3 * The single instance is (re)instantiated on demand like: 4 * Resources *res = Resources::Instance(); 5 * 6 * 24-05-07,Nigel Brown(EMBL): created. 7 * 3-7-07, Mark Larkin, modified this class for clustalw 8 */ 9 10 #ifndef RESOURCESCLUSTALW_H 11 #define RESOURCESCLUSTALW_H 12 13 #include <string> 14 15 using namespace std; 16 17 namespace clustalw 18 { 19 20 21 enum ClustalWResourcePathType { 22 DefaultPath, 23 InstallPath, 24 ExecutablePath, 25 HomePath 26 }; 27 28 class ClustalWResources 29 { 30 31 public: 32 /* return the Resources singleton */ 33 static ClustalWResources *Instance(); 34 35 /* setters */ 36 void setPathToExecutable(std::string pathToFiles); 37 38 /* getters */ getDefaultPath()39 std::string getDefaultPath() { return defaultPath; } getInstallPath()40 std::string getInstallPath() { return installPath; } getExecutablePath()41 std::string getExecutablePath() { return executablePath; } getHomePath()42 std::string getHomePath() { return homePath; } 43 44 std::string findFile(const char *file, const ClustalWResourcePathType where = DefaultPath) const; 45 std::string findFile(const std::string file, const ClustalWResourcePathType where = DefaultPath) const; 46 std::string searchPathsForFile(const std::string fileName) const; 47 48 /* debug */ 49 void dump(); 50 51 protected: 52 /* hide the constructors */ 53 ClustalWResources(); 54 ClustalWResources(const ClustalWResources&); 55 ClustalWResources& operator= (const ClustalWResources&); 56 57 std::string dirname(std::string path); 58 59 private: 60 std::string defaultPath; 61 std::string installPath; 62 std::string executablePath; 63 std::string homePath; 64 }; 65 66 } 67 #endif //RESOURCES_H 68