1 /*************************************************************************************
2  *  Copyright (C) 2016 Leslie Zhai <xiang.zhai@i-soft.com.cn>                        *
3  *                                                                                   *
4  *  This program is free software; you can redistribute it and/or                    *
5  *  modify it under the terms of the GNU General Public License                      *
6  *  as published by the Free Software Foundation; either version 2                   *
7  *  of the License, or (at your option) any later version.                           *
8  *                                                                                   *
9  *  This program is distributed in the hope that it will be useful,                  *
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
12  *  GNU General Public License for more details.                                     *
13  *                                                                                   *
14  *  You should have received a copy of the GNU General Public License                *
15  *  along with this program; if not, write to the Free Software                      *
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
17  *************************************************************************************/
18 
19 #ifndef CONVERSIONOPTIONSMANAGER_H
20 #define CONVERSIONOPTIONSMANAGER_H
21 
22 #include <QObject>
23 #include <QList>
24 #include <QHash>
25 
26 class ConversionOptions;
27 class PluginLoader;
28 
29 class ConversionOptionsManager : public QObject
30 {
31     Q_OBJECT
32 
33 public:
34     struct ConversionOptionsElement {
35         int id;
36         int references;
37         ConversionOptions *conversionOptions;
38     };
39 
40     ConversionOptionsManager( PluginLoader *_pluginLoader, QObject *parent );
41     ~ConversionOptionsManager();
42 
43     int addConversionOptions( ConversionOptions *conversionOptions );
44     int increaseReferences( int id );
45     const ConversionOptions *getConversionOptions( int id ) const;
46     void removeConversionOptions( int id );
47     int updateConversionOptions( int id, ConversionOptions *conversionOptions );
48 
49     QList<int> getAllIds() const;
50 
51 private:
52     PluginLoader *pluginLoader;
53 
54     QHash<int, ConversionOptionsElement> elements;
55     int idCounter;
56 };
57 
58 #endif
59