MediaLibrary.h 1.99 KB
Newer Older
1
2
3
#ifndef MEDIALIBRARY_H
#define MEDIALIBRARY_H

4
5
class Parser;

6
7
8
9
10
11
12
13
#include <sqlite3.h>

#include "IMediaLibrary.h"

class MediaLibrary : public IMediaLibrary
{
    public:
        MediaLibrary();
14
        ~MediaLibrary();
15
        virtual bool initialize( const std::string& dbPath, std::shared_ptr<factory::IFileSystem> fsFactory );
16

17
        virtual std::vector<FilePtr> files();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
18
19
        virtual FilePtr file( const std::string& path );
        virtual FilePtr addFile( const std::string& path );
20
21
        virtual bool deleteFile( const std::string& mrl );
        virtual bool deleteFile( FilePtr file );
22
23
24

        virtual FolderPtr addFolder( const std::string& path ) override;
        virtual FolderPtr folder( const std::string& path ) override;
25
        virtual bool deleteFolder( FolderPtr folder ) override;
26

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
27
28
29
        virtual LabelPtr createLabel( const std::string& label );
        virtual bool deleteLabel(const std::string& text );
        virtual bool deleteLabel( LabelPtr label );
30

31
32
        virtual AlbumPtr album( const std::string& title );
        virtual AlbumPtr createAlbum( const std::string& title );
33

34
35
36
        virtual ShowPtr show( const std::string& name );
        virtual ShowPtr createShow( const std::string& name );

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
37
38
39
        virtual MoviePtr movie( const std::string& title );
        virtual MoviePtr createMovie( const std::string& title );

40
        virtual void addMetadataService( IMetadataService* service );
41
42
        virtual void parse( FilePtr file, IParserCb* cb );

43
44
45
    private:
        static const std::vector<std::string> supportedExtensions;

46
47
48
    private:
        bool loadFolders();
        bool checkSubfolders( fs::IDirectory* folder, unsigned int parentId );
49
50
        void checkFiles( fs::IDirectory* folder, unsigned int parentId );
        bool addFile( const std::string& filePath, unsigned int folderId );
51

52
    private:
53
        std::shared_ptr<sqlite3> m_dbConnection;
54
        std::unique_ptr<Parser> m_parser;
55
        std::shared_ptr<factory::IFileSystem> m_fsFactory;
56
57
};
#endif // MEDIALIBRARY_H