EffectPluginTypeLoader.cpp 2.08 KB
Newer Older
1
/*****************************************************************************
2
3
 * EffectPluginTypeLoader.cpp: this class is used to load a .so and instantiate
 *                             the IEffectPluginCreator from this
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * Authors: Vincent Carrubba <cyberbouba@gmail.com>
 *
 * 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.
 *****************************************************************************/

24
#include "EffectPluginTypeLoader.h"
Vincent Carrubba's avatar
Vincent Carrubba committed
25

Vincent Carrubba's avatar
Vincent Carrubba committed
26
27
28
29
#include <IEffectPluginCreator.h>

#include <QDebug>

30
EffectPluginTypeLoader::EffectPluginTypeLoader( void ) : m_iepc( NULL )
Vincent Carrubba's avatar
Vincent Carrubba committed
31
{
32
}
Vincent Carrubba's avatar
Vincent Carrubba committed
33

34
EffectPluginTypeLoader::~EffectPluginTypeLoader()
Vincent Carrubba's avatar
Vincent Carrubba committed
35
36
37
{
}

38
IEffectPlugin*   EffectPluginTypeLoader::createIEffectPluginInstance( void ) const
39
{
40
    if ( m_iepc != NULL )
41
42
        return m_iepc->createIEffectPluginInstance();
    return NULL;
43
44
}

45
bool    EffectPluginTypeLoader::load( const QString & fileName )
Vincent Carrubba's avatar
Vincent Carrubba committed
46
{
47
48
49
    QObject*    tmp;
    m_qpl.setFileName( fileName );
    tmp = m_qpl.instance();
50

51
    if ( tmp == NULL )
52
    {
53
        qDebug() << m_qpl.errorString();
54
        return false ;
55
    }
Vincent Carrubba's avatar
Vincent Carrubba committed
56

57
58
59
    m_iepc = qobject_cast<IEffectPluginCreator*>( tmp );
    if ( m_iepc == NULL )
    {
60
61
62
        qDebug() << "The type of the created instance of"
                 << "the loaded class isn't IEffectPluginCreator* !";
        return false;
63
    }
64
    return true;
Vincent Carrubba's avatar
Vincent Carrubba committed
65
}