Overte C++ Documentation
BatchLoader.h
1 //
2 // BatchLoader.h
3 // libraries/script-engine/src
4 //
5 // Created by Ryan Huffman on 01/22/15
6 // Copyright 2015 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
14 
15 #ifndef hifi_BatchLoader_h
16 #define hifi_BatchLoader_h
17 
18 #include <QList>
19 #include <QMap>
20 #include <QObject>
21 #include <QSet>
22 #include <QString>
23 #include <QUrl>
24 
25 #include "ScriptCache.h"
26 
27 #include <mutex>
28 
29 // Proxy object internal to <code>BatchLoader</code> to ensure threadsafety during loading actions
30 class ScriptCacheSignalProxy : public QObject {
31  Q_OBJECT
32 public:
33  void receivedContent(const QString& url, const QString& contents, bool isURL, bool success, const QString& status);
34 
35 signals:
36  void contentAvailable(const QString& url, const QString& contents, bool isURL, bool success, const QString& status);
37 };
38 
40 class BatchLoader : public QObject {
41  Q_OBJECT
42 public:
43  BatchLoader(const QList<QUrl>& urls);
44 
45  void start(int maxRetries = ScriptRequest::MAX_RETRIES);
46  bool isFinished() const { return _finished; };
47 
48 signals:
49  void finished(const QMap<QUrl, QString>& data, const QMap<QUrl, QString>& status);
50 
51 private:
52  void checkFinished();
53 
54  bool _started;
55  bool _finished;
56  QSet<QUrl> _urls;
57  QMap<QUrl, QString> _data;
58  QMap<QUrl, QString> _status;
59 };
60 
61 #endif // hifi_BatchLoader_h
62 
Load one or more files for use by the scripting engine.
Definition: BatchLoader.h:40