IMediaLibrary.h 2.86 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 IMetadataCb
12
{
13 14 15 16 17 18 19
public:
    virtual ~IMetadataCb() = default;
    /**
     * @brief onMetadataUpdated Will be called when a file gets some updated metadata
     * @param file The updated file.
     */
    virtual void onMetadataUpdated( FilePtr file ) = 0;
20 21
};

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

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

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

61 62 63 64 65 66 67
        /**
         * @brief discover Launch a discovery on the provided entry point.
         * There no garanty on how this will be processed, or if it will be processed synchronously or not.
         * 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;
68
        virtual const std::string& snapshotPath() const = 0;
69 70
};

71 72 73 74 75 76
class MediaLibraryFactory
{
    public:
        static IMediaLibrary* create();
};

77
#endif // IMEDIALIBRARY_H