1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-18 13:55:11 -05:00

refactor: Cleanup

This commit is contained in:
Michael Carlberg 2016-12-09 12:43:31 +01:00
parent bff119834a
commit 83f7d2ce91
7 changed files with 17 additions and 18 deletions

View file

@ -8,7 +8,8 @@ POLYBAR_NS
class xresource_manager {
public:
static const xresource_manager& make();
using make_type = const xresource_manager&;
static make_type make();
explicit xresource_manager();

View file

@ -14,8 +14,8 @@ POLYBAR_NS
* Create instance
*/
config::make_type config::make(string path, string bar) {
return static_cast<const config&>(
*factory_util::singleton<const config>(logger::make(), xresource_manager::make(), move(path), move(bar)));
return static_cast<config::make_type>(*factory_util::singleton<std::remove_reference_t<config::make_type>>(
*factory_util::singleton<const config>(logger::make(), xresource_manager::make(), move(path), move(bar))));
}
/**

View file

@ -32,7 +32,7 @@ controller::make_type controller::make(string&& path_confwatch, bool enable_ipc,
eventloop::make(),
bar::make(),
enable_ipc ? ipc::make() : ipc::make_type{},
!path_confwatch.empty() ? inotify_util::make_watch(path_confwatch) : watch_t{},
!path_confwatch.empty() ? inotify_util::make_watch(forward<decltype(path_confwatch)>(path_confwatch)) : watch_t{},
writeback);
// clang-format on
}

View file

@ -11,11 +11,6 @@ POLYBAR_NS
* Create instance
*/
logger::make_type logger::make(loglevel level) {
#ifndef DEBUG
if (level == loglevel::TRACE) {
throw application_error("not a debug build: trace disabled...");
}
#endif
return static_cast<const logger&>(*factory_util::singleton<const logger>(level));
}
@ -52,7 +47,7 @@ logger::logger(loglevel level) : m_level(level) {
void logger::verbosity(loglevel&& level) {
#ifndef DEBUG
if (level == loglevel::TRACE) {
throw application_error("Not a debug build; trace disabled...");
throw application_error("Trace logging is only enabled for debug builds...");
}
#endif
m_level = forward<decltype(level)>(level);

View file

@ -48,8 +48,9 @@ int main(int argc, char** argv) {
throw exit_failure{};
}
connection{xcbconn}.preload_atoms();
connection{xcbconn}.query_extensions();
connection conn{xcbconn};
conn.preload_atoms();
conn.query_extensions();
//==================================================
// Block all signals by default
@ -160,8 +161,9 @@ int main(int argc, char** argv) {
}
try {
logger.info("Reload application...");
process_util::exec(argv[0], argv);
logger.warn("Re-launching application...");
logger.info("Re-launching application...");
process_util::exec(move(argv[0]), move(argv));
} catch (const system_error& err) {
logger.err("execlp() failed (%s)", strerror(errno));
}

View file

@ -12,8 +12,8 @@ POLYBAR_NS
* Create instance
*/
connection::make_type connection::make() {
return static_cast<connection&>(
*factory_util::singleton<connection>(xutils::get_connection(), xutils::get_connection_fd()));
return static_cast<connection::make_type>(*factory_util::singleton<std::remove_reference_t<connection::make_type>>(
xutils::get_connection(), xutils::get_connection_fd()));
}
/**

View file

@ -11,8 +11,9 @@ POLYBAR_NS
/**
* Create instance
*/
const xresource_manager& xresource_manager::make() {
return static_cast<const xresource_manager&>(*factory_util::singleton<xresource_manager>());
xresource_manager::make_type xresource_manager::make() {
return static_cast<xresource_manager::make_type>(
*factory_util::singleton<std::remove_reference_t<xresource_manager::make_type>>());
}
/**