25 #ifndef SHAREDLOADERFACTORY_H
26 #define SHAREDLAODERFACTORY_H
29 #include "../FileUtils.hpp"
36 namespace fs = boost::filesystem;
42 map<string, SharedLoader<T> > libs;
43 map<string, string > paths;
49 void Scan(std::vector<string> dirs) {
50 for(
int i=0; i<dirs.size(); i++)
56 map<string, SharedLoader<T> > &
GetMap() {
return libs; };
57 map<string, string > &
GetPaths() {
return paths; };
73 full_path = fs::system_complete(fs::path(directory, fs::native));
77 if(!fs::exists(full_path))
79 std::cout <<
"Directory does not exist: " << full_path.native_file_string() << std::endl;
83 if(!fs::is_directory(full_path))
85 std::cout << full_path.native_file_string() <<
" is not a directory. "<< std::endl;
91 fs::directory_iterator end_iter;
92 for (fs::directory_iterator dir_itr( full_path );
98 string file = dir_itr->leaf();
100 if(file.length() > 3)
102 if(file.substr(file.length()-3,3) ==
".so")
104 string name = file.substr(0,file.length()-3);
105 string full_name = full_path.native_file_string() +
"/"+file;
106 libs[name].LoadLibrary(full_name.c_str());
107 paths[name] = directory;
108 if(libs[name].Loaded())
120 catch (
const std::exception & ex )