Scine::Swoose  2.1.0
This is the SCINE module Swoose.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
ModuleLoader.h
Go to the documentation of this file.
1 
8 #ifndef SWOOSEUTILITIES_MODULELOADER_H
9 #define SWOOSEUTILITIES_MODULELOADER_H
10 
11 #include <Core/ModuleManager.h>
12 #include <string>
13 #include <vector>
14 
15 namespace Scine {
16 namespace SwooseUtilities {
17 
24 void loadModules(Core::ModuleManager& manager, std::vector<std::string>&& modules, bool throwError) {
25  for (auto module : modules) {
26  if (manager.moduleLoaded(module))
27  continue;
28  module.at(0) = std::tolower(module.at(0)); // convert to lowercase
29  try {
30  manager.load(module);
31  }
32  catch (const std::runtime_error& e) {
33  if (throwError)
34  throw std::runtime_error("Installation did not work properly. Essential modules could not be loaded.");
35  }
36  }
37 }
38 
39 } // namespace SwooseUtilities
40 } // namespace Scine
41 
42 #endif // SWOOSEUTILITIES_MODULELOADER_H