contrib/brl/bbas/bsta/io/bsta_io_attributes.h
Go to the documentation of this file.
00001 // This is brl/bbas/bsta/io/bsta_io_attributes.h
00002 #ifndef bsta_io_attributes_h_
00003 #define bsta_io_attributes_h_
00004 //:
00005 // \file
00006 // \brief Binary I/O for attributed distributions
00007 // \author Matt Leotta (mleotta@lems.brown.edu)
00008 // \date March 28, 2006
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   <none yet>
00013 // \endverbatim
00014 
00015 #include <bsta/bsta_attributes.h>
00016 #include <vsl/vsl_binary_io.h>
00017 #include <vcl_iostream.h>
00018 
00019 //: Binary save bsta_attributes to stream.
00020 template <class comp_>
00021 void
00022 vsl_b_write(vsl_b_ostream &os, const bsta_num_obs<comp_>& m)
00023 {
00024   comp_ n=static_cast<comp_>(m);
00025 
00026   //vcl_cout<<sizeof(n)<<' '<<sizeof(m)<<':';
00027   vsl_b_write(os,n);
00028   //vsl_b_write(os,(int)1);
00029   vsl_b_write(os,m.num_observations);
00030 }
00031 
00032 //: Binary load bsta_attributes from stream.
00033 template <class comp_>
00034 void
00035 vsl_b_read(vsl_b_istream &is, bsta_num_obs<comp_>& m)
00036 {
00037   comp_ dstrb;
00038   vsl_b_read(is,dstrb);
00039   // int a; vsl_b_read(is,a);
00040   m = bsta_num_obs<comp_>(dstrb);
00041   vsl_b_read(is,m.num_observations);
00042 }
00043 
00044 //: Print summary
00045 template <class comp_>
00046 void
00047 vsl_print_summary(vcl_ostream &os, const bsta_num_obs<comp_>& m)
00048 {
00049   vsl_print_summary(os,static_cast<comp_>(m));
00050   os << " with "<<m.num_observations<<" observations";
00051 }
00052 
00053 
00054 #endif // bsta_io_attributes_h_