00001
00002 #ifndef SequenceFileName_h_
00003 #define SequenceFileName_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013 #include <vcl_string.h>
00014 #include <vcl_iosfwd.h>
00015
00016 class SequenceFileName
00017 {
00018 public:
00019
00020
00021 SequenceFileName(char const* s, char const* read_or_write = "r");
00022 SequenceFileName(char const* s, int start_frame, int step, char const* read_or_write = "r");
00023
00024 void set_default_extension(char const* ext);
00025 vcl_string name(int frame);
00026 vcl_ostream& print(vcl_ostream& s) const;
00027
00028
00029 void probe_limits();
00030
00031 int real_index(int index) const { return start_frame_ + index * step_; }
00032
00033 int get_start_frame() const { return start_frame_; }
00034 int get_step() const { return step_; }
00035 int get_end() const { return end_; }
00036
00037 int n() const { return n_; }
00038
00039 void set_end(int e) {
00040 end_ = e;
00041 n_ = (end_ - start_frame_) / step_ + 1;
00042 }
00043
00044 public:
00045
00046 vcl_string fmt_;
00047 bool ok_;
00048 vcl_string ext_;
00049 int start_frame_;
00050 int step_;
00051 int end_;
00052 int n_;
00053
00054 protected:
00055 void init(char const* s, int start_frame, int step, char const* read_or_write = "r");
00056 static bool exists(const vcl_string& fmt, const char* extension, int real_frame_index);
00057 };
00058
00059 inline vcl_ostream& operator<<(vcl_ostream& s, const SequenceFileName& p) { return p.print(s); }
00060
00061 #endif // SequenceFileName_h_