CDF II
CDF KITS
source navigation ]
diff markup ]
identifier search ]
freetext search ]
file search ]
 
Architecture: i386 ]
Version: 4.10.4 ] [ 4.10.5 ] [ 4.8.4 ] [ 4.8.4l3s ] [ 4.8.5 ] [ 4.9.0 ] [ 4.9.1 ] [ 4.9.1.hpt3 ] [ 4.9.1hpt3 ] [ 4.9.1top1 ] [ 5.0.0 ] [ 5.1.0 ] [ 5.1.0beamonly ] [ 5.1.1 ] [ 5.2.0 ] [ 5.3.0 ] [ 5.3.1 ] [ 5.3.1dsp ] [ 5.3.3 ] [ 5.3.3_nt ] [ 5.3.4 ] [ 6.1.1 ] [ 6.1.1b ] [ 6.1.2 ] [ 6.1.3 ] [ 6.1.4 ] [ 6.1.4int3 ] [ 6.1.4mc ] [ 6.1.4mc_a ] [ 6.1.6 ] [ development ]

001 //--------------------------------------------------------------------------
002 // File and Version Information:
003 //      $Id: APPFramework.hh,v 1.31 2004/06/16 20:43:06 sexton Exp $
004 //
005 // Description:
006 //      Class AppFramework. This is the overall framework for the BaBar
007 //      analysis framework. It controls the creation of sequences and
008 //      paths and the processing of events.
009 //
010 // Environment:
011 //      Software developed for the BaBar Detector at the SLAC B-Factory.
012 //
013 // Author List:
014 //      David R. Quarrie                Original Author
015 //      Marc Turcotte                   Introduced Actions '97      May '97
016 //      Marc Turcotte                   Removed explicit dependence
017 //                                      on RW to allow sharing.     June '97
018 //      Marc Turcotte                   Modified for new style begin/end 2/11/98
019 //      Marc Turcotte                   Added execute member function
020 //                                      to deal with dynamic dispatch    3/4/98 
021 //      Marc Turcotte                   Introduced AppStopType           3/20/98
022 //      Marc Turcotte                   Renamed execute to frame         3/26/98
023 //      Marc Turcotte                   Introduced static _theFrame      4/30/98
024 //      Marc Turcotte                   Introduced static _theAbsEvent
025 //                                      but /* */ it for migration       4/30/98
026 //      Marc Turcotte                   Introduced theEvent() &zeroTheEvent() 4/30/98
027 //      Marc Turcotte                   Merged R.Kapur's TK interface         5/98
028 //      Marc Turcotte                   Added setTkInterfaceON/Off and
029 //                                            getTkInterface             6/18/98
030 //      Marc Turcotte                   Modified for AppStatus           6/20/98
031 //      Marc Turcotte                   Added theDispatchStopType to
032 //                                      signatures 6/23/98
033 //      Marc Turcotte                   Changed AppStatus for AppResult 6/23/98
034 //      Marc Turcotte                   Modified for new AbsEvent sigs 6/24/98
035 //      Marc Turcotte                   Migrated setupTheApp from APPMain 7/28/98
036 //      Marc Turcotte                   Added arg list to setupTheApp 8/6/98
037 //
038 // Copyright Information:
039 //      Copyright (C) 1994, 1995        Lawrence Berkeley Laboratory
040 //      Copyright (C) 1997, 1998        University of Texas at Dallas
041 //
042 //------------------------------------------------------------------------
043 
044 #ifndef APPFRAMEWORK_HH
045 #define APPFRAMEWORK_HH
046 //-----------------------
047 // Experiment Headers --
048 //-----------------------
049 #include "Experiment/Experiment.hh"
050 
051 //----------------------
052 // Base Class Headers --
053 //----------------------
054 #include "Framework/APPNoCloneModule.hh"
055 
056 //-------------
057 // C Headers --
058 //-------------
059 #include <cstddef>
060 
061 //------------------------------------
062 // Collaborating Class Declarations --
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 //              -- Class Interface --
090 //              ---------------------
091  
092 class AppFramework : public APPNoCloneModule {
093 
094     friend class AppBuild;
095 //--------------------
096 // Instance Members --
097 //--------------------
098 
099 public:
100 
101     // Constructors
102 #ifdef CDF
103     AppFramework( int argc, char* argv[] );
104 #else
105     AppFramework( int argc, char* argv[], Tcl_Interp *interp);
106 #endif
107 
108     // Destructor
109     virtual ~AppFramework( );
110 
111     // Operations
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 ); // Dynamic Dispatch
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       // Overload show since Framework has lots to show but some of those
136       // are not associated with commands
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     // Selectors (const)
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     // Modifiers
187     
188     void setBegun        ( bool state );
189     // Note that status must be non-zero
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   // these make the passed in module the active i/o module 
197     void setTheInputModule  (APPInputModule* thatOne);
198     void setTheOutputModule (APPOutputModule* thatOne);
199 
200   // these make the passed in module the active i/o module as well as
201   // disable all other i/o modules so use with caution...
202     bool setInputModule  ( const char* const aName );    
203     bool setOutputModule ( const char* const aName );    
204 
205   // the argument objects in all the following add members
206   // have their ownership transferred to the Framework object
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 );  // takes ownership of aPath
214 
215   // the argument objects in all the following remove members
216   // have their ownership transferred from the Framework object
217   // to the caller
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   // Used by clone command:
226   void rebuildAllAsModules( );
227       
228   // how a running module can request that this event is the last one
229   void requestStop( ) {_stopRequested = true;};
230 
231   // Actions
232 
233   APPList<AppAction*>* actions() const { return _actions;}
234 
235   // Grab bag of AppMethods
236   APPList<AppMethodBase*>* appMethods() const {return _theAppMethodsGrabBag;}  
237 
238 #ifdef CDF
239   // This string is derived from argv[0]
240   std::string processName( ) const;
241   // This string may or may not be a truncated version of processName. It is
242   // used by the EDM to mark objects created in this process with a name.
243   std::string creatingProcess( ) const;
244   // This gets called before APPUserBuild and is used to add default things
245   void  addCDFrequiredActions( );
246   // This gets called after APPUserBuild and is used to add default things
247       
248   int         argc           () const;
249   char**      argv           () const;
250 #endif
251       
252   void  setupTheApp( );
253 
254 #ifndef CDF
255    // Tcl
256    int setTclVariables( );  // initialisation
257    void setTclPaths( );    // updates path information
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       // Copy Constructor
272       AppFramework( const AppFramework& );
273 
274       // Private Utilities
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       // Data members
288 
289 #ifndef CDF
290     Tcl_Interp*                  _tclInterpreter;
291     char*                        _commandPrompt;  // owned pointer
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;              // owned list
301     APPList< APPSequence* >*     _sequences;
302 
303     APPList< APPInputModule* >*  _inputModules;
304     APPInputModule*              _theInputModule;
305     APPList< APPOutputModule* >* _outputModules;
306     APPOutputModule*             _theOutputModule;
307     // This list is filled in beginJob, it just has copies of all the pointers 
308     // to modules in the specialized lists which have been dynamic_casted back
309     // to AppModule.
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   // Actions
338    
339   APPList<AppAction*>* _actions;
340 
341   // AppMethods 
342   // This is a toss 'em grab bag and is NOT a hash table. 
343   // Look inside modules for that.
344   //
345   
346   APPList<AppMethodBase*>* _theAppMethodsGrabBag;
347   
348   // Home for the Framework's Frame. There can only be
349   // one framework so it's ok to make the frame
350   // static. In fact, the Framework could migrate to
351   // a singleton class, someday...
352   
353   AppFrame*   _theFrame;
354   AppStopType _theDispatchStopType;
355   AbsEvent*   _theAbsEvent;
356   
357 /**************************************************************
358   
359   Migration code of 4/30/98 is ready below:
360   
361   // Home for the Framework's Event. The same considerations
362   // to Frame also apply.
363   
364   static AbsEvent* _theAbsEvent;
365 **************************************************************/
366 #ifndef CDF
367   int _TkInterface; // ==1 when TK is up and ==0 when not
368 #endif  
369   AppUserBuild* _theAppUserBuild; // main() onws this.
370 
371 };
372 
373 // Inline implementations
374 #include "Framework/APPFramework.icc"
375 
376 #endif
377 
378 
379 

source navigation ] diff markup ] identifier search ] freetext search ] file search ]

This page was automatically generated by the LXR engine.
The LXR team
Valid HTML 4.01!

Send problems or questions to cdfcode@fnal.gov