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

4
5
class Parser;

6
7
8
#include <sqlite3.h>

#include "IMediaLibrary.h"
9
#include "IDiscoverer.h"
10
11
12
13
14

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

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

        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 );

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
40
        virtual void addMetadataService( std::unique_ptr<IMetadataService> service );
41
42
        virtual void parse( FilePtr file, IParserCb* cb );

43
44
45
46
47
48
        virtual void addDiscoverer( std::unique_ptr<IDiscoverer> discoverer ) override;
        virtual void discover( const std::string& entryPoint ) override;
        // IDiscovererCb implementation
        virtual FolderPtr onNewFolder( const fs::IDirectory* directory, FolderPtr parent ) override;
        virtual FilePtr onNewFile(const fs::IFile* file, FolderPtr parent ) override;

49
50
51
    private:
        static const std::vector<std::string> supportedExtensions;

52
53
54
    private:
        bool loadFolders();
        bool checkSubfolders( fs::IDirectory* folder, unsigned int parentId );
55
        void checkFiles( fs::IDirectory* folder, unsigned int parentId );
56
        FilePtr addFile( const fs::IFile* file, unsigned int folderId );
57

58
    private:
59
        std::shared_ptr<sqlite3> m_dbConnection;
60
        std::unique_ptr<Parser> m_parser;
61
        std::shared_ptr<factory::IFileSystem> m_fsFactory;
62
        std::vector<std::unique_ptr<IDiscoverer>> m_discoverers;
63
64
};
#endif // MEDIALIBRARY_H