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

File: Add a Ready flag to signal metadata collection completion

parent 63b6cbdf
...@@ -42,6 +42,8 @@ class IFile ...@@ -42,6 +42,8 @@ class IFile
virtual bool addAudioTrack( const std::string& codec, unsigned int bitrate, virtual bool addAudioTrack( const std::string& codec, unsigned int bitrate,
unsigned int sampleRate, unsigned int nbChannels ) = 0; unsigned int sampleRate, unsigned int nbChannels ) = 0;
virtual bool audioTracks( std::vector<AudioTrackPtr>& tracks ) = 0; virtual bool audioTracks( std::vector<AudioTrackPtr>& tracks ) = 0;
virtual bool isReady() const = 0;
}; };
#endif // IFILE_H #endif // IFILE_H
...@@ -27,6 +27,7 @@ File::File( DBConnection dbConnection, sqlite3_stmt* stmt ) ...@@ -27,6 +27,7 @@ File::File( DBConnection dbConnection, sqlite3_stmt* stmt )
m_showEpisodeId = sqlite3_column_int( stmt, 5 ); m_showEpisodeId = sqlite3_column_int( stmt, 5 );
m_mrl = (const char*)sqlite3_column_text( stmt, 6 ); m_mrl = (const char*)sqlite3_column_text( stmt, 6 );
m_movieId = Traits<unsigned int>::Load( stmt, 7 ); m_movieId = Traits<unsigned int>::Load( stmt, 7 );
m_isReady = m_type != UnknownType;
} }
File::File( const std::string& mrl ) File::File( const std::string& mrl )
...@@ -38,6 +39,7 @@ File::File( const std::string& mrl ) ...@@ -38,6 +39,7 @@ File::File( const std::string& mrl )
, m_showEpisodeId( 0 ) , m_showEpisodeId( 0 )
, m_mrl( mrl ) , m_mrl( mrl )
, m_movieId( 0 ) , m_movieId( 0 )
, m_isReady( false )
{ {
} }
...@@ -183,6 +185,17 @@ bool File::audioTracks( std::vector<AudioTrackPtr>& tracks ) ...@@ -183,6 +185,17 @@ bool File::audioTracks( std::vector<AudioTrackPtr>& tracks )
return SqliteTools::fetchAll<AudioTrack>( m_dbConnection, req, tracks, m_id ); return SqliteTools::fetchAll<AudioTrack>( m_dbConnection, req, tracks, m_id );
} }
bool File::isReady() const
{
return m_isReady;
}
void File::setReady()
{
assert( m_isReady == false );
m_isReady = true;
}
unsigned int File::id() const unsigned int File::id() const
{ {
return m_id; return m_id;
......
...@@ -64,6 +64,9 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy:: ...@@ -64,6 +64,9 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy::
virtual bool addAudioTrack(const std::string& codec, unsigned int bitrate , unsigned int sampleRate, unsigned int nbChannels); virtual bool addAudioTrack(const std::string& codec, unsigned int bitrate , unsigned int sampleRate, unsigned int nbChannels);
virtual bool audioTracks( std::vector<AudioTrackPtr>& tracks ); virtual bool audioTracks( std::vector<AudioTrackPtr>& tracks );
virtual bool isReady() const;
void setReady();
private: private:
DBConnection m_dbConnection; DBConnection m_dbConnection;
...@@ -83,6 +86,8 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy:: ...@@ -83,6 +86,8 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy::
ShowEpisodePtr m_showEpisode; ShowEpisodePtr m_showEpisode;
MoviePtr m_movie; MoviePtr m_movie;
bool m_isReady;
friend class Cache<File, IFile, policy::FileTable, policy::FileCache>; friend class Cache<File, IFile, policy::FileTable, policy::FileCache>;
friend struct policy::FileTable; friend struct policy::FileTable;
}; };
......
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