arcspackagemanager.h
1 /*
2  name: tools/pkg/arcspackagemanager.h
3 
4  This file is part of ARCS - Augmented Reality Component System
5  (version 2-current), written by Jean-Yves Didier
6  for IBISC Laboratory (http://www.ibisc.univ-evry.fr)
7 
8  Copyright (C) 2013 Université d'Evry-Val d'Essonne
9 
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Please send bugreports with examples or suggestions to
25  jean-yves.didier__at__ibisc.univ-evry.fr
26 */
27 
28 
29 #ifndef __ARCSPACKAGEMANAGER_H__
30 #define __ARCSPACKAGEMANAGER_H__
31 
32 #include <QString>
33 #include <QStringList>
34 #include <QSettings>
35 #include <QHash>
36 #include <QFile>
37 #include <iostream>
38 
39 
40 class ARCSDownloader;
41 
43 {
44 public:
47 
48  void setSetting(QString s,QString value)
49  {
50  if (hS.contains(s))
51  hS[s]=value;
52  }
53 
54  bool checkSettings();
55  void storeSettings();
56  void displaySettings();
57  bool hasSetting(QString key)
58  {
59  if (!hS.contains(key))
60  return false;
61  return !hS[key].isEmpty();
62  }
63 
64  void buildRepository();
65  void installLibrary(QString libraryName);
66  void installAll();
67 
68  void run() ;
69 
70 
71 private:
72  void parseRepositoryFile(QFile &data);
73 
74  QStringList getRelatedFiles(QString libraryPath);
75 
76  void storeSetting(QString key) {
77  if (!hS[key].isEmpty()) settings.setValue("pkg/"+ key, hS[key]);
78  }
79  void fetchSetting(QString key,QString defValue = QString::null) {
80  hS[key] = settings.value("pkg/"+key, defValue).toString();
81  }
82 
83  void displaySetting(QString key){
84  std::cout << " - " << qPrintable((key+":").leftJustified(20))
85  << qPrintable((hS[key].isEmpty())?"## NOT SET ##":hS[key])
86  << std::endl;
87  }
88 
89  QStringList libs;
90  QStringList libPaths;
91  QSettings settings;
92  ARCSDownloader* ad;
93  QHash<QString,QString> hS;
94 };
95 
96 #endif // __ARCSPACKAGEMANAGER_H__