00001
00002 #ifndef vil_image_view_base_h_
00003 #define vil_image_view_base_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <vcl_iosfwd.h>
00018 #include <vcl_string.h>
00019 #include <vcl_cassert.h>
00020 #include <vil/vil_pixel_format.h>
00021 #include <vil/vil_smart_ptr.h>
00022
00023
00024
00025
00026 class vil_image_view_base
00027 {
00028 protected:
00029
00030 unsigned ni_;
00031
00032 unsigned nj_;
00033
00034 unsigned nplanes_;
00035
00036 vil_image_view_base(unsigned n_i, unsigned n_j, unsigned n_planes):
00037 ni_(n_i), nj_(n_j), nplanes_(n_planes), reference_count_(0) {}
00038
00039
00040
00041 vil_image_view_base(): ni_(0), nj_(0), nplanes_(1), reference_count_(0) {}
00042
00043 public:
00044
00045 virtual ~vil_image_view_base() { assert( reference_count_ == 0 ); }
00046
00047
00048 unsigned ni() const {return ni_;}
00049
00050 unsigned nj() const {return nj_;}
00051
00052 unsigned nplanes() const {return nplanes_;}
00053
00054
00055 unsigned long size() const { return ni_ * nj_ * nplanes_; }
00056
00057
00058
00059 virtual void set_size(unsigned width, unsigned height) =0;
00060
00061
00062
00063 virtual void set_size(unsigned width, unsigned height, unsigned n_planes) =0;
00064
00065
00066 virtual void print(vcl_ostream&) const =0;
00067
00068
00069 virtual vcl_string is_a() const =0;
00070
00071
00072
00073
00074
00075 virtual enum vil_pixel_format pixel_format() const=0;
00076
00077
00078 virtual bool is_class(vcl_string const& s) const { return s=="vil_image_view_base"; }
00079
00080 private:
00081
00082
00083 friend class vil_smart_ptr<vil_image_view_base>;
00084 void ref() { ++reference_count_; }
00085 void unref() {
00086 assert(reference_count_>0);
00087 if (--reference_count_<=0) delete this;}
00088 int reference_count_;
00089 };
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 typedef vil_smart_ptr<vil_image_view_base> vil_image_view_base_sptr;
00100
00101
00102 inline
00103 vcl_ostream& operator<<(vcl_ostream& s, vil_image_view_base const& im)
00104 { im.print(s); return s; }
00105
00106 #endif // vil_image_view_base_h_