~mediascanner-team/mediascanner2/trunk

« back to all changes in this revision

Viewing changes to src/mediascanner/MediaFileBuilder.hh

  • Committer: CI bot
  • Author(s): James Henstridge
  • Date: 2014-05-30 07:28:56 UTC
  • mfrom: (231.1.14 megamerge)
  • Revision ID: ps-jenkins@lists.canonical.com-20140530072856-x3a6n2qrjxuj7c26
Merge lp:~jpakkane/mediascanner2/nomedia, lp:~jamesh/mediascanner2/mediafile-constructor, lp:~jpakkane/mediascanner2/clangfixes, lp:~jpakkane/mediascanner2/nullguard, lp:~jpakkane/mediascanner2/projectname, lp:~jpakkane/mediascanner2/pruneblocked, lp:~jamesh/mediascanner2/dbus-transport, lp:~jamesh/mediascanner2/dbus-apparmor, lp:~jamesh/mediascanner2/media-filter 

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
namespace mediascanner {
27
27
 
28
28
class MediaFile;
 
29
struct MediaFilePrivate;
29
30
 
30
31
/**
31
32
 * This is a helper class to build MediaFiles. Since we want MediaFiles
33
34
 * all variables in the constructor. This is cumbersome so this class
34
35
 * allows you to gather them one by one and then finally construct
35
36
 * a fully valid MediaFile.
36
 
 *
37
 
 * If you try to assign the same property twice, an exception is thrown.
38
 
 * This means that MediaFileBuilders are meant to build only one
39
 
 * MediaFile. To build a new one create a new MediaFileBuilder. This is to
40
 
 * ensure that no state leaks from the first MediaFile to the second.
41
37
 */
42
38
 
43
39
class MediaFileBuilder final {
 
40
    friend class MediaFile;
44
41
public:
45
42
    MediaFileBuilder(const std::string &filename);
46
43
    MediaFileBuilder(const MediaFile &mf);
47
44
    MediaFileBuilder(const MediaFileBuilder &) = delete;
48
45
    MediaFileBuilder& operator=(MediaFileBuilder &) = delete;
 
46
    ~MediaFileBuilder();
49
47
 
50
48
    MediaFile build() const;
51
49
 
52
 
    void setType(MediaType t);
53
 
    void setETag(const std::string &e);
54
 
    void setContentType(const std::string &c);
55
 
    void setTitle(const std::string &t);
56
 
    void setDate(const std::string &d);
57
 
    void setAuthor(const std::string &a);
58
 
    void setAlbum(const std::string &a);
59
 
    void setAlbumArtist(const std::string &a);
60
 
    void setGenre(const std::string &g);
61
 
    void setDiscNumber(int n);
62
 
    void setTrackNumber(int n);
63
 
    void setDuration(int d);
 
50
    MediaFileBuilder &setType(MediaType t);
 
51
    MediaFileBuilder &setETag(const std::string &e);
 
52
    MediaFileBuilder &setContentType(const std::string &c);
 
53
    MediaFileBuilder &setTitle(const std::string &t);
 
54
    MediaFileBuilder &setDate(const std::string &d);
 
55
    MediaFileBuilder &setAuthor(const std::string &a);
 
56
    MediaFileBuilder &setAlbum(const std::string &a);
 
57
    MediaFileBuilder &setAlbumArtist(const std::string &a);
 
58
    MediaFileBuilder &setGenre(const std::string &g);
 
59
    MediaFileBuilder &setDiscNumber(int n);
 
60
    MediaFileBuilder &setTrackNumber(int n);
 
61
    MediaFileBuilder &setDuration(int d);
64
62
 
65
63
private:
66
 
    bool type_set = false;
67
 
    MediaType type = UnknownMedia;
68
 
 
69
 
    std::string filename;
70
 
 
71
 
    bool content_type_set = false;
72
 
    std::string content_type;
73
 
 
74
 
    bool etag_set = false;
75
 
    std::string etag;
76
 
 
77
 
    bool title_set = false;
78
 
    std::string title;
79
 
 
80
 
    bool date_set = false;
81
 
    std::string date;
82
 
 
83
 
    bool author_set = false;
84
 
    std::string author;
85
 
 
86
 
    bool album_set = false;
87
 
    std::string album;
88
 
 
89
 
    bool album_artist_set = false;
90
 
    std::string album_artist;
91
 
 
92
 
    bool genre_set = false;
93
 
    std::string genre;
94
 
 
95
 
    bool disc_number_set = false;
96
 
    int disc_number = 0;
97
 
 
98
 
    bool track_number_set = false;
99
 
    int track_number = 0;
100
 
 
101
 
    bool duration_set = false;
102
 
    int duration = 0;
 
64
    MediaFilePrivate *p;
103
65
};
104
66
 
105
67
}