core/vgl/io/vgl_io_homg_point_1d.txx
Go to the documentation of this file.
00001 // This is core/vgl/io/vgl_io_homg_point_1d.txx
00002 #ifndef vgl_io_homg_point_1d_txx_
00003 #define vgl_io_homg_point_1d_txx_
00004 //:
00005 // \file
00006 // \author Peter Vanroose
00007 // \date 24 Oct 2002
00008 
00009 #include "vgl_io_homg_point_1d.h"
00010 
00011 //============================================================================
00012 //: Binary save self to stream.
00013 template<class T>
00014 void vsl_b_write(vsl_b_ostream& os, vgl_homg_point_1d<T> const& p)
00015 {
00016   const short io_version_no = 1;
00017   vsl_b_write(os, io_version_no);
00018   vsl_b_write(os, p.x());
00019   vsl_b_write(os, p.w());
00020 }
00021 
00022 //============================================================================
00023 //: Binary load self from stream.
00024 template<class T>
00025 void vsl_b_read(vsl_b_istream& is, vgl_homg_point_1d<T> & p)
00026 {
00027   if (!is) return;
00028 
00029   short v;
00030   vsl_b_read(is, v);
00031   switch (v)
00032   {
00033    case 1:
00034     T x, w;
00035     vsl_b_read(is, x);
00036     vsl_b_read(is, w);
00037     p.set(x,w);
00038     break;
00039 
00040    default:
00041     vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vgl_homg_point_1d<T>&)\n"
00042              << "           Unknown version number "<< v << '\n';
00043     is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on stream
00044     return;
00045   }
00046 }
00047 
00048 
00049 //============================================================================
00050 //: Output a human readable summary to the stream
00051 template<class T>
00052 void vsl_print_summary(vcl_ostream& os, vgl_homg_point_1d<T> const& p)
00053 {
00054   os<<'('<<p.x()<<','<<p.w()<<')';
00055 }
00056 
00057 #define VGL_IO_HOMG_POINT_1D_INSTANTIATE(T) \
00058 template void vsl_print_summary(vcl_ostream&, vgl_homg_point_1d<T > const&); \
00059 template void vsl_b_read(vsl_b_istream&, vgl_homg_point_1d<T > &); \
00060 template void vsl_b_write(vsl_b_ostream&, vgl_homg_point_1d<T > const&)
00061 
00062 #endif // vgl_io_homg_point_1d_txx_