mpd: make Status/Statistics accessors inlineable
This commit is contained in:
165
src/mpdpp.cpp
165
src/mpdpp.cpp
@@ -31,171 +31,6 @@ MPD::Connection Mpd;
|
|||||||
|
|
||||||
namespace MPD {//
|
namespace MPD {//
|
||||||
|
|
||||||
bool Statistics::empty() const
|
|
||||||
{
|
|
||||||
return m_stats.get() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Statistics::artists() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_stats_get_number_of_artists(m_stats.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Statistics::albums() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_stats_get_number_of_albums(m_stats.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Statistics::songs() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_stats_get_number_of_songs(m_stats.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long Statistics::playTime() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_stats_get_play_time(m_stats.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long Statistics::uptime() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_stats_get_uptime(m_stats.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long Statistics::dbUpdateTime() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_stats_get_db_update_time(m_stats.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long Statistics::dbPlayTime() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_stats_get_db_play_time(m_stats.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Status::clear()
|
|
||||||
{
|
|
||||||
m_status.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Status::empty() const
|
|
||||||
{
|
|
||||||
return m_status.get() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Status::volume() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_volume(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Status::repeat() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_repeat(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Status::random() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_random(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Status::single() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_single(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Status::consume() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_consume(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Status::playlistLength() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_queue_length(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Status::playlistVersion() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_queue_version(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerState Status::playerState() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return PlayerState(mpd_status_get_state(m_status.get()));
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Status::crossfade() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_crossfade(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
int Status::currentSongPosition() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_song_pos(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
int Status::currentSongID() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_song_id(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
int Status::nextSongPosition() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_next_song_pos(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
int Status::nextSongID() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_next_song_id(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Status::elapsedTime() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_elapsed_time(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Status::totalTime() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_total_time(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Status::kbps() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_kbit_rate(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Status::updateID() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_update_id(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *Status::error() const
|
|
||||||
{
|
|
||||||
assert(!empty());
|
|
||||||
return mpd_status_get_error(m_status.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
Connection::Connection() : m_connection(nullptr),
|
Connection::Connection() : m_connection(nullptr),
|
||||||
m_command_list_active(false),
|
m_command_list_active(false),
|
||||||
m_idle(false),
|
m_idle(false),
|
||||||
|
|||||||
56
src/mpdpp.h
56
src/mpdpp.h
@@ -71,15 +71,15 @@ struct Statistics
|
|||||||
{
|
{
|
||||||
friend class Connection;
|
friend class Connection;
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const { return m_stats.get() == nullptr; }
|
||||||
|
|
||||||
unsigned artists() const;
|
unsigned artists() const { return mpd_stats_get_number_of_artists(m_stats.get()); }
|
||||||
unsigned albums() const;
|
unsigned albums() const { return mpd_stats_get_number_of_albums(m_stats.get()); }
|
||||||
unsigned songs() const;
|
unsigned songs() const { return mpd_stats_get_number_of_songs(m_stats.get()); }
|
||||||
unsigned long playTime() const;
|
unsigned long playTime() const { return mpd_stats_get_play_time(m_stats.get()); }
|
||||||
unsigned long uptime() const;
|
unsigned long uptime() const { return mpd_stats_get_uptime(m_stats.get()); }
|
||||||
unsigned long dbUpdateTime() const;
|
unsigned long dbUpdateTime() const { return mpd_stats_get_db_update_time(m_stats.get()); }
|
||||||
unsigned long dbPlayTime() const;
|
unsigned long dbPlayTime() const { return mpd_stats_get_db_play_time(m_stats.get()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Statistics(mpd_stats *stats) : m_stats(stats, mpd_stats_free) { }
|
Statistics(mpd_stats *stats) : m_stats(stats, mpd_stats_free) { }
|
||||||
@@ -93,27 +93,27 @@ struct Status
|
|||||||
|
|
||||||
Status() { }
|
Status() { }
|
||||||
|
|
||||||
void clear();
|
void clear() { m_status.reset(); }
|
||||||
bool empty() const;
|
bool empty() const { return m_status.get() == nullptr; }
|
||||||
|
|
||||||
int volume() const;
|
int volume() const { return mpd_status_get_volume(m_status.get()); }
|
||||||
bool repeat() const;
|
bool repeat() const { return mpd_status_get_repeat(m_status.get()); }
|
||||||
bool random() const;
|
bool random() const { return mpd_status_get_random(m_status.get()); }
|
||||||
bool single() const;
|
bool single() const { return mpd_status_get_single(m_status.get()); }
|
||||||
bool consume() const;
|
bool consume() const { return mpd_status_get_consume(m_status.get()); }
|
||||||
unsigned playlistLength() const;
|
unsigned playlistLength() const { return mpd_status_get_queue_length(m_status.get()); }
|
||||||
unsigned playlistVersion() const;
|
unsigned playlistVersion() const { return mpd_status_get_queue_version(m_status.get()); }
|
||||||
PlayerState playerState() const;
|
PlayerState playerState() const { return PlayerState(mpd_status_get_state(m_status.get())); }
|
||||||
unsigned crossfade() const;
|
unsigned crossfade() const { return mpd_status_get_crossfade(m_status.get()); }
|
||||||
int currentSongPosition() const;
|
int currentSongPosition() const { return mpd_status_get_song_pos(m_status.get()); }
|
||||||
int currentSongID() const;
|
int currentSongID() const { return mpd_status_get_song_id(m_status.get()); }
|
||||||
int nextSongPosition() const;
|
int nextSongPosition() const { return mpd_status_get_next_song_pos(m_status.get()); }
|
||||||
int nextSongID() const;
|
int nextSongID() const { return mpd_status_get_next_song_id(m_status.get()); }
|
||||||
unsigned elapsedTime() const;
|
unsigned elapsedTime() const { return mpd_status_get_elapsed_time(m_status.get()); }
|
||||||
unsigned totalTime() const;
|
unsigned totalTime() const { return mpd_status_get_total_time(m_status.get()); }
|
||||||
unsigned kbps() const;
|
unsigned kbps() const { return mpd_status_get_kbit_rate(m_status.get()); }
|
||||||
unsigned updateID() const;
|
unsigned updateID() const { return mpd_status_get_update_id(m_status.get()); }
|
||||||
const char *error() const;
|
const char *error() const { return mpd_status_get_error(m_status.get()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Status(mpd_status *status) : m_status(status, mpd_status_free) { }
|
Status(mpd_status *status) : m_status(status, mpd_status_free) { }
|
||||||
|
|||||||
Reference in New Issue
Block a user