63 lines · 1.5 KB · C
RawDownload
////  BatchLoader.h//  libraries/script-engine/src////  Created by Ryan Huffman on 01/22/15//  Copyright 2015 High Fidelity, Inc.////  Distributed under the Apache License, Version 2.0.//  See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html// /// @addtogroup ScriptEngine/// @{ #ifndef hifi_BatchLoader_h#define hifi_BatchLoader_h #include <QList>#include <QMap>#include <QObject>#include <QSet>#include <QString>#include <QUrl> #include "ScriptCache.h" #include <mutex> // Proxy object internal to <code>BatchLoader</code> to ensure threadsafety during loading actionsclass ScriptCacheSignalProxy : public QObject {    Q_OBJECTpublic:    void receivedContent(const QString& url, const QString& contents, bool isURL, bool success, const QString& status); signals:    void contentAvailable(const QString& url, const QString& contents, bool isURL, bool success, const QString& status);}; /// Load one or more files for use by the scripting engineclass BatchLoader : public QObject {    Q_OBJECTpublic:    BatchLoader(const QList<QUrl>& urls);     void start(int maxRetries = ScriptRequest::MAX_RETRIES);    bool isFinished() const { return _finished; }; signals:    void finished(const QMap<QUrl, QString>& data, const QMap<QUrl, QString>& status); private:    void checkFinished();     bool _started;    bool _finished;    QSet<QUrl> _urls;    QMap<QUrl, QString> _data;    QMap<QUrl, QString> _status;}; #endif // hifi_BatchLoader_h /// @}