Commit 1d819d59 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

IFile: Expose a file type getter/setter

parent bd21b0c6
......@@ -24,6 +24,8 @@ class IFile
virtual ~IFile() {}
virtual unsigned int id() const = 0;
virtual Type type() = 0;
virtual bool setType( Type type ) = 0;
virtual AlbumTrackPtr albumTrack() = 0;
virtual bool setAlbumTrack(AlbumTrackPtr albumTrack ) = 0;
virtual unsigned int duration() const = 0;
......
......@@ -243,6 +243,23 @@ unsigned int File::id() const
return m_id;
}
IFile::Type File::type()
{
return m_type;
}
bool File::setType( Type type )
{
static const std::string req = "UPDATE " + policy::FileTable::Name
+ " SET type = ? WHERE id_file = ?";
// We need to convert to an integer representation for the sqlite traits to work properly
using type_t = std::underlying_type<Type>::type;
if ( sqlite::Tools::executeUpdate( m_dbConnection, req, static_cast<type_t>( type ), m_id ) == false )
return false;
m_type = type;
return true;
}
bool File::createTable( DBConnection connection )
{
std::string req = "CREATE TABLE IF NOT EXISTS " + policy::FileTable::Name + "("
......
......@@ -46,6 +46,8 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy::
static bool createTable( DBConnection connection );
virtual unsigned int id() const;
virtual Type type() override;
virtual bool setType( Type type ) override;
virtual AlbumTrackPtr albumTrack();
virtual bool setAlbumTrack( AlbumTrackPtr albumTrack );
virtual unsigned int duration() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment