Changeset 11692 for code/trunk/src/libraries
- Timestamp:
- Jan 3, 2018, 1:43:20 AM (7 years ago)
- Location:
- code/trunk/src/libraries/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/ApplicationPaths.cc
r11071 r11692 32 32 #include <cstdlib> 33 33 #include <cstdio> 34 #include <fstream> 34 35 #include <vector> 35 36 #include <boost/filesystem.hpp> … … 169 170 } 170 171 171 std:: vector<std::string> ApplicationPaths::getModulePaths()172 std::map<std::string, std::string> ApplicationPaths::getModulePaths() 172 173 { 173 174 return this->getModuleOrPluginPaths(modulePath_, specialConfig::moduleExtension); 174 175 } 175 176 176 std:: vector<std::string> ApplicationPaths::getPluginPaths()177 std::map<std::string, std::string> ApplicationPaths::getPluginPaths() 177 178 { 178 179 return this->getModuleOrPluginPaths(pluginPath_, specialConfig::pluginExtension); 179 180 } 180 181 181 std:: vector<std::string> ApplicationPaths::getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension)182 { 183 std:: vector<std::string> paths;182 std::map<std::string, std::string> ApplicationPaths::getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension) 183 { 184 std::map<std::string, std::string> paths; 184 185 185 186 // We search for helper files with the following extension … … 204 205 { 205 206 // We've found a helper file 206 const std::string& library = filename.substr(0, filename.size() - extensionlength); 207 paths.push_back(directory.BF_GENERIC_STRING() + '/' + library); 207 const std::string& moduleName = filename.substr(0, filename.size() - extensionlength); 208 209 // Read it's content to get the library's name 210 std::ifstream infile(file->path().string().c_str()); 211 std::string libraryName; 212 if (infile >> libraryName) 213 { 214 std::string libraryPath = directory.BF_GENERIC_STRING() + '/' + libraryName; 215 paths[moduleName] = libraryPath; 216 } 217 else 218 { 219 orxout(internal_warning) << "Could not file " << filename << endl; 220 } 208 221 } 209 222 } -
code/trunk/src/libraries/core/ApplicationPaths.h
r11071 r11692 98 98 static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; } 99 99 100 //! Returns a list with all modules declared by a *.module file in the module folder.101 std:: vector<std::string> getModulePaths();102 //! Returns a list with all plugins declared by a *.plugin file in the plugin folder.103 std:: vector<std::string> getPluginPaths();100 //! Returns a map with all modules declared by a *.module file in the module folder; key = module-name, value = library-path (content of the file). 101 std::map<std::string, std::string> getModulePaths(); 102 //! Returns a map with all plugins declared by a *.plugin file in the plugin folder; key = plugin-name, value = library-path (content of the file). 103 std::map<std::string, std::string> getPluginPaths(); 104 104 105 105 private: … … 108 108 ApplicationPaths& operator=(const ApplicationPaths&) = delete; 109 109 110 std:: vector<std::string> getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension);110 std::map<std::string, std::string> getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension); 111 111 112 112 //! Path to the parent directory of the ones above if program was installed with relative paths -
code/trunk/src/libraries/core/Core.cc
r11691 r11692 281 281 orxout(internal_info) << "Loading modules:" << endl; 282 282 283 const std:: vector<std::string>& modulePaths = ApplicationPaths::getInstance().getModulePaths();284 for (const std:: string& modulePath : modulePaths)285 { 286 ModuleInstance* module = new ModuleInstance(modulePath );283 const std::map<std::string, std::string>& modulePaths = ApplicationPaths::getInstance().getModulePaths(); 284 for (const std::pair<std::string, std::string>& modulePath : modulePaths) 285 { 286 ModuleInstance* module = new ModuleInstance(modulePath.second); 287 287 this->loadModule(module); 288 288 this->modules_.push_back(module); -
code/trunk/src/libraries/core/module/PluginManager.cc
r11071 r11692 28 28 29 29 #include "PluginManager.h" 30 31 #include <fstream>32 30 33 31 #include "SpecialConfig.h" … … 95 93 void PluginManager::findPlugins() 96 94 { 97 const std:: vector<std::string>& pluginPaths = ApplicationPaths::getInstance().getPluginPaths();98 for (const std:: string& libraryName: pluginPaths)95 const std::map<std::string, std::string>& pluginPaths = ApplicationPaths::getInstance().getPluginPaths(); 96 for (const std::pair<std::string, std::string>& pluginPath : pluginPaths) 99 97 { 100 std::string name; 101 std::string filename = libraryName + + specialConfig::pluginExtension; 102 std::ifstream infile(filename.c_str()); 103 if (infile >> name) 104 { 105 orxout(internal_info) << "Found plugin with name '" << name << "' in module " << libraryName << endl; 106 this->plugins_[name] = new Plugin(name, libraryName); 107 } 108 else 109 { 110 orxout(internal_warning) << "Could not read plugin file " << filename << endl; 111 } 98 const std::string& name = pluginPath.first; 99 const std::string& libraryName = pluginPath.second; 100 101 orxout(internal_info) << "Found plugin with name '" << name << "' in module " << libraryName << endl; 102 this->plugins_[name] = new Plugin(name, libraryName); 112 103 } 113 104 }
Note: See TracChangeset
for help on using the changeset viewer.