Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

JobCPath.h

Go to the documentation of this file.
00001 
00002 // $Id: JobCPath.h,v 1.38 2007/10/25 17:21:25 bckhouse Exp $
00003 //
00004 // A reconstruction path
00005 //
00006 // messier@huhepl.harvard.edu
00008 #ifndef JOBCPATH_H
00009 #define JOBCPATH_H
00010 #ifndef STRING
00011 #include <string>
00012 #define STRING
00013 #endif
00014 #ifndef LIST
00015 #include <list>
00016 #define LIST
00017 #endif
00018 #ifndef __CINT__
00019 # ifdef SITE_HAS_SIGC
00020 #  ifndef SIGNAL_H
00021 #   include "sigc++/signal.h"
00022 #   define SIGNAL_H
00023 #  endif
00024 # endif
00025 #endif
00026 #ifndef JOBCRESULT_H
00027 #include "JobControl/JobCResult.h"
00028 #endif
00029 #ifndef JOBCGRAPHVTX_H
00030 #include "JobControl/JobCGraphVtx.h"
00031 #endif
00032 #ifndef JOBCNODE_H
00033 #include "JobControl/JobCNode.h"
00034 #endif
00035 #ifndef ROOT_Rtypes
00036 #if !defined(__CINT__) || defined(__MAKECINT__)
00037 #include "Rtypes.h" // Needed for ClassDef and ClassImp macros
00038 #endif
00039 #endif
00040 
00041 class MomNavigator;
00042 class JobCModule;
00043 class JobCInputModule;
00044 class JobCNode;
00045 
00046 // Set a limit to prevent jobs from spiraling off to infinity
00047 #define JOBCPATH_RUN_LIMIT (1000000000)
00048 
00049 class JobCPath : public JobCGraphVtx
00050 {
00051   friend ostream& operator<<(ostream& os, const JobCPath& p);
00052 public:
00053   typedef enum ERunMode {
00054     kRunAll,
00055     kRunNin,
00056     kRunNpass,
00057     kRunNfail
00058   } RunMode_t;
00059 
00060   typedef list<JobCModule*>::const_iterator ModuleIterator;
00061   typedef list<JobCNode*>::const_iterator   NodeIterator;
00062 
00063 public:
00064   JobCPath();
00065   JobCPath(const char *name, MomNavigator* mom, JobCInputModule* input);
00066   virtual ~JobCPath();
00067 
00068 public:
00069   // The set of commands I expect people to use in macros
00070   JobCModule& Mod(const char *moduleName);
00071   JobCNode&   Node(const char* nodeName);
00072   void        Report();
00073   void        Run(int n=JOBCPATH_RUN_LIMIT, RunMode_t mode=JobCPath::kRunNin);
00074   void        RunNin(int n);   // Run until n events have been read in
00075   void        RunNpass(int n); // Run until n events have passed cuts
00076   void        RunNfail(int n); // Run until n events have failed cuts
00077   void        SetAllFilters(bool onOff);
00078   void        ReverseAllFilters();
00079 
00080   JobCResult  LastResult() const { return fResult; }
00081 
00082   // Commands I expect will only be used internally
00083   const char*    GetName()          const;
00084   void           Print(ostream& os) const;
00085 
00086   JobCModule* GetModule(const char* moduleName, bool create=false);
00087   JobCNode*   FindNode(const char* module, const char* method);
00088   JobCInputModule* GetInputModule();
00089 
00090   JobCNode* PushFront( const char *moduleName, const char *methodName);
00091   JobCNode* PushBack(  const char *moduleName, const char *methodName);
00092   JobCNode* AddAt(     const char *moduleName, const char *methodName, int n);
00093   JobCNode* AddBetween(const char *moduleName, const char *methodName,
00094                        const char *afterNodeName, const char *beforeNodeName);
00095   void      Remove(    const char *moduleName, const char *methodName);
00096 
00097   // JobCGraphVtx interface
00098   void       Attach(JobCGraphVtx *p);
00099   void       Detach(JobCGraphVtx *p) ;
00100   bool       EvalInput(JobCRecord* rec);
00101   JobCResult Execute(JobCRecord* rec);
00102   void       BeginJob() const;
00103 
00104   ModuleIterator GetModuleBegin() { return fModuleList.begin(); }
00105   ModuleIterator GetModuleEnd()   { return fModuleList.end(); }
00106   NodeIterator   GetNodeBegin()   { return fNodeList.begin(); }
00107   NodeIterator   GetNodeEnd()     { return fNodeList.end(); }
00108   void           HandleResult(const JobCResult& r) const;
00109   void           SetRefreshMode(bool onOff)        const;
00110 
00111 #ifndef __CINT__
00112 #ifdef SITE_HAS_SIGC
00113 public:
00114   // Emit signals when state changes
00115   typedef enum EUpdateCodes {
00116     kAddNode,          // Node added
00117     kRemoveNode,       // Node removed
00118     kAddConnection,    // New path attached
00119     kRemoveConnection, // New path attached
00120     kFilters,          // Node filters changed
00121     kGeneral           // Can't tell you exactly, assume everything...
00122   } Update_t;
00123   SigC::Signal1<void,JobCPath*>                    SigDelete;
00124   SigC::Signal2<void,JobCPath*,JobCPath::Update_t> SigUpdate;
00125   SigC::Signal1<void,JobCPath*>                    SigStartRun;
00126   SigC::Signal1<void,JobCPath*>                    SigEndRun;
00127 
00128   // Provide a call-back to handle node reconfiguration
00129   void NodeUpdateCB(JobCNode* n, JobCNode::Update_t u);
00130 #endif
00131 private:
00132  public: //rwh for ROOT 2007-01-26
00133   // SigC::Signal1/2 derives from SignalBase which has a private operator=
00134   // CINT attempts to generate explicit assignment unless told not to do so
00135   JobCPath& operator= (const JobCPath&) { abort(); return *this; } // no assignment
00136 #endif
00137 
00138 private:
00139   bool        AtJobStart() const;
00140   void        CheckResult(const JobCResult& r);
00141   JobCNode*   CreateNode(const char* modName, const char* metName);
00142   bool        HandleError(const JobCResult& r, const JobCNode* n);
00143   static void PropagateResult(const JobCResult& r, JobCPath* p);
00144   void        PropagateRefreshMode(bool onOff);
00145   void        SetUniquePaths(const char* base="");
00146 
00147 private:
00148   mutable bool fIsRefreshRun;    // In the process of a refresh run command?
00149   mutable bool fAtJobStart;      // At the start of a job?
00150   string       fName;            // The name of this path
00151   int          fNin;             // Number of events to enter this path
00152   int          fNpass;           // Number of events passed
00153   int          fNfail;           // Number of events failed
00154 
00155   MomNavigator*     fMom;        // Pointer to "the event" data
00156   JobCInputModule*  fInput;      // Input module
00157   list<JobCModule*> fModuleList; // The list of modules used in this path
00158   list<JobCNode*>   fNodeList;   // The list of nodes in this path
00159   JobCResult        fResult;     // The most recent result returned from a node
00160 
00161   mutable JobCModule* fDummyModule; // An empty module used for failed lookups
00162   mutable JobCNode*   fDummyNode;   // An empty node used for failed lookups
00163 
00164   ClassDef(JobCPath,0) // a reconstruction path
00165 };
00166 
00167 #endif // JOBCPATH_H

Generated on Mon Feb 15 11:06:49 2010 for loon by  doxygen 1.3.9.1