]> git.sesse.net Git - kdenlive/blob - src/trackpanelfunctionfactory.cpp
add missing files
[kdenlive] / src / trackpanelfunctionfactory.cpp
1 /***************************************************************************
2                           trackpanelfunctionfactory  -  description
3                              -------------------
4     begin                : Sun Dec 28 2003
5     copyright            : (C) 2003 by Jason Wood
6     email                : jasonwood@blueyonder.co.uk
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 #include "trackpanelfunctionfactory.h"
18
19 #include "trackpanelfunction.h"
20
21 #include <KDebug>
22
23 TrackPanelFunctionFactory::TrackPanelFunctionFactory()
24 {
25 }
26
27
28 TrackPanelFunctionFactory::~TrackPanelFunctionFactory()
29 {
30     clearFactory();
31 }
32
33 void TrackPanelFunctionFactory::clearFactory()
34 {
35     QMap < QString, TrackPanelFunction * >::iterator itt =
36         m_functionMap.begin();
37
38     while (itt != m_functionMap.end()) {
39         delete(itt.value());
40         itt.value() = 0;
41         ++itt;
42     }
43     m_functionMap.clear();
44 }
45
46 void TrackPanelFunctionFactory::registerFunction(const QString & name,
47     TrackPanelFunction * function)
48 {
49     if (!m_functionMap.contains(name)) {
50         m_functionMap[name] = function;
51     } else {
52         kError() << "Factory already contains a function called " << name;
53     }
54 }
55
56 TrackPanelFunction *TrackPanelFunctionFactory::
57 function(const QString & name)
58 {
59     if (m_functionMap.contains(name)) {
60         return m_functionMap[name];
61     } else {
62         kError() << "No function called " << name << " found in factory";
63     }
64
65     return 0;
66 }
67
68 #include "trackpanelfunctionfactory.moc"
69