core/vbl/io/vbl_io_smart_ptr.h
Go to the documentation of this file.
00001 // This is core/vbl/io/vbl_io_smart_ptr.h
00002 #ifndef vbl_io_smart_ptr_h
00003 #define vbl_io_smart_ptr_h
00004 //:
00005 // \file
00006 // \brief Serialised binary IO functions for vbl_smart_ptr<T>
00007 // \author Ian Scott (Manchester)
00008 // \date 26-Mar-2001
00009 //
00010 // In order to use IO for smart pointers you will need to have
00011 // the IO functions defined for pointers to MY_CLASS (class T.)
00012 // If you have written I/O for polymorphic classes, some of these
00013 // functions may already be defined.
00014 //
00015 // If you need to write them, you can use the following as examples
00016 // \code
00017 // void vsl_b_read(vsl_b_istream& is, impl * &p)
00018 // {
00019 //   delete p;
00020 //   bool not_null_ptr;
00021 //   vsl_b_read(is, not_null_ptr);
00022 //   if (not_null_ptr)
00023 //   {
00024 //     p = new MY_CLASS();
00025 //     vsl_b_read(is, *p);
00026 //   }
00027 //   else
00028 //     p = 0;
00029 // }
00030 //
00031 // void vsl_b_write(vsl_b_ostream& os, const MY_CLASS *p)
00032 // {
00033 //   if (p==0)
00034 //   {
00035 //     vsl_b_write(os, false); // Indicate null pointer stored
00036 //   }
00037 //   else
00038 //   {
00039 //     vsl_b_write(os,true); // Indicate non-null pointer stored
00040 //     vsl_b_write(os,*p);
00041 //   }
00042 // }
00043 //
00044 // void vsl_print_summary(vcl_ostream& os, const MY_CLASS *p)
00045 // {
00046 //   if (p==0)
00047 //     os << "NULL PTR";
00048 //   else
00049 //   {http://www.isbe.man.ac.uk/internal/software/c++/vxl-doxygen/
00050 //                              vcl/html/class_vcl_not_equal_to.html
00051 //     os << "T: ";
00052 //     vsl_print_summary(os, *p);
00053 //   }
00054 // }
00055 // \endcode
00056 //
00057 // Objects using I/O via a smart ptr, should not save the objects reference count.
00058 
00059 #include <vsl/vsl_fwd.h>
00060 #include <vbl/vbl_smart_ptr.h>
00061 #include <vcl_iosfwd.h>
00062 
00063 //: Binary save vbl_smart_ptr to stream.
00064 template <class T>
00065 void vsl_b_write(vsl_b_ostream & os, const vbl_smart_ptr<T> & v);
00066 
00067 //: Binary load vbl_smart_ptr from stream.
00068 template <class T>
00069 void vsl_b_read(vsl_b_istream & is, vbl_smart_ptr<T> & v);
00070 
00071 //: Print human readable summary of object to a stream
00072 template <class T>
00073 void vsl_print_summary(vcl_ostream & os,const vbl_smart_ptr<T> & b);
00074 
00075 #endif // vbl_io_smart_ptr_h