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