IMediaLibrary.h 3.22 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
     * @brief onMetadataUpdated Will be called when a file gets added, or if its metadata
     *                          got updated.
18 19
     * @param file The updated file.
     */
20
    virtual void onFileUpdated( FilePtr file ) = 0;
21 22 23

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

26
class IMediaLibrary
27 28
{
    public:
29
        virtual ~IMediaLibrary() {}
30
        ///
31 32 33
        /// \brief  initialize Initializes the media library.
        ///         This will use the provided discoverer to search for new media asynchronously.
        ///
34 35 36
        /// \param dbPath       Path to the database
        /// \return true in case of success, false otherwise
        ///
37
        virtual bool initialize( const std::string& dbPath, const std::string& snapshotPath, IMediaLibraryCb* metadataCb ) = 0;
38 39 40 41 42 43
        /**
         * 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;
44
        /// Adds a stand alone file
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
45 46
        virtual FilePtr addFile( const std::string& path ) = 0;
        virtual FilePtr file( const std::string& path ) = 0;
47 48
        virtual bool deleteFile( const std::string& mrl ) = 0;
        virtual bool deleteFile( FilePtr file ) = 0;
49 50 51

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

54
        virtual LabelPtr createLabel( const std::string& label ) = 0;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
55 56
        virtual bool deleteLabel( const std::string& label ) = 0;
        virtual bool deleteLabel( LabelPtr label ) = 0;
57
        virtual std::vector<FilePtr> files() = 0;
58 59
        virtual std::vector<FilePtr> audioFiles() = 0;
        virtual std::vector<FilePtr> videoFiles() = 0;
60 61
        virtual AlbumPtr album( const std::string& title ) = 0;
        virtual AlbumPtr createAlbum( const std::string& title ) = 0;
62 63
        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
64 65
        virtual MoviePtr movie( const std::string& title ) = 0;
        virtual MoviePtr createMovie( const std::string& title ) = 0;
66

67 68
        /**
         * @brief discover Launch a discovery on the provided entry point.
69
         * The actuall discovery will run asynchronously, meaning this method will immediatly return.
70 71 72 73
         * 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;
74
        virtual const std::string& snapshotPath() const = 0;
75
        virtual void setLogger( ILogger* logger ) = 0;
76 77
};

78 79 80 81 82 83
class MediaLibraryFactory
{
    public:
        static IMediaLibrary* create();
};

84
#endif // IMEDIALIBRARY_H