00001 #ifndef cbvsreadmgr_h
00002 #define cbvsreadmgr_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "cbvsio.h"
00017 #include "cbvsinfo.h"
00018 #include "datainterp.h"
00019 #include <iosfwd>
00020 class CBVSReader;
00021 class CBVSInfo;
00022 class CubeSampling;
00023
00024
00029 mClass CBVSReadMgr : public CBVSIOMgr
00030 {
00031 public:
00032
00033 CBVSReadMgr(const char*,const CubeSampling* cs=0,
00034 bool single_file=false,
00035 bool glob_info_only=false);
00038 ~CBVSReadMgr();
00039
00040 const CBVSInfo& info() const { return info_; }
00041 void close();
00042
00043 BinID nextBinID() const;
00044 bool goTo(const BinID&);
00045 bool toNext();
00046 bool toStart();
00047
00048 bool getAuxInfo(PosAuxInfo&);
00049 bool fetch(void**,const bool* comps=0,
00050 const Interval<int>* samps=0);
00052
00053 static const char* check(const char*);
00056
00057 int nrComponents() const;
00058 const BinID& binID() const;
00059 bool hasAuxInfo() const { return haveaux_; }
00060 void fetchAuxInfo(bool yn=true);
00062 void getIsRev(bool& inl, bool& crl) const;
00063
00064 const char* baseFileName() const
00065 { return (const char*)basefname_; }
00066
00067 int nrReaders() const
00068 { return readers_.size(); }
00069 const CBVSReader& reader( int idx ) const
00070 { return *readers_[idx]; }
00071 int pruneReaders(const CubeSampling&);
00073
00074 void dumpInfo(std::ostream&,bool include_compinfo) const;
00075 const TypeSet<Coord>& trailerCoords() const;
00076 void getPositions(TypeSet<BinID>&) const;
00077 void getPositions(TypeSet<Coord>&) const;
00079
00080 protected:
00081
00082 ObjectSet<CBVSReader> readers_;
00083 CBVSInfo& info_;
00084 bool vertical_;
00085 DataInterpreter<int> iinterp;
00086 DataInterpreter<float> finterp;
00087 DataInterpreter<double> dinterp;
00088 int rdr1firstsampnr_;
00089
00090 bool addReader(std::istream*,const CubeSampling*,bool);
00091 bool addReader(const char*,const CubeSampling*,bool);
00092 int nextRdrNr(int) const;
00093 const char* errMsg_() const;
00094
00095 bool haveaux_;
00096 std::istream* auxstrm_;
00097 int auxinlidx_;
00098 int auxcrlidx_;
00099 ObjectSet<AuxInlInf> auxinlinfs_;
00100 int auxnrbytes_;
00101 unsigned char auxflgs_;
00102
00103 void getAuxFromFile(PosAuxInfo&);
00104
00105 private:
00106
00107 void createInfo();
00108 bool handleInfo(CBVSReader*,int);
00109 void handleAuxFile();
00110 void handleAuxTrailer();
00111
00112 };
00113
00114
00115 #endif