IMediaLibrary.h 3.23 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 11 12
class IParserCb
{
    public:
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
13
        virtual ~IParserCb() = default;
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

        /**
         * @brief onServiceDone will be called after each MetadataService completes
         * @param file      The file being parsed
         * @param status    A flag describing the parsing outcome
         */
        virtual void onServiceDone( FilePtr file, ServiceStatus status ) = 0;
        /**
         * @brief onFileDone will be called when all parsing operations on a given file have been completed
         *
         * This doesn't imply all modules have succeeded
         */
        //FIXME: We should probably expose some way of telling if the user should retry later in
        // case of tmeporary failure
        virtual void onFileDone( FilePtr file ) = 0;
};

31 32 33
class IMediaLibrary
{
    public:
34
        virtual ~IMediaLibrary() {}
35 36 37 38 39 40 41
        ///
        /// \brief initialize Initializes the media library.
        /// \param dbPath       Path to the database
        /// \param fsFactory    An instance to a filesystem factory.
        ///                     In case this is a nullptr, a default factory will be used
        /// \return true in case of success, false otherwise
        ///
42
        virtual bool initialize( const std::string& dbPath, std::shared_ptr<factory::IFileSystem> fsFactory = nullptr ) = 0;
43
        /// Adds a stand alone file
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
44 45
        virtual FilePtr addFile( const std::string& path ) = 0;
        virtual FilePtr file( const std::string& path ) = 0;
46 47
        virtual bool deleteFile( const std::string& mrl ) = 0;
        virtual bool deleteFile( FilePtr file ) = 0;
48 49 50 51

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


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

66 67 68
        /**
         * @brief addMetadataService Adds a service to parse media
         *
69 70 71 72
         * User is expected to add all services before calling parse for the first time.
         * Once parse has been called, adding another service is an undefined behavior.
         * This method will call service->initialize(), therefor the passed ServiceStatus
         * is expected to be uninitialized.
73
         */
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
74
        virtual void addMetadataService( std::unique_ptr<IMetadataService> service ) = 0;
75
        virtual void parse( FilePtr file, IParserCb* cb ) = 0;
76 77
};

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

84
#endif // IMEDIALIBRARY_H