Overte C++ Documentation
ATPAssetMigrator.h
1 //
2 // ATPAssetMigrator.h
3 // interface/src/assets
4 //
5 // Created by Stephen Birarda on 2015-10-12.
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 
12 #pragma once
13 
14 #ifndef hifi_ATPAssetMigrator_h
15 #define hifi_ATPAssetMigrator_h
16 
17 #include <QtCore/QJsonArray>
18 #include <QtCore/QObject>
19 #include <QtCore/QMultiHash>
20 #include <QtCore/QSet>
21 
22 class AssetUpload;
23 class ResourceRequest;
24 class SetMappingRequest;
25 
26 class ATPAssetMigrator : public QObject {
27  Q_OBJECT
28 public:
29  static ATPAssetMigrator& getInstance();
30 
31  void setDialogParent(QWidget* dialogParent) { _dialogParent = dialogParent; }
32 public slots:
33  void loadEntityServerFile();
34 private slots:
35  void assetUploadFinished(AssetUpload* upload, const QString& hash);
36  void setMappingFinished(SetMappingRequest* request);
37 private:
38  void migrateResource(ResourceRequest* request);
39 
40  void checkIfFinished();
41  void saveEntityServerFile();
42 
43  void reset();
44 
45  bool wantsToMigrateResource(const QUrl& url);
46 
47  QWidget* _dialogParent = nullptr;
48  QJsonArray _entitiesArray;
49 
50  bool _doneReading { false };
51 
52  using JSONTypePair = std::pair<QJsonValueRef, quint8>;
53 
54  QMultiHash<QUrl, JSONTypePair> _pendingReplacements;
55  QHash<QUrl, QUrl> _uploadedAssets;
56  QHash<QObject*, QUrl> _originalURLs;
57  QSet<QUrl> _ignoredUrls;
58  int _errorCount { 0 };
59 };
60 
61 
62 #endif // hifi_ATPAssetMigrator_h