src/components/controller.cpp
/**
 * Creates module instances for all the modules in the given alignment block
 */
Creates module instances for all the modules in the given alignment block
Creates module instances for all the modules in the given alignment block
size_t controller::setup_modules(alignment align) {
  string key;
  switch (align) {
    case alignment::LEFT:
      key = "modules-left";
      break;
    case alignment::CENTER:
      key = "modules-center";
      break;
    case alignment::RIGHT:
      key = "modules-right";
      break;
    case alignment::NONE:
      m_log.err("controller: Tried to setup modules for alignment NONE");
      break;
  }
  string configured_modules;
  if (!key.empty()) {
    configured_modules = m_conf.get(m_conf.section(), key, ""s);
  }
  for (auto& module_name : string_util::split(configured_modules, ' ')) {
    if (module_name.empty()) {
      continue;
    }
    try {
      auto type = m_conf.get("module/" + module_name, "type");
      if (type == ipc_module::TYPE && !m_ipc) {
        throw application_error("Inter-process messaging needs to be enabled");
      }
      auto ptr = make_module(move(type), m_bar->settings(), module_name, m_log);
      module_t module = shared_ptr<modules::module_interface>(ptr);
      ptr = nullptr;
      m_modules.push_back(module);
      m_blocks[align].push_back(module);
    } catch (const std::exception& err) {
      m_log.err("Disabling module \"%s\" (reason: %s)", module_name, err.what());
    }
  }
  return m_modules.size();
}
size_t controller :: setup_modules ( alignment align ) { string key ; switch ( align ) { case alignment :: LEFT : key = " " ; break ; case alignment :: CENTER : key = " " ; break ; case alignment :: RIGHT : key = " " ; break ; case alignment :: NONE : m_log . err ( " " ) ; break ; } string configured_modules ; if ( ! key . empty ( ) ) { configured_modules = m_conf . get ( m_conf . section ( ) , key , " " s ) ; } for ( auto & module_name : string_util :: split ( configured_modules , ' ' ) ) { if ( module_name . empty ( ) ) { continue ; } try { auto type = m_conf . get ( " " + module_name , " " ) ; if ( type == ipc_module :: TYPE && ! m_ipc ) { throw application_error ( " " ) ; } auto ptr = make_module ( move ( type ) , m_bar -> settings ( ) , module_name , m_log ) ; module_t module = shared_ptr < modules :: module_interface > ( ptr ) ; ptr = nullptr ; m_modules . push_back ( module ) ; m_blocks [ align ] . push_back ( module ) ; } catch ( const std :: exception & err ) { m_log . err ( " \" \" " , module_name , err . what ( ) ) ; } } return m_modules . size ( ) ; }
Creates module instances for all the modules in the given alignment block
Creates module instances for all the modules in the given alignment block