Changeset View
Changeset View
Standalone View
Standalone View
src/qmljsc/ir/module.h
Show All 39 Lines | |||||
40 | { | 40 | { | ||
41 | public: | 41 | public: | ||
42 | enum LoadingState { | 42 | enum LoadingState { | ||
43 | Loading, | 43 | Loading, | ||
44 | Successful, | 44 | Successful, | ||
45 | ErrorState | 45 | ErrorState | ||
46 | }; | 46 | }; | ||
47 | 47 | | |||
48 | explicit Module(ImportDescription import, QObject *parent = 0); | 48 | explicit Module(QString name, int versionMajor, int versionMinor, QObject *parent = 0); | ||
49 | ~Module(); | 49 | ~Module(); | ||
50 | 50 | | |||
51 | LoadingState loadingState(); | 51 | LoadingState loadingState(); | ||
52 | void setLoadingState(LoadingState status); | 52 | void setLoadingState(LoadingState status); | ||
53 | 53 | | |||
54 | void waitForLoaded(); | 54 | void waitForLoaded(); | ||
55 | 55 | | |||
56 | /** | 56 | /** | ||
57 | * Returns the type object for the (QML-) name. | 57 | * Returns the type object for the (QML-) name. | ||
58 | * | 58 | * | ||
59 | * If the data isn't available, yet, because the module is still loading, | 59 | * If the data isn't available, yet, because the module is still loading, | ||
60 | * this function will block until the data is available. | 60 | * this function will block until the data is available. | ||
61 | */ | 61 | */ | ||
62 | Type *type(QString name); | 62 | Type *type(QString name); | ||
63 | 63 | | |||
64 | /** | 64 | /** | ||
65 | * Returns the type object for the name it has in JS code. | 65 | * Returns the type object for the name it has in JS code. | ||
66 | * | 66 | * | ||
67 | * This function won't wait for the data to be available, only use this | 67 | * This function won't wait for the data to be available, only use this | ||
68 | * function if you're certain about it! | 68 | * function if you're certain about it! | ||
69 | */ | 69 | */ | ||
70 | Type *typeFromJSName(QString name); | 70 | Type *typeFromJSName(QString name); | ||
71 | 71 | | |||
72 | const QString &name(); | 72 | const QString &name() const; | ||
73 | int versionMajor() const; | ||||
74 | int versionMinor() const; | ||||
73 | 75 | | |||
74 | void addType(Type *type); | 76 | void addType(Type *type); | ||
75 | 77 | | |||
76 | ImportDescription importDescription(); | | |||
77 | | ||||
78 | private: | 78 | private: | ||
79 | QString m_name; | ||||
80 | int m_versionMajor; | ||||
81 | int m_versionMinor; | ||||
79 | QHash<QString, Type*> m_types; | 82 | QHash<QString, Type*> m_types; | ||
80 | QHash<QString, Type*> m_jsNameToTypeHash; | 83 | QHash<QString, Type*> m_jsNameToTypeHash; | ||
81 | ImportDescription m_importDescription; | | |||
82 | LoadingState m_loadingState; | 84 | LoadingState m_loadingState; | ||
83 | QWaitCondition m_loadFinishedCondition; | 85 | QWaitCondition m_loadFinishedCondition; | ||
84 | QMutex m_loadMutex; | 86 | QMutex m_loadMutex; | ||
85 | }; | 87 | }; | ||
86 | 88 | | |||
87 | } // namespace IR | 89 | } // namespace IR | ||
88 | } // namespace QMLJSc | 90 | } // namespace QMLJSc | ||
89 | 91 | | |||
90 | #endif // MODULE_H | 92 | #endif // MODULE_H |