WSF
ParseWorker.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 PARSEWORKER_HPP
13#define PARSEWORKER_HPP
14
15#include <map>
16#include <memory>
17#include <vector>
18
19#include <QEvent>
20
21#include "ProxyMerge.hpp"
22#include "ThreadNotifyEvent.hpp"
23#include "UtMemory.hpp"
24#include "UtPath.hpp"
25#include "WsfPProxy.hpp"
26#include "WsfPProxyRegistry.hpp"
28#include "WsfPProxyType.hpp"
30#include "WsfParseNode.hpp"
31
33class WsfParser;
34
35namespace wizard
36{
37class ParseResults;
38class Project;
39class WsfScriptTypes;
40
42// ParseWorker -- Manages parse related tasks which are done in a helper thread
43// For thread safety, this class only uses data that it owns.
44// Exceptions:
45// ParseDefinitions -- read-only, shared from WsfExe
46//
47//
50{
51public:
53 const static int cMAX_ERROR_COUNT = 100;
54
55 explicit ParseWorker(Project* aProjectPtr);
57
58 // methods to be called from the main thread:
60 void Start(ParseResults* aResultsPtr, int aTaskId, bool aTestingParse);
61
62 std::vector<UtTextDocument*> StartSerialize(int aTaskId,
63 const std::map<WsfPProxyPath, std::string>& aRenameMap,
64 const std::map<WsfPProxyPath, std::string>& aSaveFiles);
65
67
77
78 // This method may be called in another thread.
79 // Result Run();
81
83
84 volatile bool* mAbortSwitch;
85
86 bool IsExecuting() { return mIsExecuting; }
87
88 // ViProxyDataTemplated* TakeProxyPtr() { ViProxyDataTemplated* proxyPtr = mProxyPtr; mProxyPtr = 0; return proxyPtr; }
89
90private:
91 enum TaskType
92 {
93 cTASK_PARSE,
94 cTASK_SERIALIZE
95 };
96
97 struct ParseState
98 {
99 ParseState()
100 : parseTreePtr(nullptr)
101 {
102 }
103 WsfParseNode* parseTreePtr;
104 };
105
106 // The following members are copied here by the main thread
107 struct TaskData
108 {
109 TaskData()
110 : mTaskType(cTASK_PARSE)
111 , mMainFiles()
112 , mParseResultsPtr(nullptr)
113 , mSequenceNumber(-1)
114 , mTaskId(-1)
115 , mTestMode(false)
116 {
117 }
118 TaskType mTaskType;
119 std::vector<UtPath> mMainFiles;
120 ParseResults* mParseResultsPtr;
121 long long mSequenceNumber;
122 int mTaskId;
123 bool mTestMode;
124 WsfPProxyValue proxyToSerialize;
125 };
126
127 void SetDefinitions(const std::shared_ptr<WsfParseDefinitions>& aDefinitionsPtr);
128 Result ParsePhase(ParseState& parseState);
129 Result ProxySyncPhase(ParseState& parseState, const std::unique_ptr<WsfPProxy>& aProxyState);
130 void UpdateIncludeData(WsfParseSourceInclude* aIncludePtr,
131 std::map<UtTextDocument*, WsfParseSourceInclude*>& aFirstIncludes);
132 Result ExecuteSerialize();
133
134 TaskData mTaskData;
135
136 // Parse definitions on loan from WsfExe.
137 std::shared_ptr<WsfParseDefinitions> mDefinitions;
138 std::shared_ptr<WsfPProxyRegistry> mProxyRegistry;
139
140 Project* mProjectPtr;
141 std::unique_ptr<WsfParser> mParserPtr;
142 WsfScriptTypes* mScriptDataBuildPtr;
143 WsfParseNodePool mRootNodePool;
144 std::map<WsfPProxyPath, std::string> mSaveFiles;
145 volatile bool mAborting;
146 bool mFirstDefinitions;
147 volatile bool mIsExecuting;
148};
149} // namespace wizard
150#endif
Definition WsfParseSourceInclude.hpp:31
Definition WsfParser.hpp:36
Provides access to the results of parsing the WSF inputs.
Definition ParseResults.hpp:147
bool IsExecuting()
Definition ParseWorker.hpp:86
std::vector< UtTextDocument * > StartSerialize(int aTaskId, const std::map< WsfPProxyPath, std::string > &aRenameMap, const std::map< WsfPProxyPath, std::string > &aSaveFiles)
Definition ParseWorker.cpp:281
Result ExecuteParse()
Definition ParseWorker.cpp:326
Result
Definition ParseWorker.hpp:69
@ cWORK_DONE
Definition ParseWorker.hpp:75
@ cPROXY_SYNC_COMPLETE
Definition ParseWorker.hpp:73
@ cFAILED
Definition ParseWorker.hpp:70
@ cABORTED
Definition ParseWorker.hpp:71
@ cPARSE_COMPLETE
Definition ParseWorker.hpp:72
@ cPROXY_SERIALIZE_COMPLETE
Definition ParseWorker.hpp:74
~ParseWorker()
Definition ParseWorker.cpp:45
volatile bool * mAbortSwitch
Definition ParseWorker.hpp:84
static const int cMAX_ERROR_COUNT
Definition ParseWorker.hpp:53
Result Execute()
Definition ParseWorker.cpp:96
ParseWorker(Project *aProjectPtr)
Definition ParseWorker.cpp:33
friend class ViProjectParseThread
Definition ParseWorker.hpp:52
void UpdateParseDefinitions()
Updates the parse definitions from the project's selected executable.
Definition ParseWorker.cpp:312
void Start(ParseResults *aResultsPtr, int aTaskId, bool aTestingParse)
Primes the worker to begin a new parse.
Definition ParseWorker.cpp:55
A WSF 'project'. Manages WSF sources files in a WSF project.
Definition Project.hpp:66
Definition WsfScriptData.hpp:213
Definition Runner.hpp:22
Copyrights Multiple, All Rights Reserved