2018-08-09 10:05:48 +00: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 11:30:11 +00:00
|
|
|
return *new waybar::modules::Battery(_config[name]);
|
2018-08-09 10:05:48 +00:00
|
|
|
if (name == "workspaces")
|
|
|
|
return *new waybar::modules::Workspaces(_bar);
|
|
|
|
if (name == "memory")
|
2018-08-09 11:30:11 +00:00
|
|
|
return *new waybar::modules::Memory(_config[name]);
|
2018-08-09 10:05:48 +00:00
|
|
|
if (name == "cpu")
|
2018-08-09 11:30:11 +00:00
|
|
|
return *new waybar::modules::Cpu(_config[name]);
|
2018-08-09 10:05:48 +00:00
|
|
|
if (name == "clock")
|
2018-08-09 11:30:11 +00:00
|
|
|
return *new waybar::modules::Clock(_config[name]);
|
2018-08-09 14:38:24 +00:00
|
|
|
if (name == "network")
|
|
|
|
return *new waybar::modules::Network(_config[name]);
|
2018-08-09 10:05:48 +00:00
|
|
|
throw std::runtime_error("Unknown module: " + name);
|
|
|
|
}
|