uniformize ways to convert strings into screen type

This commit is contained in:
Andrzej Rybczak
2014-08-27 08:54:02 +02:00
parent e3e6aa09cc
commit 7fdace835b
9 changed files with 155 additions and 168 deletions

View File

@@ -26,6 +26,7 @@
#include <vector>
#include <mpd/client.h>
#include "actions.h"
#include "screen_type.h"
#include "strbuffer.h"
struct BaseScreen; // forward declaration for screens sequence
@@ -46,27 +47,6 @@ struct Column
bool display_empty_tag;
};
// FIXME: temporary hack
struct ScreenRef
{
ScreenRef() : m_ptr(0) { }
template <typename ScreenT>
ScreenRef(ScreenT *&ptr) : m_ptr(reinterpret_cast<BaseScreen **>(&ptr)) { }
BaseScreen &operator*() const { return **m_ptr; }
BaseScreen *operator->() const { return *m_ptr; }
bool operator==(const ScreenRef &rhs) const { return m_ptr == rhs.m_ptr; }
bool operator!=(const ScreenRef &rhs) const { return m_ptr != rhs.m_ptr; }
bool operator==(const BaseScreen *rhs) const { return *m_ptr == rhs; }
bool operator!=(const BaseScreen *rhs) const { return *m_ptr != rhs; }
operator bool() { return m_ptr != 0; }
private:
BaseScreen **m_ptr;
};
struct Configuration
{
Configuration();
@@ -208,8 +188,8 @@ struct Configuration
size_t now_playing_prefix_length;
size_t now_playing_suffix_length;
ScreenRef startup_screen;
std::list<ScreenRef> screens_seq;
ScreenType startup_screen_type;
std::list<ScreenType> screens_seq;
SortMode browser_sort_mode;