Library.h 2.97 KB
Newer Older
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*****************************************************************************
 * Library.h: Multimedia library
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * 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 General Public License for more details.
 *
 * You should have received a copy of the GNU 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.
 *****************************************************************************/

23
24
25
26
27
28
/** \file
  * This file the library contains class declaration/definition.
  * It's the the backend part of the Library widget of vlmc.
  * It can load and unload Clips (Clip.h/Clip.cpp)
  */

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
29
30
31
32
33
34
35
#ifndef LIBRARY_H
#define LIBRARY_H

#include <QObject>
#include <QHash>
#include <QUuid>
#include <QFileInfo>
36
37
#include <QMutex>
#include <QMutexLocker>
38
#include <QDomElement>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
39

40
#include "Media.h"
41
#include "Clip.h"
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
42
43
44
45
46
47
48
#include "Singleton.hpp"

class   Library : public QObject, public Singleton<Library>
{
    Q_OBJECT
    Q_DISABLE_COPY( Library );
public:
49
    Media*                  getMedia( const QUuid& uuid );
50
    Clip*                   getClip( const QUuid& uudi );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
51
52
53

private:
    Library();
54
55
    bool                    mediaAlreadyLoaded( const QString& filePath );

56
    QHash<QUuid, Media*>    m_medias;
57
58
59
60
61
62
63
64
65
    QHash<QUuid, Clip*>     m_clips;
    template <typename T>
    T                       getElementByUuid( const QHash<QUuid, T>& container , const QUuid& uuid )
    {
        typename QHash<QUuid, T>::const_iterator   it = container.find( uuid );
        if ( it == container.end() )
            return NULL;
        return *it;
    }
66
    QAtomicInt              m_nbMediasToLoad;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
67
68

public slots:
69
    void                    newMediaLoadingAsked( const QString& filePath, const QString& uuid = QString() );
70
    void                    removingMediaAsked( const QUuid& uuid );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
71

72
    void                    loadProject( const QDomElement& project );
73
    void                    saveProject( QDomDocument& doc, QDomElement& rootNode );
74

75
76
77
private slots:
    void                    metaDataComputed( Media* );

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
78
signals:
79
    void                    newClipLoaded( Clip* );
80
    void                    metadataRequired( Media* );
81
82
    void                    newMediaLoaded( Media* );
    void                    mediaRemoved( const QUuid& );
83
    void                    projectLoaded();
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
84

85
    friend class            Singleton<Library>;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
86
87
88
};

#endif // LIBRARY_H