IFile.h 2.66 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*****************************************************************************
 * Media Library
 *****************************************************************************
 * Copyright (C) 2015 Hugo Beauzée-Luyssen, Videolabs
 *
 * Authors: Hugo Beauzée-Luyssen<hugo@beauzee.fr>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#pragma once

#include <string>

27 28 29
namespace medialibrary
{

30 31 32 33 34 35 36
class IFile
{
public:
    enum class Type
    {
        /// Unknown type, so far
        Unknown,
37
        /// The main file of a media.
38 39 40
        Main,
        /// A part of a media (for instance, the first half of a movie)
        Part,
41 42
        /// External soundtrack
        Soundtrack,
43 44
        /// External subtitles
        Subtitles,
45 46
        /// A playlist File
        Playlist,
47 48 49
    };

    virtual ~IFile() = default;
50
    virtual int64_t id() const = 0;
51 52 53 54 55 56 57 58 59 60
    /**
     * @brief mrl Returns the full mrl for this file.
     * Since we can't compute an mrl for a file or folder that is/was present on
     * a removable storage or network share that is not mounted, a
     * fs::DeviceRemovedException will be thrown when trying to get the mrl of
     * a non present file.
     * You should always account for this exception is isRemovable returns true.
     * If for some reasons we can't compute the MRL, an empty string will be returned
     * @return The folder's mrl
     */
61 62 63
    virtual const std::string& mrl() const = 0;
    virtual Type type() const = 0;
    virtual unsigned int lastModificationDate() const = 0;
64
    virtual unsigned int size() const = 0;
65
    virtual bool isRemovable() const = 0;
66 67 68 69
    ///
    /// \brief isExternal returns true if this stream isn't managed by the medialibrary
    ///
    virtual bool isExternal() const = 0;
70 71 72 73 74 75
    /**
     * @brief isNetwork returns true if this file is on a network location
     *
     * If the file is external, this is a best guess effort.
     */
    virtual bool isNetwork() const = 0;
76
};
77 78

}