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

JobCInput.h

Go to the documentation of this file.
00001 
00002 // $Id: JobCInput.h,v 1.22 2009/01/05 06:10:20 schubert Exp $
00003 //
00004 // A module used for getting data into and emtpy data record. This
00005 // module is implemented in terms of any of a variety of
00006 // user/framework provided inputs modules
00007 //
00008 // messier@huhepl.harvard.edu
00010 #ifndef JOBCINPUT_H
00011 #define JOBCINPUT_H
00012 #ifndef JOBCINPUTMODULE_H
00013 #include "JobControl/JobCInputModule.h"
00014 #endif
00015 #ifndef PER_H
00016 #include "Persistency/Per.h"
00017 #endif
00018 #ifdef SITE_HAS_SIGC
00019 # ifndef __CINT__
00020 # include "sigc++/signal.h"
00021 # endif
00022 #else
00023   // In order to get alignment right when a script using JobC.h 
00024   // is compiled using ACLiC, we must account for the space used by
00025   // the signals below or the offsets for the JobC's member variables
00026   // "Msg" and "Path" are incorrect.
00027 
00028   // ACLiC knows nothing about SITE_HAS_SIGC, nor does it have
00029   // sigc++ in it's include path.
00030 
00031   // This hack assumes the space requirements of sigc++1.2 where
00032   // Signal0 derives from SignalBase which holds only a single
00033   // pointer (4bytes) and neither has a vtbl.
00034 
00035   namespace SigC {
00036     class SignalNode;
00037 
00038     class SignalBasePlaceHolder {
00039     public:
00040       SignalBasePlaceHolder() : impl_(0) { ; }
00041     protected: 
00042       mutable SignalNode *impl_;
00043     };  // SignalBasePlaceHolder
00044     class Signal0PlaceHolder : public SignalBasePlaceHolder {
00045     public:
00046       Signal0PlaceHolder() { ; }
00047     };  // Signal0PlaceHolder
00048   }
00049 #endif
00050 #ifndef ROOT_Rtypes
00051 #if !defined(__CINT__) || defined(__MAKECINT__)
00052 #include "Rtypes.h" // Needed for ClassDef and ClassImp macros
00053 #endif
00054 #endif
00055 
00056 #include <cassert>
00057 
00058 class JobCResult;
00059 class MomNavigator;
00060 
00061 class JobCInput : public JobCInputModule
00062 {
00063 public:
00064   JobCInput();
00065   virtual ~JobCInput();
00066   
00067   // Read in event at current position in input stream
00068   JobCResult Get();
00069   
00070   // Methods to set the position in the record stream
00071   JobCResult Next(int n=1);
00072   JobCResult Prev(int n=1);
00073   JobCResult GoTo(int runNumber, int snarlNumber, int searchDir=0);
00074   JobCResult GoTo(const VldContext& vld);
00075 
00076  // Query methods
00077   Int_t GetCurrentRun() const;
00078   Int_t GetLastRun() const;
00079   const char* GetCurrentFile(const char* streamname="*") const;
00080   const char* GetLastFile(const char* streamname="*") const;
00081   Int_t GetCurrentSnarl() const;
00082 
00083   // Methods to manage the list of attached files
00084   void List(const char* streamlist = "*") const;
00085   void AddFile(const char* filename, const char* streamlist = "*", int at=-1);
00086   void RemoveFile(const char* filename, const char* streamlist = "*");
00087   void DefineStream(const char* stream, const char* tree);
00088   void Select(const char* stream, const char* cut, bool isrequired = false);
00089   void SetSequenceMode(const char* stream, 
00090                        Per::ESequenceMode seqmode=Per::kKey);
00091   void SetTestMode(const char* stream, bool testmode);
00092   void SetPerOwnedDisabled(const char* stream, bool perowneddisabled = true);
00093   void SetWindow(const char* stream, double lower, double upper);
00094 
00095   void SetMaxFileRepeat(const char* stream, int numRepeat);
00096   void SetMeanMom(const char* stream, double mean);
00097   void SetPushRandom(const char* stream, bool setRandom);
00098   void SetRandomSeed(int rSeed);
00099 
00100   // Methods to set the position in the file list
00101   JobCResult NextFile(int n=1, const char* streamlist = "*");
00102   JobCResult PrevFile(int n=1, const char* streamlist = "*");
00103   JobCResult GoToFile(int i=0, const char* streamlist = "*");
00104   JobCResult GoToFile(const char* filename, const char* streamlist = "*");
00105   
00106   // Which job module should we use to implement this class?
00107   void Use(const char* name);
00108 
00109   // Complete the JobModule interface
00110   void BeginJob();
00111   void EndJob();
00112   void BeginFile();
00113   void EndFile();
00114   void BeginRun();
00115   void EndRun();
00116 
00117   // Module configuration
00118   const Registry& DefaultConfig() const;
00119   void            Config(const Registry& r);
00120   Registry&       GetConfig();
00121   
00122   // Input/output
00123   // JobCResult Get(MomNavigator *mom);
00124   // JobCResult Put(const MomNavigator *mom);
00125 
00126   // Interactive mode methods
00127   void Cmd(const char* command);
00128   void HandleCommand(JobCommand *command);
00129   void Help();
00130   void Report();
00131   void Reset();
00132 
00133 #ifdef SITE_HAS_SIGC
00134 # ifndef __CINT__
00135   // Send a signal when methods which change current record set are called
00136   SigC::Signal0<void> SigGet;
00137   SigC::Signal0<void> SigNext;
00138   SigC::Signal0<void> SigPrev;  
00139   SigC::Signal0<void> SigGoTo;
00140 #endif
00141 private:
00142   // SigC::Signal0 derives from SignalBase which has a private operator=
00143   // CINT attempts to generate explicit assignment unless told not to do so
00144   JobCInput& operator= (const JobCInput&); // no assignment
00145 #else
00146   // Inelegant hack to make a script using JobC work when compiled
00147   // with ACLiC.  The declaration of these stand-ins make the alignment
00148   // the same whether compiled externally or via ACLiC (which doesn't
00149   // have SITE_HAS_SIGC defined, nor (even if it did) know where to
00150   // find the sigc++ includes.
00151   
00152   // Names must match usage above or one gets problems with ROOT's 
00153   // automated generation of ShowMembers();
00154 
00155   SigC::Signal0PlaceHolder SigGet;
00156   SigC::Signal0PlaceHolder SigNext;
00157   SigC::Signal0PlaceHolder SigPrev;
00158   SigC::Signal0PlaceHolder SigGoTo;
00159 # endif
00160   
00161 private:
00162   int CheckImpl() const;
00163 
00164 private:
00165   JobCInputModule* fImpl; // The implementation of the input module
00166 
00167   // Get() hides this from base class JobCModule & JobCInputModule
00168   virtual JobCResult Get(MomNavigator*) { assert(0); return JobCResult::kFatal; }
00169 
00170   ClassDef(JobCInput,0) // JobControl's interface to input module(s)
00171 };
00172 
00173 #endif
00174 

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