WSF
ProjectWorkspace.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef PROJECTWORKSPACE_HPP
13#define PROJECTWORKSPACE_HPP
14
15#include <set>
16
17#include <QFuture>
18#include <QThread>
19#include <QTime>
20#include <QTimer>
21
22#include "FileSignature.hpp"
24#include "UtCallbackHolder.hpp"
25#include "UtMemory.hpp"
26#include "UtPath.hpp"
27#include "UtSemaphore.hpp"
28#include "UtThread.hpp"
29
30class UtTextDocumentRange;
31class ViMainWindow;
32class UtTextDocument;
33
34namespace wizard
35{
36class ActionManager;
37class CreateNewFile;
38class EditorManager;
39class Project;
40class ProxyMerge;
41class TextSource;
42class TextSourceCache;
43class TextSourceView;
44class WsfConnector;
45class WsfExecution;
46
47class VI_EXPORT ProjectWorkspace : public QObject
48{
49 Q_OBJECT
50public:
52 ~ProjectWorkspace() override;
53
54 static ProjectWorkspace* Instance();
55
56 TextSourceCache* GetSourceCache() const { return mSourceCachePtr; }
57
58 Project* GetProject();
59
60 void Update();
62
63 void customEvent(QEvent*) override;
64
65 void WaitForParsing();
67 // void CompleteParsing();
68 void RequestReparseWsf(TextSource* aSourcePtr);
69
70 void WaitForSourceModifications(TextSource* aSourcePtr);
71
72 void ProjectAdded(Project* aProjectPtr);
73 void RemoveProject(Project* aProjectPtr);
74 void NotifyOfSourceChange(TextSource* aSourcePtr);
75 void ViewOpened(TextSourceView* aViewPtr);
76 void ViewClosed(TextSourceView* aViewPtr);
77 ActionManager* GetActionManager() const { return mActionManagerPtr; }
78 EditorManager* GetEditorManager() const { return mEditorPtr; }
79 bool ParseIsUpToDate();
82 double GetLastGrammarParseTime() const noexcept;
85 double GetLastInputParseTime() const noexcept;
88 double GetLastProxyDeserializeTime() const noexcept;
91 double GetLastProxyMergeGUI_Time() const noexcept;
92 void ReparseAll();
93
94 // This version will block while parsing finishing and then run.
95 // Prefer ScheduleCheckingFilesForModification() where possible.
96 void CheckFilesForModification();
97 // This version will set a flag to check files after parsing finishes if parsing is currently
98 // happening or now if no parsing is happening.
99 void ScheduleCheckingFilesForModification();
100
101 void ApplicationActivated();
102 void SaveAll();
103 void ParseStatistics();
104
105 TextSource* FindSource(const std::string& aPath, bool aCreate, bool aRead);
106 std::vector<TextSource*> GetSourceList();
107 wizard::Editor* OpenSource(TextSource* aSourcePtr);
108 wizard::Editor* GotoRange(const UtTextDocumentRange& aRange);
109 wizard::Editor* GotoRange(const std::string& aFilePath, size_t aLineNumber);
110 wizard::Editor* GotoFile(UtTextDocument* aSourcePtr, bool aRecordLocation);
111 wizard::Editor* GotoFile(const std::string& aFilePath, bool aRecordLocation = true);
112 bool RequestClose(bool aForce = false);
113
114 void ProjectIncrementParseNumber() { ++mModificationSequenceNumber; }
115 void TouchParse(bool aUpdateQuick = false);
116 void RestyleViews();
117
118 void StartExecution(WsfExecution* aExecutionPtr);
119 void StopAllExecutions();
120 const std::vector<WsfExecution*>& GetExecutions() const { return mExecutions; }
121
122 VI_DEPRECATED void EmitProxyUpdated(ProxyMerge* aProxyMerge);
123
124 struct FileStat
125 {
127 UtPath mPath;
128 };
129
130 void BeginSerialize();
131
132 WsfConnector* GetWsfConnector() { return mWsfConnectorPtr; }
133
134 bool IsProcessing() const;
135
136 void NewProject();
137 void CreateA_NewFile(Project* aProject, const UtPath& aDir);
138
139signals:
140 void ProjectOpened(Project* aProjectPtr);
141 void ProjectClosed(Project* aProjectPtr);
142 void ActiveProjectChanged(Project* aProjectPtr);
143 void StartingExecution(WsfExecution* aExecutionPtr);
144 void ParseStatisticsReady(Project* aProjectPtr, QString aReportText);
145
146 void SourceRemoved(TextSource* aSourcePtr);
147 void ProxyUpdated(ProxyMerge* aProxyMerge);
148
150 void FullParseComplete(Project* aProjectPtr);
151
153 void PerformanceResult(Project* aProjectPtr, QString aWorkType, int aTimeToCompleteMS);
154
155 void NewTextSource(TextSource* aSourcePtr);
156
157 // Debug session has started/ended
158 void ChangeDebug(bool aIsActive);
159
160protected slots:
161 void ExecutionDestroyed(QObject* aObjectPtr);
162 void OnChangeDebug(bool aIsActive);
163
164private:
165 void OnParseCompletion();
166 void CheckFilesForModificationInternal();
167
168 QString OutputPerformanceString(Project* aProjectPtr, int aTimeSpentParsing, int aTimeSpentProxying);
169 void SetModified(bool aUpdateQuick = false);
170 void BeginUpdateParse(bool aTesting);
171 bool DelayedFileModificationCheck();
172
173 void SyncModifiedWsfSources();
174
175 void InitializeNewSources();
176
178 bool mTouched;
179
180 // Files that have pending modifications (usually from the text editor)
181 std::set<TextSource*> mModifiedWsfSources;
183 volatile int mModificationSequenceNumberBeingParsed;
185 volatile int mModificationSequenceNumber;
187 int mParsedModificationSequenceNumber;
188
189 TextSourceCache* mSourceCachePtr;
190 ProjectParseThread mParseThread;
191
192 // After a parse is completed, there are many things that need updated.
193 // These members are used to do a 'full update' at a later time:
194 int mFullUpdateSequenceNumber;
195 QTime mFullUpdateTime;
196 bool mFullUpdateQuick;
197 int mPreventUpdates;
198
199 bool mTriggerParseAll;
201
202 Project* mProjectPtr;
203
204 ActionManager* mActionManagerPtr;
205 EditorManager* mEditorPtr;
206 std::vector<TextSourceView*> mOpenViews;
207
208 UtCallbackHolder mCallbacks;
209
210 std::vector<WsfExecution*> mExecutions;
211
212 int mCurrentTaskId;
213
214 // Future to grab file stats when application focus is lost and regained
215 QFuture<FileStat> mFileModCheckFuture;
216
217 WsfConnector* mWsfConnectorPtr;
218
219 CreateNewFile* mNewFileDialogPtr;
220
221 bool mCheckFilesAfterParse = false;
222
223public:
224 // STATIC Access
225 static int GetMaximumWSF_FileSize() { return mMaximumWSF_FileSize; }
226 static void SetMaximumWSF_FileSize(int aFileSize) { mMaximumWSF_FileSize = aFileSize; }
227
228private:
229 static int mMaximumWSF_FileSize;
230 bool mDebug; // True if debug session is active
231};
232} // namespace wizard
233
235
236#endif
Q_DECLARE_METATYPE(wizard::ProjectWorkspace *)
#define VI_DEPRECATED
Definition ViExport.hpp:39
#define VI_EXPORT
Definition ViExport.hpp:38
aObjectPtr Update(simTime)
Definition ActionManager.hpp:43
Definition CreateNewFile.hpp:27
Definition EditorManager.hpp:41
Definition Editor.hpp:57
Definition FileSignature.hpp:22
Thread for parsing the WSF source in the background.
Definition ProjectParseThread.hpp:23
Definition ProjectWorkspace.hpp:48
void ParseStatisticsReady(Project *aProjectPtr, QString aReportText)
void WaitForAbortParsing()
Definition ProjectWorkspace.cpp:286
static int GetMaximumWSF_FileSize()
Definition ProjectWorkspace.hpp:225
void ChangeDebug(bool aIsActive)
void SourceRemoved(TextSource *aSourcePtr)
void BeginSerialize()
Definition ProjectWorkspace.cpp:825
TextSourceCache * GetSourceCache() const
Definition ProjectWorkspace.hpp:56
QTimer mUpdateTimer
Definition ProjectWorkspace.hpp:61
static void SetMaximumWSF_FileSize(int aFileSize)
Definition ProjectWorkspace.hpp:226
void ActiveProjectChanged(Project *aProjectPtr)
void PerformanceResult(Project *aProjectPtr, QString aWorkType, int aTimeToCompleteMS)
A piece of work has completed. This is used to record timing information.
void WaitForSourceModifications(TextSource *aSourcePtr)
Returns when the source has all queued changes applied. This may require waiting until parsing is com...
Definition ProjectWorkspace.cpp:263
void RequestReparseWsf(TextSource *aSourcePtr)
Definition ProjectWorkspace.cpp:246
void FullParseComplete(Project *aProjectPtr)
The project has been fully parsed and proxied.
void OnChangeDebug(bool aIsActive)
Definition ProjectWorkspace.cpp:921
void ViewOpened(TextSourceView *aViewPtr)
Definition ProjectWorkspace.cpp:306
WsfConnector * GetWsfConnector()
Definition ProjectWorkspace.hpp:132
void customEvent(QEvent *) override
Definition ProjectWorkspace.cpp:703
void StartingExecution(WsfExecution *aExecutionPtr)
EditorManager * GetEditorManager() const
Definition ProjectWorkspace.hpp:78
void ExecutionDestroyed(QObject *aObjectPtr)
Definition ProjectWorkspace.cpp:687
void ViewClosed(TextSourceView *aViewPtr)
Definition ProjectWorkspace.cpp:312
ActionManager * GetActionManager() const
Definition ProjectWorkspace.hpp:77
void NotifyOfSourceChange(TextSource *aSourcePtr)
Definition ProjectWorkspace.cpp:617
void WaitForParsing()
Waits until the parsing thread is complete. This should only be called from the main thread.
Definition ProjectWorkspace.cpp:273
const std::vector< WsfExecution * > & GetExecutions() const
Definition ProjectWorkspace.hpp:120
void ProjectClosed(Project *aProjectPtr)
void ProxyUpdated(ProxyMerge *aProxyMerge)
void ProjectOpened(Project *aProjectPtr)
void ProjectAdded(Project *aProjectPtr)
Definition ProjectWorkspace.cpp:107
ProjectWorkspace()
Definition ProjectWorkspace.cpp:52
void RemoveProject(Project *aProjectPtr)
Definition ProjectWorkspace.cpp:128
void ProjectIncrementParseNumber()
Definition ProjectWorkspace.hpp:114
void NewTextSource(TextSource *aSourcePtr)
static ProjectWorkspace * Instance()
Definition ProjectWorkspace.cpp:820
A WSF 'project'. Manages WSF sources files in a WSF project.
Definition Project.hpp:66
Definition ProxyMerge.hpp:96
Definition TextSourceCache.hpp:35
Definition TextSourceView.hpp:23
Definition TextSource.hpp:48
Definition WsfConnector.hpp:27
Encapsulates the execution of a WSF application.
Definition WsfExecution.hpp:28
Template specialization for wsf::comm::Address. Allows usage of Address in std::unordered_map/set.
Definition WsfCommAddress.hpp:185
Definition Runner.hpp:22
Definition ProjectWorkspace.hpp:125
FileSignature mOldSignature
Definition ProjectWorkspace.hpp:126
UtPath mPath
Definition ProjectWorkspace.hpp:127
Copyrights Multiple, All Rights Reserved