IMediaLibrary.h 4.09 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

10
class IMediaLibraryCb
11
{
12
public:
13
    virtual ~IMediaLibraryCb() = default;
14
    /**
15 16 17 18 19 20 21 22 23 24
     * @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.
25 26
     * @param file The updated file.
     */
27
    virtual void onFileUpdated( FilePtr file ) = 0;
28 29 30

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

33
class IMediaLibrary
34 35
{
    public:
36
        virtual ~IMediaLibrary() = default;
37
        ///
38 39 40
        /// \brief  initialize Initializes the media library.
        ///         This will use the provided discoverer to search for new media asynchronously.
        ///
41 42 43
        /// \param dbPath       Path to the database
        /// \return true in case of success, false otherwise
        ///
44
        virtual bool initialize( const std::string& dbPath, const std::string& snapshotPath, IMediaLibraryCb* metadataCb ) = 0;
45 46 47 48 49 50
        /**
         * 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;
51 52 53 54 55 56 57 58
        ///
        /// \brief addFile Adds a file to the media library.
        /// \param path The absolute path to this file
        /// \param parentFolder The parent folder, or nullptr to add this file as
        ///                     a stand alone file.
        /// \return The newly created file, or nullptr in case of error
        ///
        virtual FilePtr addFile( const std::string& path, FolderPtr parentFolder ) = 0;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
59
        virtual FilePtr file( const std::string& path ) = 0;
60 61
        virtual bool deleteFile( const std::string& mrl ) = 0;
        virtual bool deleteFile( FilePtr file ) = 0;
62 63 64

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

67
        virtual LabelPtr createLabel( const std::string& label ) = 0;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
68 69
        virtual bool deleteLabel( const std::string& label ) = 0;
        virtual bool deleteLabel( LabelPtr label ) = 0;
70
        virtual std::vector<FilePtr> files() = 0;
71 72
        virtual std::vector<FilePtr> audioFiles() = 0;
        virtual std::vector<FilePtr> videoFiles() = 0;
73 74
        virtual AlbumPtr album( const std::string& title ) = 0;
        virtual AlbumPtr createAlbum( const std::string& title ) = 0;
75
        virtual std::vector<AlbumPtr> albums() = 0;
76 77
        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
78 79
        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
80 81
        virtual ArtistPtr artist( const std::string& name ) = 0;
        virtual ArtistPtr createArtist( const std::string& name ) = 0;
82
        virtual std::vector<ArtistPtr> artists() const = 0;
83

84 85
        /**
         * @brief discover Launch a discovery on the provided entry point.
86
         * The actuall discovery will run asynchronously, meaning this method will immediatly return.
87 88 89 90
         * 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;
91
        virtual const std::string& snapshotPath() const = 0;
92
        virtual void setLogger( ILogger* logger ) = 0;
93 94
};

95 96 97 98 99 100
class MediaLibraryFactory
{
    public:
        static IMediaLibrary* create();
};

101
#endif // IMEDIALIBRARY_H