contrib/brl/bseg/bbgm/bbgm_image_of.txx
Go to the documentation of this file.
00001 // This is brl/bseg/bbgm/bbgm_image_of.txx
00002 #ifndef bbgm_image_of_txx_
00003 #define bbgm_image_of_txx_
00004 //:
00005 // \file
00006 
00007 #include "bbgm_image_of.h"
00008 #include <vcl_typeinfo.h>
00009 #include <vbl/io/vbl_io_array_2d.h>
00010 
00011 
00012 //===========================================================================
00013 // Binary I/O Methods
00014 
00015 
00016 //: Return a string name
00017 // \note this is probably not portable
00018 template<class dist_>
00019 vcl_string
00020 bbgm_image_of<dist_>::is_a() const
00021 {
00022   return "bbgm_image_of<"+vcl_string(typeid(dist_).name())+">";
00023 }
00024 
00025 
00026 template<class dist_>
00027 bbgm_image_base*
00028 bbgm_image_of<dist_>::clone() const
00029 {
00030   return new bbgm_image_of<dist_>(*this);
00031 }
00032 
00033 
00034 //: Return IO version number;
00035 template<class dist_>
00036 short
00037 bbgm_image_of<dist_>::version() const
00038 {
00039   return 1;
00040 }
00041 
00042 
00043 //: Binary save self to stream.
00044 template<class dist_>
00045 void
00046 bbgm_image_of<dist_>::b_write(vsl_b_ostream &os) const
00047 {
00048   vsl_b_write(os, version());
00049   vsl_b_write(os, data_);
00050 }
00051 
00052 
00053 //: Binary load self from stream.
00054 template<class dist_>
00055 void
00056 bbgm_image_of<dist_>::b_read(vsl_b_istream &is)
00057 {
00058   if (!is)
00059     return;
00060   short ver;
00061   vsl_b_read(is, ver);
00062   switch (ver)
00063   {
00064     case 1:
00065       vsl_b_read(is, data_);
00066       break;
00067     default:
00068       vcl_cerr << "bbgm_image: unknown I/O version " << ver << '\n';
00069   }
00070 }
00071 
00072 
00073 #include <vbl/io/vbl_io_array_2d.txx>
00074 
00075 #define BBGM_IMAGE_INSTANTIATE(T) \
00076 template class bbgm_image_of<T >; \
00077 VBL_IO_ARRAY_2D_INSTANTIATE(T)
00078 
00079 
00080 #endif // bbgm_image_of_txx_