001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044 #ifndef APPFRAMEWORK_HH
045 #define APPFRAMEWORK_HH
046
047
048
049 #include "Experiment/Experiment.hh"
050
051
052
053
054 #include "Framework/APPNoCloneModule.hh"
055
056
057
058
059 #include <cstddef>
060
061
062
063
064 class APPExecNode;
065 class APPPath;
066 class APPSequence;
067 class APPInputModule;
068 class APPOutputModule;
069 class AbsEvent;
070 class AppFrame;
071 class AppUserBuild;
072
073 #include "Framework/APPPathCommand.hh"
074 #include "Framework/APPSequenceCommand.hh"
075 #include "Framework/APPModuleCommand.hh"
076 #include "Framework/APPEventsCommand.hh"
077 #include "Framework/APPFilterCommand.hh"
078 #include "Framework/AppConfigCommand.hh"
079
080 #include "Framework/AppAction.hh"
081 #include "Framework/AppStopType.hh"
082 #include "Framework/AppMethodBase.hh"
083 #include "Framework/AbsParmGeneral.hh"
084
085 template<class Item> class APPHash;
086 template<class Item> class APPList;
087
088
089
090
091
092 class AppFramework : public APPNoCloneModule {
093
094 friend class AppBuild;
095
096
097
098
099 public:
100
101
102 #ifdef CDF
103 AppFramework( int argc, char* argv[] );
104 #else
105 AppFramework( int argc, char* argv[], Tcl_Interp *interp);
106 #endif
107
108
109 virtual ~AppFramework( );
110
111
112
113 virtual AppResult beginJob( AbsEvent* anEvent );
114 virtual AppResult beginRun( AbsEvent* anEvent );
115
116 virtual AppResult event( AbsEvent* anEvent );
117 virtual AppResult other( AbsEvent* anEvent );
118
119 virtual AppResult frame( AppFrame* aFrame,
120 const AppStopType& theDispatchStopType );
121
122 virtual AppResult endRun( AbsEvent* anEvent );
123 virtual AppResult endJob( AbsEvent* anEvent );
124
125 virtual AppResult abortJob( AbsEvent* anEvent );
126
127 virtual AppResult inputEvent( AbsEvent*& anEvent );
128
129 virtual AppResult outputEvent( AbsEvent*& anEvent );
130
131 virtual void talkTo( );
132 virtual void help( int argc, char** argv );
133 virtual void exit( );
134
135
136
137 virtual void show( int argc, char** argv ) const;
138
139 virtual void beginHandler ( int nEvents );
140 virtual void continueHandler( int nEvents );
141
142 void resetIndent ( );
143 void increaseIndent( );
144 void decreaseIndent( );
145 void skipToIndent ( );
146 void printName ( const char* const theName, int mode = 0 );
147
148
149 #ifndef CDF
150 Tcl_Interp* tclInterpreter( ) const;
151 #endif
152 bool isExitRequested ( ) const;
153 bool isStopRequested ( ) const;
154 int lastEventRequest ( ) const;
155
156 APPInputModule* theInputModule ( ) const;
157 APPOutputModule* theOutputModule ( ) const;
158
159 #ifndef CDF
160 AppJob* theJob() const;
161 AppRun* theRun() const;
162 #endif
163
164 APPExecutable* fetch ( const char* const aName ) const;
165 AppModule* fetchModule ( const char* const aName ) const;
166 APPPath* fetchPath ( const char* const aName ) const;
167 APPSequence* fetchSequence( const char* const aName ) const;
168 bool has ( const char* const aName ) const;
169 bool hasModule ( const char* const aName ) const;
170 bool hasPath ( const char* const aName ) const;
171 bool hasSequence ( const char* const aName ) const;
172
173 APPList< APPExecNode* >* nodes ( ) const;
174 APPList< AppModule* >* modules ( ) const;
175 APPList< APPPath* >* paths ( ) const;
176 APPList< APPSequence* >* sequences( ) const;
177
178 APPList< APPInputModule* >* inputModules ( ) const;
179 APPList< APPOutputModule* >* outputModules( ) const;
180 APPList< AppModule* >* allAsModules ( ) const;
181
182 APPExecutable* execFromName( const char* const theName ) const;
183 int maxNameLength( ) const;
184 int procStatus( ) const {return _procStatus;}
185
186
187
188 void setBegun ( bool state );
189
190 void setProcReturn( const int status ) {if (status!=0) _procStatus=status;}
191
192 #ifndef CDF
193 void setTclInterpreter( const Tcl_Interp* const theInterp );
194 void setCommandPrompt( const char* const thePrompt );
195 #endif
196
197 void setTheInputModule (APPInputModule* thatOne);
198 void setTheOutputModule (APPOutputModule* thatOne);
199
200
201
202 bool setInputModule ( const char* const aName );
203 bool setOutputModule ( const char* const aName );
204
205
206
207 virtual void add ( AppModule* const aModule );
208 virtual void add ( const APPExecNode* const aNode );
209 virtual void add ( APPInputModule* const aModule );
210 virtual void add ( APPOutputModule* const aModule );
211 virtual void add ( APPSequence* const aSequence );
212
213 virtual void add ( APPPath* const aPath );
214
215
216
217
218 virtual void remove( const APPExecNode* const aNode );
219 virtual void remove( const AppModule* const aModule );
220 virtual void remove( const APPInputModule* const aModule );
221 virtual void remove( const APPOutputModule* const aModule );
222 virtual void remove( const APPSequence* const aSequence );
223 virtual void remove( const APPPath* const aPath );
224
225
226 void rebuildAllAsModules( );
227
228
229 void requestStop( ) {_stopRequested = true;};
230
231
232
233 APPList<AppAction*>* actions() const { return _actions;}
234
235
236 APPList<AppMethodBase*>* appMethods() const {return _theAppMethodsGrabBag;}
237
238 #ifdef CDF
239
240 std::string processName( ) const;
241
242
243 std::string creatingProcess( ) const;
244
245 void addCDFrequiredActions( );
246
247
248 int argc () const;
249 char** argv () const;
250 #endif
251
252 void setupTheApp( );
253
254 #ifndef CDF
255
256 int setTclVariables( );
257 void setTclPaths( );
258
259 void setTkInterfaceON( ) {_TkInterface=1;}
260 void setTkInterfaceOFF( ) {_TkInterface=0;}
261 int getTkInterface( ) {return _TkInterface;}
262 #endif
263 void setupTheApp(AppUserBuild* build);
264 bool useRCPsys( ) { return _useRCPsys.value( ); }
265
266
267 AppUserBuild* appBuilder();
268
269 private:
270
271
272 AppFramework( const AppFramework& );
273
274
275 void resetNodes( );
276 APPPath* getDefaultPath();
277 void resetAppMethods( bool toThis );
278
279 void _makeControllers( const APPList< AppModule* >* modList );
280 void _makeControllers( const APPList< APPInputModule* >* modList );
281 void _makeControllers( const APPList< APPOutputModule* >* modList );
282
283 void _buildModuleList( APPList<AppModule*>& destination , APPList<APPInputModule*>& source );
284 void _buildModuleList( APPList<AppModule*>& destination , APPList<APPOutputModule*>& source );
285 void _buildModuleList( APPList<AppModule*>& destination , APPList<AppModule*>& source );
286
287
288
289 #ifndef CDF
290 Tcl_Interp* _tclInterpreter;
291 char* _commandPrompt;
292 #endif
293 bool _exitRequested;
294 int _procStatus;
295
296 APPHash< APPExecutable >* _executables;
297
298 APPList< APPExecNode* >* _execNodes;
299 APPList< AppModule* >* _modules;
300 APPList< APPPath* >* _paths;
301 APPList< APPSequence* >* _sequences;
302
303 APPList< APPInputModule* >* _inputModules;
304 APPInputModule* _theInputModule;
305 APPList< APPOutputModule* >* _outputModules;
306 APPOutputModule* _theOutputModule;
307
308
309
310 APPList< AppModule* >* _allAsModules;
311 APPPath* _defaultPath;
312
313 bool _isBegun;
314 int _indentLevel;
315 size_t _maxNameLength;
316 #ifndef CDF
317 AppJob* _theJob;
318 AppRun* _theRun;
319 #endif
320 int _argc;
321 char** _argv;
322
323 bool _stopRequested;
324 int _lastEventReq;
325 std::string _procName;
326
327 APPEventsCommand _eventsCmd;
328 APPModuleCommand _moduleCmd;
329 APPPathCommand _pathCmd;
330 APPSequenceCommand _sequenceCmd;
331 APPFilterCommand _filterCmd;
332 AppConfigCommand _configCmd;
333
334 AbsParmGeneral<std::string> _creatingProcess;
335 AbsParmGeneral<bool> _useRCPsys;
336
337
338
339 APPList<AppAction*>* _actions;
340
341
342
343
344
345
346 APPList<AppMethodBase*>* _theAppMethodsGrabBag;
347
348
349
350
351
352
353 AppFrame* _theFrame;
354 AppStopType _theDispatchStopType;
355 AbsEvent* _theAbsEvent;
356
357
358
359
360
361
362
363
364
365
366 #ifndef CDF
367 int _TkInterface;
368 #endif
369 AppUserBuild* _theAppUserBuild;
370
371 };
372
373
374 #include "Framework/APPFramework.icc"
375
376 #endif
377
378
379
Send problems or questions to cdfcode@fnal.gov