IMediaLibrary.h 3.73 KB
Newer Older
1 2 3 4 5 6
#ifndef IMEDIALIBRARY_H
#define IMEDIALIBRARY_H

#include <vector>
#include <string>

7
#include "Types.h"
8
#include "factory/IFileSystem.h"
9
#include "IDiscoverer.h"
10

11
class IMediaLibraryCb
12
{
13
public:
14
    virtual ~IMediaLibraryCb() = default;
15
    /**
16 17 18 19 20 21 22 23 24 25
     * @brief onFileAdded Will be called when a file gets added.
     * Depending if the file is being restored or was just discovered,
     * the file type might be a best effort guess. If the file was freshly
     * discovered, it is extremely likely that no metadata will be
     * available yet.
     * @param file
     */
    virtual void onFileAdded( FilePtr file ) = 0;
    /**
     * @brief onFileUpdated Will be called when a file metadata gets updated.
26 27
     * @param file The updated file.
     */
28
    virtual void onFileUpdated( FilePtr file ) = 0;
29 30 31

    virtual void onDiscoveryStarted( const std::string& entryPoint ) = 0;
    virtual void onDiscoveryCompleted( const std::string& entryPoint ) = 0;
32 33
};

34
class IMediaLibrary
35 36
{
    public:
37
        virtual ~IMediaLibrary() = default;
38
        ///
39 40 41
        /// \brief  initialize Initializes the media library.
        ///         This will use the provided discoverer to search for new media asynchronously.
        ///
42 43 44
        /// \param dbPath       Path to the database
        /// \return true in case of success, false otherwise
        ///
45
        virtual bool initialize( const std::string& dbPath, const std::string& snapshotPath, IMediaLibraryCb* metadataCb ) = 0;
46 47 48 49 50 51
        /**
         * Replaces the default filesystem factory
         * The default one will use standard opendir/readdir functions
         * Calling this after initialize() is not a supported scenario.
         */
        virtual void setFsFactory( std::shared_ptr<factory::IFileSystem> fsFactory ) = 0;
52
        /// Adds a stand alone file
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
53 54
        virtual FilePtr addFile( const std::string& path ) = 0;
        virtual FilePtr file( const std::string& path ) = 0;
55 56
        virtual bool deleteFile( const std::string& mrl ) = 0;
        virtual bool deleteFile( FilePtr file ) = 0;
57 58 59

        /// Adds a folder and all the files it contains
        virtual FolderPtr folder( const std::string& path ) = 0;
60
        virtual bool deleteFolder( FolderPtr folder ) = 0;
61

62
        virtual LabelPtr createLabel( const std::string& label ) = 0;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
63 64
        virtual bool deleteLabel( const std::string& label ) = 0;
        virtual bool deleteLabel( LabelPtr label ) = 0;
65
        virtual std::vector<FilePtr> files() = 0;
66 67
        virtual std::vector<FilePtr> audioFiles() = 0;
        virtual std::vector<FilePtr> videoFiles() = 0;
68 69
        virtual AlbumPtr album( const std::string& title ) = 0;
        virtual AlbumPtr createAlbum( const std::string& title ) = 0;
70
        virtual std::vector<AlbumPtr> albums() = 0;
71 72
        virtual ShowPtr show( const std::string& name ) = 0;
        virtual ShowPtr createShow( const std::string& name ) = 0;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
73 74
        virtual MoviePtr movie( const std::string& title ) = 0;
        virtual MoviePtr createMovie( const std::string& title ) = 0;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
75 76
        virtual ArtistPtr artist( const std::string& name ) = 0;
        virtual ArtistPtr createArtist( const std::string& name ) = 0;
77

78 79
        /**
         * @brief discover Launch a discovery on the provided entry point.
80
         * The actuall discovery will run asynchronously, meaning this method will immediatly return.
81 82 83 84
         * Depending on which discoverer modules where provided, this might or might not work
         * @param entryPoint What to discover.
         */
        virtual void discover( const std::string& entryPoint ) = 0;
85
        virtual const std::string& snapshotPath() const = 0;
86
        virtual void setLogger( ILogger* logger ) = 0;
87 88
};

89 90 91 92 93 94
class MediaLibraryFactory
{
    public:
        static IMediaLibrary* create();
};

95
#endif // IMEDIALIBRARY_H