2018-08-09 12:05:48 +02:00
|
|
|
#include "factory.hpp"
|
|
|
|
|
|
|
|
waybar::Factory::Factory(Bar &bar, Json::Value config)
|
|
|
|
: _bar(bar), _config(config)
|
|
|
|
{}
|
|
|
|
|
|
|
|
waybar::IModule &waybar::Factory::makeModule(std::string name)
|
|
|
|
{
|
|
|
|
if (name == "battery")
|
2018-08-09 13:30:11 +02:00
|
|
|
return *new waybar::modules::Battery(_config[name]);
|
2018-08-09 12:05:48 +02:00
|
|
|
if (name == "workspaces")
|
|
|
|
return *new waybar::modules::Workspaces(_bar);
|
|
|
|
if (name == "memory")
|
2018-08-09 13:30:11 +02:00
|
|
|
return *new waybar::modules::Memory(_config[name]);
|
2018-08-09 12:05:48 +02:00
|
|
|
if (name == "cpu")
|
2018-08-09 13:30:11 +02:00
|
|
|
return *new waybar::modules::Cpu(_config[name]);
|
2018-08-09 12:05:48 +02:00
|
|
|
if (name == "clock")
|
2018-08-09 13:30:11 +02:00
|
|
|
return *new waybar::modules::Clock(_config[name]);
|
2018-08-09 16:38:24 +02:00
|
|
|
if (name == "network")
|
|
|
|
return *new waybar::modules::Network(_config[name]);
|
2018-08-09 12:05:48 +02:00
|
|
|
throw std::runtime_error("Unknown module: " + name);
|
|
|
|
}
|