Go to the documentation of this file.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 <vcl_atomic_count.h>
00021 #include <vil/vil_pixel_format.h>
00022 #include <vil/vil_smart_ptr.h>
00023
00024
00025
00026
00027 class vil_image_view_base
00028 {
00029 protected:
00030
00031 unsigned ni_;
00032
00033 unsigned nj_;
00034
00035 unsigned nplanes_;
00036
00037 vil_image_view_base(unsigned n_i, unsigned n_j, unsigned n_planes):
00038 ni_(n_i), nj_(n_j), nplanes_(n_planes), reference_count_(0) {}
00039
00040
00041
00042 vil_image_view_base(): ni_(0), nj_(0), nplanes_(1), reference_count_(0) {}
00043
00044 public:
00045
00046 virtual ~vil_image_view_base() { assert( reference_count_ == 0 ); }
00047
00048
00049 unsigned ni() const {return ni_;}
00050
00051 unsigned nj() const {return nj_;}
00052
00053 unsigned nplanes() const {return nplanes_;}
00054
00055
00056 unsigned long size() const { return ni_ * nj_ * nplanes_; }
00057
00058
00059
00060 virtual void set_size(unsigned width, unsigned height) =0;
00061
00062
00063
00064 virtual void set_size(unsigned width, unsigned height, unsigned n_planes) =0;
00065
00066
00067 virtual void print(vcl_ostream&) const =0;
00068
00069
00070 virtual vcl_string is_a() const =0;
00071
00072
00073
00074
00075
00076 virtual enum vil_pixel_format pixel_format() const=0;
00077
00078
00079 virtual bool is_class(vcl_string const& s) const { return s=="vil_image_view_base"; }
00080
00081 private:
00082
00083
00084 friend class vil_smart_ptr<vil_image_view_base>;
00085 void ref() { ++reference_count_; }
00086 void unref() {
00087 assert(reference_count_>0);
00088 if (--reference_count_<=0) delete this;}
00089 vcl_atomic_count reference_count_;
00090 };
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 typedef vil_smart_ptr<vil_image_view_base> vil_image_view_base_sptr;
00101
00102
00103 inline
00104 vcl_ostream& operator<<(vcl_ostream& s, vil_image_view_base const& im)
00105 { im.print(s); return s; }
00106
00107 #endif // vil_image_view_base_h_