core/vil/vil_cached_image_resource.h
Go to the documentation of this file.
00001 // This is core/vil/vil_cached_image_resource.h
00002 #ifndef vil_cached_image_resource_h_
00003 #define vil_cached_image_resource_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief A cached and blocked representation of the image_resource
00010 // \author J. L. Mundy
00011 
00012 #include <vil/vil_blocked_image_resource.h>
00013 #include <vil/vil_block_cache.h>
00014 
00015 class vil_cached_image_resource : public vil_blocked_image_resource
00016 {
00017  public:
00018 
00019   vil_cached_image_resource(vil_blocked_image_resource_sptr bir,
00020                             const unsigned cache_size):
00021     bir_(bir), cache_(vil_block_cache(cache_size)){}
00022 
00023   virtual ~vil_cached_image_resource(){}
00024 
00025  inline virtual unsigned nplanes() const
00026     {return bir_->nplanes();}
00027  inline virtual unsigned ni() const
00028     {return bir_->ni();}
00029  inline virtual unsigned nj() const
00030   {return bir_->nj();}
00031   //: Block size in columns
00032  inline virtual unsigned size_block_i() const
00033     {return bir_->size_block_i();}
00034   //: Block size in rows
00035  inline virtual unsigned size_block_j() const
00036     {return bir_->size_block_j();}
00037   //: Number of blocks in image width
00038  inline virtual unsigned n_block_i() const
00039     {return bir_->n_block_i();}
00040   //: Number of blocks in image height
00041  inline virtual unsigned n_block_j() const
00042     {return bir_->n_block_j();}
00043 
00044  inline virtual enum vil_pixel_format pixel_format() const
00045     {return bir_->pixel_format();}
00046 
00047  inline virtual bool put_view(const vil_image_view_base& im, unsigned i0, unsigned j0) {return bir_->put_view(im, i0, j0);}
00048 
00049   //: Block access
00050   virtual vil_image_view_base_sptr get_block( unsigned  block_index_i,
00051                                               unsigned  block_index_j ) const;
00052 
00053   //: put the block into the resource at the indicated location
00054   virtual bool put_block(unsigned  block_index_i,
00055                          unsigned  block_index_j,
00056                          const vil_image_view_base& view)
00057     {return bir_->put_block(block_index_i, block_index_j, view);}
00058 
00059 
00060   //: Extra property information
00061  inline virtual bool get_property(char const* tag, void* property_value = 0) const
00062     {return bir_->get_property(tag, property_value);}
00063 
00064  protected:
00065   vil_blocked_image_resource_sptr bir_;
00066   vil_block_cache cache_;
00067 };
00068 
00069 #endif // vil_cached_image_resource_h_