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

IoDataStreamItr.h

Go to the documentation of this file.
00001 
00002 // $Id: IoDataStreamItr.h,v 1.12 2009/01/05 05:55:13 schubert Exp $
00003 //
00004 // Abstract base class for a iterator for an input data stream. This
00005 // base class is subclassed for different data sources.
00006 //
00007 // All IoDataStreamItr's should have the following behavior:
00008 //
00009 // * Upon creation the IoDataStreamItr should be placed on a "begin
00010 // file" marker. Ie. to get to the first valid record set in the
00011 // stream one should do an Increment().
00012 //
00013 // * Increment() should return the number of record sets the position
00014 // in the data stream was advanced by. In the case where the Next
00015 // request would advance past the EOF marker Increment should place
00016 // the position in the input stream at the EOF marker and return the
00017 // number of records sets actually advanced to reach the last record
00018 // set.
00019 //
00020 // * If the position in the data stream is at the EOF or the BOF
00021 // marker, LoadRecords() should return 0.
00022 //
00023 // * Decrement() should return the number of record sets the position
00024 // in the data stream was backed up by. In the case where the Prev
00025 // request would advance past the BOF marker Decrement should the
00026 // position in the input stream at the BOF marker and return the
00027 // number of record sets actually traversed to reach the first record
00028 // set.
00029 //
00030 // Here's an example for a stream with 5 record sets in it:
00031 //
00032 //      Next's:    1-> 2-> 3-> 4-> 5-> 6-> (7th Next returns 0, stays at EOF)
00033 // Record Sets: BOF   0   1   2   3   4   5   EOF(6)
00034 //      Prev's:    <-6 <-5 <-4 <-3 <-2 <-1
00035 //              |
00036 //              (7th Prev returns 0, leaving the position at BOF)
00037 //
00038 // messier@huhepl.harvard.edu
00040 #ifndef IODATASTREAMITR_H
00041 #define IODATASTREAMITR_H
00042 
00043 #ifndef JOBCRESULT_H
00044 #include "JobControl/JobCResult.h"
00045 #endif
00046 #ifndef STRING
00047 #include <string>
00048 #define STRING
00049 #endif
00050 #ifndef LIST
00051 #include <list>
00052 #define LIST
00053 #endif
00054 #ifndef PER_H
00055 #include "Persistency/Per.h"
00056 #endif
00057 
00058 class MomNavigator;
00059 class VldContext;
00060 
00061 class IoDataStreamItr {
00062 
00063 public:
00064   IoDataStreamItr();
00065   IoDataStreamItr(const char* sourceName);
00066   virtual ~IoDataStreamItr();
00067   
00068   const char* GetSourceName() const { return fSourceName.c_str(); }
00069   void        SetSourceName(const char* name) { fSourceName = name; }
00070 
00071   // Sub-classes must implement these for themselves
00072   virtual bool        IsValid() const                                = 0;
00073   virtual const char* GetFormat() const                              = 0;
00074   virtual int         LoadRecords(MomNavigator* mom)                 = 0;
00075   virtual int         Increment(int n=1, MomNavigator* m=0)          = 0;
00076   virtual int         Decrement(int n=1, MomNavigator* m=0)          = 0;
00077   virtual JobCResult  GoTo(const VldContext& vld, MomNavigator* m=0) = 0;
00078 
00079   // Default implementation provided for these (most are dummy)
00080   virtual int  GoToEOF();
00081   virtual int  DefineStream(const char* streamname, const char* treename);
00082   virtual int  Streams(const char* streamlist);
00083   virtual int  Select(const char* stream, const char* selection, bool isRequired = false);
00084   virtual int  SetSequenceMode(const char* stream, Per::ESequenceMode seqmode);
00085   virtual int  SetPerOwnedDisabled(const char* stream, 
00086                                    bool perowneddisabled = true);    
00087   virtual int  SetWindow(const char* stream, double lower, double upper);
00088   virtual void SetPort(unsigned int port);
00089   virtual void SetTimeOut(unsigned int seconds);
00090 
00091   virtual int  SetMaxFileRepeat(const char* stream,int numRepeat);
00092   virtual int  SetMeanMom(const char* stream, double mean);
00093   virtual int  SetPushRandom(const char* stream, bool setRandom);
00094   virtual void SetRandomSeed(int rSeed);
00095   virtual int  SetTestMode(const char* stream,bool testmode);
00096   
00097   // File list manipulation default implementation
00098   virtual void AddFile(const char* fullfilepathname, int at = -1,
00099                        const char* streamlist = "*");
00100   virtual const char* GetCurrentFile(const char* streamname = "*") const;
00101   virtual JobCResult GoToFile(int i, const char* streamlist = "*");
00102   virtual JobCResult GoToFile(const char* fullfilepathname, 
00103                               const char* streamlist = "*");
00104   virtual JobCResult NextFile(int n = 1, const char* streamlist = "*");
00105   virtual JobCResult PrevFile(int n = 1, const char* streamlist = "*");
00106   virtual void RemoveFile(const char* fullfilepathname="*",
00107                           const char* streamlist="*");
00108   virtual std::ostream& ListFile(std::ostream& os, 
00109                                  const char* streamlist = "*") const;
00110   
00111  private:
00112   // File manipulation default implementation, these are dummy methods
00113   virtual JobCResult OpenFile();
00114   virtual void       CloseFile();
00115 
00116   std::string fSourceName;  // The source of data records
00117   std::list<std::string> fFileList; // file list used for def implementation
00118   std::list<std::string>::iterator fFileListItr; // current file ptr def imp
00119   bool fIsBOF; // at beginning of file list if true
00120 
00121 };
00122 
00123 #endif
00124 

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